import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.content.res.ColorStateList;
-import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Icon;
import android.os.AsyncTask;
barDrawerToggle = null;
if (mViewPager != null) mViewPager.removeOnPageChangeListener(pageChangeListener);
pageChangeListener = null;
- if (mProfileListAdapter != null) mProfileListAdapter.deleteEditingProfilesObserver(editingProfilesObserver);
+ if (mProfileListAdapter != null)
+ mProfileListAdapter.deleteEditingProfilesObserver(editingProfilesObserver);
editingProfilesObserver = null;
super.onDestroy();
}
}
if (barDrawerToggle == null) {
- barDrawerToggle = new ActionBarDrawerToggle(this, drawer, mToolbar, R.string.navigation_drawer_open,
- R.string.navigation_drawer_close);
+ barDrawerToggle = new ActionBarDrawerToggle(this, drawer, mToolbar,
+ R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(barDrawerToggle);
}
barDrawerToggle.syncState();
markDrawerItemCurrent(R.id.nav_latest_transactions);
break;
default:
- Log.e("MainActivity", String.format("Unexpected page index %d", position));
+ Log.e("MainActivity",
+ String.format("Unexpected page index %d", position));
}
super.onPageSelected(position);
drawer.addDrawerListener(drawerListener);
}
+ findViewById(R.id.nav_profile_list_head_layout)
+ .setOnClickListener(this::navProfilesHeadClicked);
+ findViewById(R.id.nav_profiles_label).setOnClickListener(this::navProfilesHeadClicked);
setupProfile();
onProfileChanged(null);
updateLastUpdateTextFromDB();
- Date lastUpdate = Data.lastUpdateDate.get();
+ scheduleDataRetrievalIfStale();
+ }
+ private void scheduleDataRetrievalIfStale() {
+ Date lastUpdate = Data.lastUpdateDate.get();
long now = new Date().getTime();
if ((lastUpdate == null) || (now > (lastUpdate.getTime() + (24 * 3600 * 1000)))) {
if (lastUpdate == null) Log.d("db::", "WEB data never fetched. scheduling a fetch");
}
}
private void createShortcuts() {
- Resources rm = getResources();
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
+
List<ShortcutInfo> shortcuts = new ArrayList<>();
try (LockHolder lh = Data.profiles.lockForReading()) {
for (int i = 0; i < Data.profiles.size(); i++) {
.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();
+ .setRank(i).build();
shortcuts.add(si);
}
}
MobileLedgerProfile profile = Data.profile.get();
MainActivity.this.runOnUiThread(() -> {
+ boolean haveProfile = profile != null;
+ findViewById(R.id.no_profiles_layout).setVisibility(haveProfile ? View.GONE : View.VISIBLE);
+ findViewById(R.id.pager_layout)
+ .setVisibility(haveProfile ? View.VISIBLE : View.VISIBLE);
+
Data.transactions.clear();
Log.d("transactions", "requesting list reload");
TransactionListViewModel.scheduleTransactionListReload();
fab.hide();
}
}
+
+ updateLastUpdateTextFromDB();
+
+ scheduleDataRetrievalIfStale();
});
}
private void updateLastUpdateDisplay() {