From 0e1ae0f10b4dd5bb6b268f6d448c8cae94f14a33 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 18 May 2019 12:42:03 +0300 Subject: [PATCH] drop two fields, sparing their initialization in onCreate the idea is to make onCreate as slim as possible --- .../mobileledger/ui/activity/MainActivity.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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 e1704670..d20e63f0 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 @@ -90,8 +90,6 @@ public class MainActivity extends ProfileThemedActivity { private View profileListHeadMore, profileListHeadCancel, profileListHeadAddProfile; private FragmentManager fragmentManager; private View bTransactionListCancelDownload; - private ProgressBar progressBar; - private LinearLayout progressLayout; private SectionsPagerAdapter mSectionsPagerAdapter; private ViewPager mViewPager; private FloatingActionButton fab; @@ -163,8 +161,6 @@ public class MainActivity extends ProfileThemedActivity { profileListHeadAddProfile = findViewById(R.id.nav_new_profile_button); drawer = findViewById(R.id.drawer_layout); bTransactionListCancelDownload = findViewById(R.id.transaction_list_cancel_download); - progressBar = findViewById(R.id.transaction_list_progress_bar); - progressLayout = findViewById(R.id.transaction_progress_layout); fragmentManager = getSupportFragmentManager(); mSectionsPagerAdapter = new SectionsPagerAdapter(fragmentManager); mViewPager = findViewById(R.id.root_frame); @@ -198,11 +194,6 @@ public class MainActivity extends ProfileThemedActivity { e.printStackTrace(); } - if (progressBar == null) - throw new RuntimeException("Can't get hold on the transaction value progress bar"); - if (progressLayout == null) throw new RuntimeException( - "Can't get hold on the transaction value progress bar layout"); - markDrawerItemCurrent(R.id.nav_account_summary); mViewPager.setAdapter(mSectionsPagerAdapter); @@ -575,7 +566,7 @@ public class MainActivity extends ProfileThemedActivity { } public void onRetrieveDone(String error) { Data.transactionRetrievalDone(); - progressLayout.setVisibility(View.GONE); + findViewById(R.id.transaction_progress_layout).setVisibility(View.GONE); if (error == null) { updateLastUpdateTextFromDB(); @@ -586,15 +577,17 @@ public class MainActivity extends ProfileThemedActivity { else Toast.makeText(this, error, Toast.LENGTH_LONG).show(); } public void onRetrieveStart() { + ProgressBar progressBar = findViewById(R.id.transaction_list_progress_bar); bTransactionListCancelDownload.setEnabled(true); progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary)); progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary)); progressBar.setIndeterminate(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false); else progressBar.setProgress(0); - progressLayout.setVisibility(View.VISIBLE); + findViewById(R.id.transaction_progress_layout).setVisibility(View.VISIBLE); } public void onRetrieveProgress(RetrieveTransactionsTask.Progress progress) { + ProgressBar progressBar = findViewById(R.id.transaction_list_progress_bar); if ((progress.getTotal() == RetrieveTransactionsTask.Progress.INDETERMINATE) || (progress.getTotal() == 0)) { -- 2.39.5