X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=370c5e2b6e95ab905dd80804df7c3ae238a56b36;hb=db56efb04c4a1c260676e743481b8f67b36e60ed;hp=94c21bf369dc85811611dce2cdaeef3d673f022a;hpb=18c7b6dcb2ab4c3049588335b472663fb569b6c2;p=mobile-ledger-staging.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 94c21bf3..370c5e2b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -36,6 +36,7 @@ import android.widget.TextView; 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; @@ -56,7 +57,6 @@ import net.ktnx.mobileledger.model.Data; 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; @@ -230,14 +230,15 @@ public class MainActivity extends ProfileThemedActivity { } 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) @@ -469,17 +470,6 @@ public class MainActivity extends ProfileThemedActivity { 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); @@ -619,9 +609,19 @@ public class MainActivity extends ProfileThemedActivity { 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; }