Skip to content

Commit

Permalink
Fixed crash on click on map if list is not yet loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
jklmnn committed Jul 6, 2017
1 parent 1c0e000 commit 38b9db7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/de/jkliemann/parkendd/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ public class MainActivity extends AppCompatActivity implements LoaderInterface,
private Loader cityLoader;
private City city;
private NavigationView navigationView;
private MenuItem map_action;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((ParkenDD) getApplication()).getTracker().trackAppDownload();
setContentView(R.layout.activity_main);

//navigationView.getMenu().getItem(R.id.action_map).setEnabled(false);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Expand Down Expand Up @@ -152,6 +155,7 @@ public void onLoaderFinished(String data[], Loader loader){
String locDate = dateFormat.format(city.last_updated());
String locTime = timeFormat.format(city.last_updated());
Error.showLongErrorToast(this, getString(R.string.last_update) + ": " + locDate + " " + locTime);
map_action.setEnabled(true);
onProgressUpdated();
}catch (JSONException e){
e.printStackTrace();
Expand Down Expand Up @@ -291,6 +295,8 @@ private void setList(City CITY){
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
map_action = menu.findItem(R.id.action_map);
map_action.setEnabled(false);
return true;
}

Expand All @@ -311,6 +317,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
startActivity(about);
}
if(id == R.id.action_refresh){
map_action.setEnabled(false);
pg.setMax(4);
pg.setProgress(0);
pg.setVisibility(View.VISIBLE);
Expand Down

0 comments on commit 38b9db7

Please sign in to comment.