Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Bug fixes for empty state in calculatorActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Rminsh committed Sep 10, 2020
1 parent f66e353 commit b2d0198
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId "com.shalchian.sarrafi"
minSdkVersion 19
targetSdkVersion 30
versionCode 10
versionName "1.1.0"
versionCode 11
versionName "1.1.1"
multiDexEnabled true
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.shalchian.sarrafi.R;
import com.shalchian.sarrafi.adapter.UnitAdapter;
import com.shalchian.sarrafi.model.UnitItem;
import com.shalchian.sarrafi.utils.ActivityHelper;
import com.shalchian.sarrafi.utils.JSONParser;

import org.json.JSONException;
Expand Down Expand Up @@ -127,7 +128,15 @@ protected void onCreate(Bundle savedInstanceState) {
unitItems = new ArrayList<>();
unitAdapter = new UnitAdapter(this, unitItems);

getData();
checkConnection();

status_button.setOnClickListener(view -> {
status_button.setVisibility(View.GONE);
status_animation.setAnimation("loading_animation.json");
status_animation.playAnimation();
status_text.setText("");
checkConnection();
});

spinnerFirst.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
Expand Down Expand Up @@ -187,6 +196,14 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
});
}

public void checkConnection() {
if (ActivityHelper.checkConnection(getBaseContext())) {
getData();
} else {
showProblem(getResources().getString(R.string.no_network));
}
}

public void getData() {
AndroidNetworking
.get(mainUrl)
Expand Down

0 comments on commit b2d0198

Please sign in to comment.