Fixed application crash when deactivate service on not MainFragment

This commit is contained in:
PeratX 2017-04-26 21:54:10 +08:00
parent e6d6d5ee92
commit f55c1e024d
2 changed files with 5 additions and 2 deletions

View File

@ -226,13 +226,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Log.d(TAG, "Updating user interface");
int launchAction = intent.getIntExtra(LAUNCH_ACTION, LAUNCH_ACTION_NONE);
if (launchAction == LAUNCH_ACTION_ACTIVATE) {
Daedalus.updateShortcut(this.getApplicationContext());
mMain.activateService();
} else if (launchAction == LAUNCH_ACTION_DEACTIVATE) {
Daedalus.getInstance().deactivateService();
} else if (launchAction == LAUNCH_ACTION_AFTER_DEACTIVATE) {
Daedalus.updateShortcut(this.getApplicationContext());
mHandler.obtainMessage(MainFragment.MainFragmentHandler.MSG_REFRESH).sendToTarget();
if (currentFragment == FRAGMENT_MAIN) {
mHandler.obtainMessage(MainFragment.MainFragmentHandler.MSG_REFRESH).sendToTarget();
}
} else {
Daedalus.updateShortcut(this.getApplicationContext());
}

View File

@ -103,6 +103,8 @@ public class MainFragment extends Fragment {
Button button = (Button) view.findViewById(R.id.button_activate);
button.setText(R.string.button_text_deactivate);
Daedalus.updateShortcut(Daedalus.getInstance());
}
}