import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.MainModel;
import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
-import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
import net.ktnx.mobileledger.ui.profiles.ProfilesRecyclerViewAdapter;
import net.ktnx.mobileledger.ui.transaction_list.TransactionListFragment;
import net.ktnx.mobileledger.utils.Colors;
super.onDestroy();
}
@Override
- protected void setupProfileColors() {
- final int profileColor = Data.retrieveCurrentThemeIdFromDb();
- Colors.setupTheme(this, profileColor);
- Colors.profileThemeId = profileColor;
- }
- @Override
protected void onResume() {
super.onResume();
fabShouldShow();
}
findViewById(R.id.btn_no_profiles_add).setOnClickListener(
- v -> startEditProfileActivity(null));
+ v -> MobileLedgerProfile.startEditProfileActivity(this, null));
findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked);
findViewById(R.id.nav_new_profile_button).setOnClickListener(
- v -> startEditProfileActivity(null));
+ v -> MobileLedgerProfile.startEditProfileActivity(this, null));
- findViewById(R.id.transaction_list_cancel_download).setOnClickListener(this::onStopTransactionRefreshClick);
+ findViewById(R.id.transaction_list_cancel_download).setOnClickListener(
+ this::onStopTransactionRefreshClick);
RecyclerView root = findViewById(R.id.nav_profile_list);
if (root == null)
recreate();
}
- public void startEditProfileActivity(MobileLedgerProfile profile) {
- Intent intent = new Intent(this, ProfileDetailActivity.class);
- Bundle args = new Bundle();
- if (profile != null) {
- int index = Data.getProfileIndex(profile);
- if (index != -1)
- intent.putExtra(ProfileDetailFragment.ARG_ITEM_ID, index);
- }
- intent.putExtras(args);
- startActivity(intent, args);
- }
public void fabNewTransactionClicked(View view) {
Intent intent = new Intent(this, NewTransactionActivity.class);
startActivity(intent);
mainModel.transactionRetrievalDone();
- if (progress.getError() != null) {
- Snackbar.make(mViewPager, progress.getError(), Snackbar.LENGTH_LONG)
- .show();
+ String error = progress.getError();
+ if (error != null) {
+ if (error.equals(RetrieveTransactionsTask.Result.ERR_JSON_PARSER_ERROR))
+ error = getResources().getString(R.string.err_json_parser_error);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(error);
+ builder.setPositiveButton(R.string.btn_profile_options, (dialog, which) -> {
+ Logger.debug("error", "will start profile editor");
+ MobileLedgerProfile.startEditProfileActivity(this, profile);
+ });
+ builder.create()
+ .show();
return;
}