added nice ass loading

This commit is contained in:
LagradOst 2021-12-11 00:57:11 +01:00
parent 1e858ddd04
commit 7e83670963
16 changed files with 321 additions and 32 deletions

View file

@ -35,8 +35,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 31 targetSdkVersion 31
versionCode 36 versionCode 37
versionName "2.4.4" versionName "2.4.5"
resValue "string", "app_version", resValue "string", "app_version",
"${defaultConfig.versionName}${versionNameSuffix ?: ""}" "${defaultConfig.versionName}${versionNameSuffix ?: ""}"
@ -159,4 +159,7 @@ dependencies {
// debugImplementation because LeakCanary should only run in debug builds. // debugImplementation because LeakCanary should only run in debug builds.
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
// for shimmer when loading
implementation 'com.facebook.shimmer:shimmer:0.5.0'
} }

View file

@ -248,6 +248,8 @@ class HomeFragment : Fragment() {
observe(homeViewModel.page) { data -> observe(homeViewModel.page) { data ->
when (data) { when (data) {
is Resource.Success -> { is Resource.Success -> {
home_loading_shimmer?.stopShimmer()
val d = data.value val d = data.value
currentHomePage = d currentHomePage = d
@ -263,11 +265,13 @@ class HomeFragment : Fragment() {
home_master_recycler?.adapter?.notifyDataSetChanged() home_master_recycler?.adapter?.notifyDataSetChanged()
home_loading.visibility = View.GONE home_loading?.isVisible = false
home_loading_error.visibility = View.GONE home_loading_error?.isVisible = false
home_loaded.visibility = View.VISIBLE home_loaded?.isVisible = true
} }
is Resource.Failure -> { is Resource.Failure -> {
home_loading_shimmer?.stopShimmer()
result_error_text.text = data.errorString result_error_text.text = data.errorString
home_reload_connectionerror.setOnClickListener(apiChangeClickListener) home_reload_connectionerror.setOnClickListener(apiChangeClickListener)
@ -287,14 +291,15 @@ class HomeFragment : Fragment() {
} }
} }
home_loading.visibility = View.GONE home_loading?.isVisible = false
home_loading_error.visibility = View.VISIBLE home_loading_error?.isVisible = true
home_loaded.visibility = View.GONE home_loaded?.isVisible = false
} }
is Resource.Loading -> { is Resource.Loading -> {
home_loading.visibility = View.VISIBLE home_loading_shimmer?.startShimmer()
home_loading_error.visibility = View.GONE home_loading?.isVisible = true
home_loaded.visibility = View.GONE home_loading_error?.isVisible = false
home_loaded?.isVisible = false
} }
} }
} }

View file

@ -801,7 +801,7 @@ class ResultFragment : Fragment() {
WatchType.values().map { fab.context.getString(it.stringRes) }.toList(), WatchType.values().map { fab.context.getString(it.stringRes) }.toList(),
watchType.ordinal, watchType.ordinal,
fab.context.getString(R.string.action_add_to_bookmarks), fab.context.getString(R.string.action_add_to_bookmarks),
showApply = true, showApply = false,
{}) { {}) {
viewModel.updateWatchStatus(fab.context, WatchType.values()[it]) viewModel.updateWatchStatus(fab.context, WatchType.values()[it])
} }

View file

@ -135,11 +135,36 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/> app:layout_constraintBottom_toBottomOf="parent"/>
<!--
<ProgressBar <ProgressBar
android:visibility="visible" android:visibility="visible"
tools:visibility="gone" tools:visibility="gone"
android:id="@+id/download_loading" android:id="@+id/download_loading"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="50dp" android:layout_height="50dp"> android:layout_width="50dp" android:layout_height="50dp">
</ProgressBar> </ProgressBar>-->
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/download_loading"
app:shimmer_base_alpha="0.2"
app:shimmer_highlight_alpha="0.3"
app:shimmer_duration="@integer/loading_time"
app:shimmer_auto_start="true"
android:paddingTop="40dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/loading_downloads"/>
<include layout="@layout/loading_downloads"/>
<include layout="@layout/loading_downloads"/>
<include layout="@layout/loading_downloads"/>
<include layout="@layout/loading_downloads"/>
<include layout="@layout/loading_downloads"/>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -11,17 +11,81 @@
<FrameLayout <FrameLayout
android:visibility="gone" android:visibility="gone"
tools:visibility="gone" tools:visibility="visible"
android:id="@+id/home_loading" android:id="@+id/home_loading"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ProgressBar <ProgressBar
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="visible" android:visibility="gone"
tools:visibility="visible" tools:visibility="gone"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp"> android:layout_height="50dp">
</ProgressBar> </ProgressBar>
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/home_loading_shimmer"
app:shimmer_base_alpha="0.2"
app:shimmer_highlight_alpha="0.3"
app:shimmer_duration="@integer/loading_time"
app:shimmer_auto_start="true"
android:paddingTop="40dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_margin="@dimen/loading_margin"
android:layout_gravity="center"
app:cardCornerRadius="@dimen/loading_radius"
android:background="@color/grayShimmer"
android:translationX="-164dp"
android:layout_width="125dp"
android:layout_height="200dp">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_margin="@dimen/loading_margin"
android:layout_gravity="center"
app:cardCornerRadius="@dimen/loading_radius"
android:background="@color/grayShimmer"
android:layout_width="148dp"
android:layout_height="234dp">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_margin="@dimen/loading_margin"
android:layout_gravity="center"
app:cardCornerRadius="@dimen/loading_radius"
android:background="@color/grayShimmer"
android:translationX="164dp"
android:layout_width="125dp"
android:layout_height="200dp">
</androidx.cardview.widget.CardView>
</FrameLayout>
<include layout="@layout/loading_line_short_center"/>
<LinearLayout
android:orientation="vertical"
android:layout_marginTop="@dimen/result_padding"
android:layout_marginStart="@dimen/result_padding"
android:layout_marginEnd="@dimen/result_padding"
android:layout_width="match_parent" android:layout_height="wrap_content">
<include layout="@layout/loading_list"/>
<include layout="@layout/loading_list"/>
<include layout="@layout/loading_list"/>
</LinearLayout>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/home_loading_statusbar" android:id="@+id/home_loading_statusbar"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -84,7 +148,7 @@
</LinearLayout> </LinearLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:background="?attr/primaryBlackBackground" android:background="?attr/primaryBlackBackground"
tools:visibility="visible" tools:visibility="gone"
android:visibility="gone" android:visibility="gone"
android:id="@+id/home_loaded" android:id="@+id/home_loaded"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -304,17 +368,19 @@
</ImageView> </ImageView>
</FrameLayout> </FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp" <androidx.recyclerview.widget.RecyclerView
android:clipToPadding="false" android:paddingHorizontal="5dp"
android:descendantFocusability="afterDescendants" android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" android:descendantFocusability="afterDescendants"
android:id="@+id/home_watch_child_recyclerview" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="horizontal" android:id="@+id/home_watch_child_recyclerview"
android:layout_width="wrap_content" android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_width="wrap_content"
tools:listitem="@layout/home_result_grid" android:layout_height="wrap_content"
/> tools:listitem="@layout/home_result_grid"
/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -404,7 +470,6 @@
android:contentDescription="@string/home_more_info"> android:contentDescription="@string/home_more_info">
</ImageView> </ImageView>
</FrameLayout> </FrameLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:paddingHorizontal="5dp" android:paddingHorizontal="5dp"
android:clipToPadding="false" android:clipToPadding="false"

View file

@ -10,13 +10,59 @@
android:focusable="true" android:focusable="true"
> >
<ProgressBar <com.facebook.shimmer.ShimmerFrameLayout
tools:visibility="gone"
app:shimmer_base_alpha="0.2"
app:shimmer_highlight_alpha="0.3"
app:shimmer_duration="@integer/loading_time"
app:shimmer_auto_start="true"
android:paddingTop="40dp"
android:id="@+id/result_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_margin="@dimen/result_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_marginBottom="@dimen/loading_margin"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/loading_poster"/>
<LinearLayout
android:layout_marginStart="@dimen/loading_margin"
android:layout_marginEnd="@dimen/loading_margin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line_short"/>
</LinearLayout>
</LinearLayout>
<ImageView android:layout_width="match_parent" android:layout_height="20dp"
tools:ignore="ContentDescription"/>
<include layout="@layout/loading_episode"/>
<include layout="@layout/loading_episode"/>
<include layout="@layout/loading_episode"/>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<!--<ProgressBar
android:visibility="visible" android:visibility="visible"
tools:visibility="gone" tools:visibility="gone"
android:id="@+id/result_loading" android:id="@+id/result_loading"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="50dp" android:layout_height="50dp"> android:layout_width="50dp" android:layout_height="50dp">
</ProgressBar> </ProgressBar>-->
<LinearLayout <LinearLayout
android:id="@+id/result_loading_error" android:id="@+id/result_loading_error"
@ -611,6 +657,8 @@
android:id="@+id/result_bookmark_fab" android:id="@+id/result_bookmark_fab"
android:layout_gravity="end|bottom" android:layout_gravity="end|bottom"
app:icon="@drawable/ic_baseline_bookmark_24" app:icon="@drawable/ic_baseline_bookmark_24"
android:textAllCaps="false"
android:gravity="center"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:ignore="ContentDescription"> tools:ignore="ContentDescription">

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:paddingBottom="@dimen/loading_margin"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/loading_poster"/>
<LinearLayout
android:layout_marginStart="15dp"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_marginEnd="50dp"
android:layout_height="wrap_content">
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line_short"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:paddingTop="@dimen/loading_margin"
android:paddingBottom="@dimen/loading_margin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_marginBottom="@dimen/loading_margin"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<!--app:cardCornerRadius="@dimen/roundedImageRadius"-->
<androidx.cardview.widget.CardView
android:background="@color/grayShimmer"
app:cardCornerRadius="@dimen/loading_radius"
android:layout_width="126dp"
android:layout_height="72dp"
android:foreground="@drawable/outline_drawable"
>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_marginStart="15dp"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_marginEnd="50dp"
android:layout_height="wrap_content">
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line_short"/>
</LinearLayout>
</LinearLayout>
<include layout="@layout/loading_line"/>
<include layout="@layout/loading_line"/>
</LinearLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
app:cardCornerRadius="@dimen/loading_radius"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/loading_line_height"
android:layout_marginBottom="@dimen/loading_margin"
android:background="@color/grayShimmer"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ContentDescription"
xmlns:app="http://schemas.android.com/apk/res-auto"/>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
app:cardCornerRadius="@dimen/loading_radius"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="120dp"
android:layout_height="@dimen/loading_line_height"
android:layout_marginBottom="@dimen/loading_margin"
android:background="@color/grayShimmer"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ContentDescription"
xmlns:app="http://schemas.android.com/apk/res-auto"/>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
app:cardCornerRadius="@dimen/loading_radius"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="200dp"
android:layout_gravity="center"
android:layout_height="@dimen/loading_line_height"
android:layout_marginBottom="@dimen/loading_margin"
android:background="@color/grayShimmer"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ContentDescription"
xmlns:app="http://schemas.android.com/apk/res-auto"/>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:paddingTop="@dimen/loading_margin"
android:paddingBottom="@dimen/loading_margin"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="200dp" android:layout_width="match_parent">
<include layout="@layout/loading_line_short"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="match_parent" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
<View android:layout_height="wrap_content" android:layout_width="@dimen/loading_margin"/>
<include layout="@layout/loading_poster"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
app:cardCornerRadius="@dimen/loading_radius"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="100dp"
android:layout_height="140dp"
android:background="@color/grayShimmer"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ContentDescription"
xmlns:app="http://schemas.android.com/apk/res-auto"/>

View file

@ -14,6 +14,7 @@
<color name="textColor">#e9eaee</color> <!--FFF--> <color name="textColor">#e9eaee</color> <!--FFF-->
<color name="grayTextColor">#9ba0a4</color> <!-- 5e5f62--> <color name="grayTextColor">#9ba0a4</color> <!-- 5e5f62-->
<color name="grayShimmer">#DCDCDC</color> <!-- 5e5f62-->
<color name="searchColorTransparent">#1AFFFFFF</color> <!--DADADA--> <color name="searchColorTransparent">#1AFFFFFF</color> <!--DADADA-->
<color name="transparent">#00000000</color> <color name="transparent">#00000000</color>

View file

@ -6,4 +6,10 @@
<dimen name="navbar_height">0dp</dimen> <dimen name="navbar_height">0dp</dimen>
<dimen name="card_corner_radius">2dp</dimen> <dimen name="card_corner_radius">2dp</dimen>
<dimen name="result_padding">15dp</dimen> <dimen name="result_padding">15dp</dimen>
<dimen name="loading_line_height">15dp</dimen>
<dimen name="loading_radius">3dp</dimen>
<dimen name="loading_margin">15dp</dimen>
<integer name="loading_time">2000</integer>
</resources> </resources>

View file

@ -315,7 +315,10 @@
<item name="strokeColor">@color/toggle_button_outline</item> <item name="strokeColor">@color/toggle_button_outline</item>
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">45dp</item> <item name="android:layout_height">45dp</item>
<item name="android:padding">0dp</item> <item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingStart">10dp</item>
<item name="android:paddingEnd">10dp</item>
<!--<item name="android:layout_marginStart">10dp</item>--> <!--<item name="android:layout_marginStart">10dp</item>-->
<item name="android:layout_marginEnd">5dp</item> <item name="android:layout_marginEnd">5dp</item>
<item name="textAllCaps">false</item> <item name="textAllCaps">false</item>