From ec5af3c18c069f1942563b5626dfb1dc92625651 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 31 Dec 2018 14:43:34 +0200 Subject: [PATCH] StatsFragment crash fix, up libs & version --- app/build.gradle | 8 ++++---- .../activities/profile/stats/StatsFragment.java | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a1c8c82c..12853e57 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 19 targetSdkVersion 28 - versionCode 15 - versionName "1.6.0" + versionCode 16 + versionName "1.6.1" archivesBaseName = "mTHMMY-v$versionName" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" @@ -62,7 +62,7 @@ tasks.whenTaskAdded { task -> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.preference:preference:1.1.0-alpha01' + implementation 'androidx.preference:preference:1.1.0-alpha02' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.cardview:cardview:1.0.0' @@ -72,7 +72,7 @@ dependencies { implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.firebase:firebase-core:16.0.6' implementation 'com.google.firebase:firebase-messaging:17.3.4' - implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7' + implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8' implementation 'com.squareup.okhttp3:okhttp:3.12.0' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java index fbf498c5..8ecf48bd 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java @@ -56,13 +56,12 @@ public class StatsFragment extends Fragment { private ProfileStatsTask profileStatsTask; private LinearLayout mainContent; private MaterialProgressBar progressBar; - private boolean haveParsed = false; private boolean userHasPosts = true; private String generalStatisticsTitle = "", generalStatistics = "", postingActivityByTimeTitle = "", mostPopularBoardsByPostsTitle = "", mostPopularBoardsByActivityTitle = ""; - final private List postingActivityByTime = new ArrayList<>(); - final private List mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); - final private ArrayList mostPopularBoardsByPostsLabels = new ArrayList<>(), mostPopularBoardsByActivityLabels = new ArrayList<>(); + private final List postingActivityByTime = new ArrayList<>(); + private final List mostPopularBoardsByPosts = new ArrayList<>(), mostPopularBoardsByActivity = new ArrayList<>(); + private final ArrayList mostPopularBoardsByPostsLabels = new ArrayList<>(), mostPopularBoardsByActivityLabels = new ArrayList<>(); public StatsFragment() { // Required empty public constructor @@ -95,7 +94,7 @@ public class StatsFragment extends Fragment { final View rootView = inflater.inflate(R.layout.fragment_stats, container, false); mainContent = rootView.findViewById(R.id.main_content); progressBar = rootView.findViewById(R.id.progressBar); - if (haveParsed) + if (profileStatsTask!=null && profileStatsTask.getStatus() == AsyncTask.Status.FINISHED) populateLayout(); return rootView; } @@ -103,7 +102,7 @@ public class StatsFragment extends Fragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - if (!haveParsed) { + if (profileStatsTask==null) { profileStatsTask = new ProfileStatsTask(); profileStatsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, profileUrl + ";sa=statPanel"); } @@ -130,7 +129,6 @@ public class StatsFragment extends Fragment { @Override protected void onPreExecute() { progressBar.setVisibility(ProgressBar.VISIBLE); - haveParsed = true; } @Override @@ -159,7 +157,6 @@ public class StatsFragment extends Fragment { getActivity().finish(); } //Parse was successful - progressBar.setVisibility(ProgressBar.INVISIBLE); populateLayout(); } @@ -233,6 +230,7 @@ public class StatsFragment extends Fragment { } private void populateLayout() { + progressBar.setVisibility(ProgressBar.VISIBLE); ((TextView) mainContent.findViewById(R.id.general_statistics_title)) .setText(generalStatisticsTitle); ((TextView) mainContent.findViewById(R.id.general_statistics)) @@ -358,6 +356,7 @@ public class StatsFragment extends Fragment { mostPopularBoardsByActivityData.setValueTextColor(Color.WHITE); mostPopularBoardsByActivityChart.setData(mostPopularBoardsByActivityData); mostPopularBoardsByActivityChart.invalidate(); + progressBar.setVisibility(ProgressBar.INVISIBLE); } private class MyXAxisValueFormatter implements IAxisValueFormatter {