/*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
* This file is part of MoLe.
* MoLe is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.GetOptCallback;
import net.ktnx.mobileledger.utils.LockHolder;
+import net.ktnx.mobileledger.utils.Logger;
import net.ktnx.mobileledger.utils.MLDB;
import org.jetbrains.annotations.NotNull;
protected void onStart() {
super.onStart();
+ Logger.debug("MainActivity", "onStart()");
+
mViewPager.setCurrentItem(mCurrentPage, false);
}
@Override
}
@Override
protected void onCreate(Bundle savedInstanceState) {
+ debug("MainActivity", "onCreate()/entry");
super.onCreate(savedInstanceState);
- debug("flow", "MainActivity.onCreate()");
+ debug("MainActivity", "onCreate()/after super");
setContentView(R.layout.activity_main);
fab = findViewById(R.id.btn_add_transaction);
};
drawer.addDrawerListener(drawerListener);
}
+
+ Data.drawerOpen.observe(this, open -> {
+ if (open)
+ drawer.open();
+ else
+ drawer.close();
+ });
}
private void scheduleDataRetrievalIfStale(Date lastUpdate) {
long now = new Date().getTime();
if (!p.isPostingPermitted())
continue;
- ShortcutInfo si =
- new ShortcutInfo.Builder(this, "new_transaction_" + p.getUuid()).setShortLabel(
- p.getName())
- .setIcon(
- Icon.createWithResource(
- this,
- R.drawable.svg_thick_plus_white))
- .setIntent(
- new Intent(
- Intent.ACTION_VIEW,
- null,
- this,
- NewTransactionActivity.class).putExtra(
- "profile_uuid",
- p.getUuid()))
- .setRank(i)
- .build();
+ final ShortcutInfo.Builder builder =
+ new ShortcutInfo.Builder(this, "new_transaction_" + p.getUuid());
+ ShortcutInfo si = builder.setShortLabel(p.getName())
+ .setIcon(Icon.createWithResource(this,
+ R.drawable.thick_plus_icon))
+ .setIntent(new Intent(Intent.ACTION_VIEW, null, this,
+ NewTransactionActivity.class).putExtra("profile_uuid",
+ p.getUuid()))
+ .setRank(i)
+ .build();
shortcuts.add(si);
i++;
}
sm.setDynamicShortcuts(shortcuts);
}
private void onProfileListChanged(List<MobileLedgerProfile> newList) {
- if (newList == null) {
- // profiles not yet loaded from DB
- findViewById(R.id.loading_layout).setVisibility(View.VISIBLE);
- findViewById(R.id.no_profiles_layout).setVisibility(View.GONE);
- findViewById(R.id.main_app_layout).setVisibility(View.GONE);
- return;
- }
-
- if (newList.isEmpty()) {
+ if ((newList == null) || newList.isEmpty()) {
findViewById(R.id.no_profiles_layout).setVisibility(View.VISIBLE);
findViewById(R.id.main_app_layout).setVisibility(View.GONE);
- findViewById(R.id.loading_layout).setVisibility(View.GONE);
return;
}
findViewById(R.id.main_app_layout).setVisibility(View.VISIBLE);
findViewById(R.id.no_profiles_layout).setVisibility(View.GONE);
- findViewById(R.id.loading_layout).setVisibility(View.GONE);
findViewById(R.id.nav_profile_list).setMinimumHeight(
(int) (getResources().getDimension(R.dimen.thumb_row_height) * newList.size()));
mProfileListAdapter.notifyDataSetChanged();
- drawer.closeDrawers();
-
Data.transactions.clear();
debug("transactions", "requesting list reload");
TransactionListViewModel.scheduleTransactionListReload();