# added preference to base activity

# fixed very unlikely lifecycle bug in LoginActivity
This commit is contained in:
Lukas Niemeier
2013-11-16 18:03:09 +01:00
parent 9b030ae4e4
commit 339669341c
2 changed files with 13 additions and 3 deletions
@@ -6,6 +6,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuInflater;
@@ -53,6 +54,8 @@ public abstract class BaseActivity extends LoggableActivity {
}
private static final String TAG = BaseActivity.class.getName();
protected AppPreferences preferences;
protected MenuItem menuItemLive;
@@ -65,6 +68,12 @@ public abstract class BaseActivity extends LoggableActivity {
public BaseActivity() {
this.sendingServiceConnection = new EventSendingServiceConnection();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.preferences = AppPreferences.on(getApplicationContext());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@@ -177,9 +177,10 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
@Override
public void onDialogPositiveButton(AttachedDialogFragment dialog) {
AppPreferences preferences = AppPreferences.on(dialog.getActivity());
preferences.setAuthor(loginDialog.getAuthor());
switch (loginDialog.getSelectedLoginType()) {
// We have to take the passed instance, LoginActivity.this might be a new instance!
LoginDialog localLoginDialog = (LoginDialog) dialog;
preferences.setAuthor(localLoginDialog.getAuthor());
switch (localLoginDialog.getSelectedLoginType()) {
case OFFICER:
ExLog.i(TAG, "Communication with backend is active.");
preferences.setSendingActive(true);