From 7e8367096340ec88c70a20e0d7fc80d009b37292 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Sat, 11 Dec 2021 00:57:11 +0100 Subject: [PATCH] added nice ass loading --- app/build.gradle | 7 +- .../cloudstream3/ui/home/HomeFragment.kt | 23 +++-- .../cloudstream3/ui/result/ResultFragment.kt | 2 +- .../main/res/layout/fragment_downloads.xml | 27 +++++- app/src/main/res/layout/fragment_home.xml | 97 ++++++++++++++++--- app/src/main/res/layout/fragment_result.xml | 52 +++++++++- app/src/main/res/layout/loading_downloads.xml | 21 ++++ app/src/main/res/layout/loading_episode.xml | 37 +++++++ app/src/main/res/layout/loading_line.xml | 11 +++ .../main/res/layout/loading_line_short.xml | 11 +++ .../res/layout/loading_line_short_center.xml | 12 +++ app/src/main/res/layout/loading_list.xml | 31 ++++++ app/src/main/res/layout/loading_poster.xml | 10 ++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/dimens.xml | 6 ++ app/src/main/res/values/styles.xml | 5 +- 16 files changed, 321 insertions(+), 32 deletions(-) create mode 100644 app/src/main/res/layout/loading_downloads.xml create mode 100644 app/src/main/res/layout/loading_episode.xml create mode 100644 app/src/main/res/layout/loading_line.xml create mode 100644 app/src/main/res/layout/loading_line_short.xml create mode 100644 app/src/main/res/layout/loading_line_short_center.xml create mode 100644 app/src/main/res/layout/loading_list.xml create mode 100644 app/src/main/res/layout/loading_poster.xml diff --git a/app/build.gradle b/app/build.gradle index 0d333882..b0f62af9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,8 +35,8 @@ android { minSdkVersion 21 targetSdkVersion 31 - versionCode 36 - versionName "2.4.4" + versionCode 37 + versionName "2.4.5" resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix ?: ""}" @@ -159,4 +159,7 @@ dependencies { // debugImplementation because LeakCanary should only run in debug builds. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' + + // for shimmer when loading + implementation 'com.facebook.shimmer:shimmer:0.5.0' } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index f201d6c0..d8382be1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -248,6 +248,8 @@ class HomeFragment : Fragment() { observe(homeViewModel.page) { data -> when (data) { is Resource.Success -> { + home_loading_shimmer?.stopShimmer() + val d = data.value currentHomePage = d @@ -263,11 +265,13 @@ class HomeFragment : Fragment() { home_master_recycler?.adapter?.notifyDataSetChanged() - home_loading.visibility = View.GONE - home_loading_error.visibility = View.GONE - home_loaded.visibility = View.VISIBLE + home_loading?.isVisible = false + home_loading_error?.isVisible = false + home_loaded?.isVisible = true } is Resource.Failure -> { + home_loading_shimmer?.stopShimmer() + result_error_text.text = data.errorString home_reload_connectionerror.setOnClickListener(apiChangeClickListener) @@ -287,14 +291,15 @@ class HomeFragment : Fragment() { } } - home_loading.visibility = View.GONE - home_loading_error.visibility = View.VISIBLE - home_loaded.visibility = View.GONE + home_loading?.isVisible = false + home_loading_error?.isVisible = true + home_loaded?.isVisible = false } is Resource.Loading -> { - home_loading.visibility = View.VISIBLE - home_loading_error.visibility = View.GONE - home_loaded.visibility = View.GONE + home_loading_shimmer?.startShimmer() + home_loading?.isVisible = true + home_loading_error?.isVisible = false + home_loaded?.isVisible = false } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index cea841c1..bc239928 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -801,7 +801,7 @@ class ResultFragment : Fragment() { WatchType.values().map { fab.context.getString(it.stringRes) }.toList(), watchType.ordinal, fab.context.getString(R.string.action_add_to_bookmarks), - showApply = true, + showApply = false, {}) { viewModel.updateWatchStatus(fab.context, WatchType.values()[it]) } diff --git a/app/src/main/res/layout/fragment_downloads.xml b/app/src/main/res/layout/fragment_downloads.xml index b29bfb33..31914e19 100644 --- a/app/src/main/res/layout/fragment_downloads.xml +++ b/app/src/main/res/layout/fragment_downloads.xml @@ -135,11 +135,36 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 030274d8..b524d4fc 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -11,17 +11,81 @@ + + + + + + + + + + + + + + + + + + + + + - + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/loading_downloads.xml b/app/src/main/res/layout/loading_downloads.xml new file mode 100644 index 00000000..bcd8df89 --- /dev/null +++ b/app/src/main/res/layout/loading_downloads.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/app/src/main/res/layout/loading_episode.xml b/app/src/main/res/layout/loading_episode.xml new file mode 100644 index 00000000..062c3975 --- /dev/null +++ b/app/src/main/res/layout/loading_episode.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/loading_line.xml b/app/src/main/res/layout/loading_line.xml new file mode 100644 index 00000000..9d43b4e6 --- /dev/null +++ b/app/src/main/res/layout/loading_line.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/loading_line_short.xml b/app/src/main/res/layout/loading_line_short.xml new file mode 100644 index 00000000..620cf84f --- /dev/null +++ b/app/src/main/res/layout/loading_line_short.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/loading_line_short_center.xml b/app/src/main/res/layout/loading_line_short_center.xml new file mode 100644 index 00000000..49340ab9 --- /dev/null +++ b/app/src/main/res/layout/loading_line_short_center.xml @@ -0,0 +1,12 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/loading_list.xml b/app/src/main/res/layout/loading_list.xml new file mode 100644 index 00000000..29478930 --- /dev/null +++ b/app/src/main/res/layout/loading_list.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/loading_poster.xml b/app/src/main/res/layout/loading_poster.xml new file mode 100644 index 00000000..1248eddc --- /dev/null +++ b/app/src/main/res/layout/loading_poster.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 7a9e4d43..4146520a 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -14,6 +14,7 @@ #e9eaee #9ba0a4 + #DCDCDC #1AFFFFFF #00000000 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c00bb6d1..e0accac5 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,4 +6,10 @@ 0dp 2dp 15dp + + 15dp + 3dp + 15dp + + 2000 \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8a37a51a..6a7b9518 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -315,7 +315,10 @@ @color/toggle_button_outline wrap_content 45dp - 0dp + 0dp + 0dp + 10dp + 10dp 5dp false