creating an instance fails in release builds and there is nothing dynamic
there so a static class seems ok
package net.ktnx.mobileledger.ui.account_summary;
package net.ktnx.mobileledger.ui.account_summary;
-import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
public class AccountSummaryFragment extends MobileLedgerListFragment {
MenuItem mShowOnlyStarred;
public class AccountSummaryFragment extends MobileLedgerListFragment {
MenuItem mShowOnlyStarred;
- private AccountSummaryViewModel model;
private AccountSummaryAdapter modelAdapter;
private Menu optMenu;
private FloatingActionButton fab;
private AccountSummaryAdapter modelAdapter;
private Menu optMenu;
private FloatingActionButton fab;
Log.d("flow", "AccountSummaryFragment.onActivityCreated()");
super.onActivityCreated(savedInstanceState);
Log.d("flow", "AccountSummaryFragment.onActivityCreated()");
super.onActivityCreated(savedInstanceState);
- model = ViewModelProviders.of(this).get(AccountSummaryViewModel.class);
modelAdapter = new AccountSummaryAdapter();
root = mActivity.findViewById(R.id.account_root);
modelAdapter = new AccountSummaryAdapter();
root = mActivity.findViewById(R.id.account_root);
Data.accounts.addObserver(
(o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));
Data.profile.addObserver(
Data.accounts.addObserver(
(o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));
Data.profile.addObserver(
- (o, arg) -> mActivity.runOnUiThread(() -> model.scheduleAccountListReload()));
+ (o, arg) -> mActivity.runOnUiThread(() -> AccountSummaryViewModel.scheduleAccountListReload()));
update_account_table();
}
private void update_account_table() {
if (this.getContext() == null) return;
update_account_table();
}
private void update_account_table() {
if (this.getContext() == null) return;
- model.scheduleAccountListReload();
+ AccountSummaryViewModel.scheduleAccountListReload();
}
void stopSelection() {
modelAdapter.stopSelection();
}
void stopSelection() {
modelAdapter.stopSelection();
task.execute(
new CommitAccountsTaskParams(Data.accounts.get(), Data.optShowOnlyStarred.get()));
}
task.execute(
new CommitAccountsTaskParams(Data.accounts.get(), Data.optShowOnlyStarred.get()));
}
- void scheduleAccountListReload() {
+ static void scheduleAccountListReload() {
if (Data.profile.get() == null) return;
UAT task = new UAT();
if (Data.profile.get() == null) return;
UAT task = new UAT();