import net.ktnx.mobileledger.ui.transaction_list.TransactionListViewModel;
import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.LockHolder;
-import net.ktnx.mobileledger.utils.Logger;
import net.ktnx.mobileledger.utils.MLDB;
import org.jetbrains.annotations.NotNull;
-import java.lang.ref.WeakReference;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
private LinearLayout profileListContainer;
private View profileListHeadArrow, profileListHeadMore, profileListHeadCancel;
private FragmentManager fragmentManager;
- private RetrieveTransactionsTask retrieveTransactionsTask;
private View bTransactionListCancelDownload;
private ProgressBar progressBar;
private LinearLayout progressLayout;
super.onDestroy();
}
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- debug("flow", "MainActivity.onCreate()");
+ protected void setupProfileColors() {
int profileColor = Data.retrieveCurrentThemeIdFromDb();
Colors.setupTheme(this, profileColor);
Colors.profileThemeId = profileColor;
+ }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ debug("flow", "MainActivity.onCreate()");
setContentView(R.layout.activity_main);
fab = findViewById(R.id.btn_add_transaction);
"WEB data last fetched at %1.3f and now is %1.3f. re-fetching",
lastUpdate.getTime() / 1000f, now / 1000f));
- scheduleTransactionListRetrieval();
+ Data.scheduleTransactionListRetrieval(this);
}
}
private void createShortcuts(List<MobileLedgerProfile> list) {
scheduleDataRetrievalIfStale(newValue);
}
private void profileThemeChanged() {
- setupProfileColors();
-
Bundle bundle = new Bundle();
onSaveInstanceState(bundle);
// restart activity to reflect theme change
Data.lastUpdateDate.postValue(new Date(last_update));
}
}
- public void scheduleTransactionListRetrieval() {
- if (Data.profile.get() == null) return;
-
- retrieveTransactionsTask = new RetrieveTransactionsTask(new WeakReference<>(this));
-
- retrieveTransactionsTask.execute();
- }
public void onStopTransactionRefreshClick(View view) {
debug("interactive", "Cancelling transactions refresh");
- if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false);
+ Data.stopTransactionsRetrieval();
bTransactionListCancelDownload.setEnabled(false);
}
public void onRetrieveDone(String error) {
+ Data.transactionRetrievalDone();
progressLayout.setVisibility(View.GONE);
if (error == null) {