]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
multiple profile list fixes
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 760f6aacfbbdfffda4d69ede20cf59dcd4a5f9be..0991a694a3b28d2ea0f5000d5ae4d9a3e4185ed4 100644 (file)
@@ -33,8 +33,6 @@ import android.support.v7.app.ActionBarDrawerToggle;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
 import android.util.Log;
-import android.view.ContextMenu;
-import android.view.MenuItem;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.ProgressBar;
@@ -56,8 +54,6 @@ import java.text.DateFormat;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.Date;
-import java.util.Observable;
-import java.util.Observer;
 
 public class MainActivity extends AppCompatActivity {
     public MobileLedgerListFragment currentFragment = null;
@@ -98,15 +94,12 @@ public class MainActivity extends AppCompatActivity {
         Toolbar toolbar = findViewById(R.id.toolbar);
         setSupportActionBar(toolbar);
 
-        Data.profile.addObserver(new Observer() {
-            @Override
-            public void update(Observable o, Object arg) {
-                MobileLedgerProfile profile = Data.profile.get();
-                runOnUiThread(() -> {
-                    if (profile == null) toolbar.setSubtitle("");
-                    else toolbar.setSubtitle(profile.getName());
-                });
-            }
+        Data.profile.addObserver((o, arg) -> {
+            MobileLedgerProfile profile = Data.profile.get();
+            runOnUiThread(() -> {
+                if (profile == null) toolbar.setSubtitle("");
+                else toolbar.setSubtitle(profile.getName());
+            });
         });
 
         setupProfile();
@@ -217,8 +210,7 @@ public class MainActivity extends AppCompatActivity {
 
         if (profile == null) throw new AssertionError("profile must have a value");
 
-        Data.profile.set(profile);
-        MLDB.set_option_value(MLDB.OPT_PROFILE_UUID, profile.getUuid());
+        Data.setCurrentProfile(profile);
 
         if (profile.getUrl().isEmpty()) {
             Intent intent = new Intent(this, ProfileListActivity.class);
@@ -243,6 +235,7 @@ public class MainActivity extends AppCompatActivity {
     public void nav_settings_clicked(View view) {
         Intent intent = new Intent(this, SettingsActivity.class);
         startActivity(intent);
+        drawer.closeDrawers();
     }
     public void markDrawerItemCurrent(int id) {
         TextView item = drawer.findViewById(id);
@@ -265,29 +258,6 @@ public class MainActivity extends AppCompatActivity {
             }
         }
     }
-    public void onOptionsMenuClicked(MenuItem menuItem) {
-        ContextMenu.ContextMenuInfo info = menuItem.getMenuInfo();
-        switch (menuItem.getItemId()) {
-            case R.id.menu_acc_summary_cancel_selection:
-                if (accountSummaryFragment != null)
-                    accountSummaryFragment.onCancelAccSelection(menuItem);
-                break;
-            case R.id.menu_acc_summary_confirm_selection:
-                if (accountSummaryFragment != null)
-                    accountSummaryFragment.onConfirmAccSelection(menuItem);
-                break;
-            case R.id.menu_acc_summary_only_starred:
-                if (accountSummaryFragment != null)
-                    accountSummaryFragment.onShowOnlyStarredClicked(menuItem);
-                break;
-            case R.id.menu_transaction_list_filter:
-                if (transactionListFragment != null)
-                    transactionListFragment.onShowFilterClick(menuItem);
-                break;
-            default:
-                Log.e("menu", String.format("Menu item %d not handled", menuItem.getItemId()));
-        }
-    }
     public void onViewClicked(View view) {
         switch (view.getId()) {
             case R.id.clearAccountNameFilter: