From f8d06717faf642c3a8667c17682a89220b30eb51 Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Fri, 7 Sep 2018 21:16:47 +0300 Subject: [PATCH] Create ContributionListViewUtils class to change visibility of views according to MediaDetailsFragment visiblity or their loading state --- .../utils/ContributionListViewUtils.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/src/main/java/fr/free/nrw/commons/utils/ContributionListViewUtils.java diff --git a/app/src/main/java/fr/free/nrw/commons/utils/ContributionListViewUtils.java b/app/src/main/java/fr/free/nrw/commons/utils/ContributionListViewUtils.java new file mode 100644 index 000000000..6dc9625d7 --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/utils/ContributionListViewUtils.java @@ -0,0 +1,39 @@ +package fr.free.nrw.commons.utils; + +import android.util.Log; +import android.view.View; + +/** + * This class includes utilities for contribution list fragment indicators, such as number of + * uploads, notification and nearby cards and their progress bar behind them. + */ +public class ContributionListViewUtils { + + /** + * Sets indicator and progress bar visibility according to 3 states, data is ready to display, + * data still loading, both should be invisible because media details fragment is visible + * @param indicator this can be numOfUploads text view, notification/nearby card views + * @param progressBar this is the progress bar behind indicators, displays they are loading + * @param isIndicatorReady is indicator fetched the information will be displayed + * @param isBothInvisible true if contribution list fragment is not active (ie. Media Details Fragment is active) + */ + public static void setIndicatorVisibility(View indicator, View progressBar, boolean isIndicatorReady, boolean isBothInvisible) { + if (indicator!=null && progressBar!=null) { + if (isIndicatorReady) { + // Indicator ready, display them + indicator.setVisibility(View.VISIBLE); + progressBar.setVisibility(View.GONE); + } else { + if (isBothInvisible) { + // Media Details Fragment is visible, hide both + indicator.setVisibility(View.GONE); + progressBar.setVisibility(View.GONE); + } else { + // Indicator is not ready, still loading + indicator.setVisibility(View.GONE); + progressBar.setVisibility(View.VISIBLE); + } + } + } + } +}