Skip to content

Commit 8f9ad66

Browse files
Kishan Kumar MauryaKishan Kumar Maurya
authored andcommitted
Shimmer Effect added
1 parent 60140db commit 8f9ad66

File tree

5 files changed

+68
-14
lines changed

5 files changed

+68
-14
lines changed

app/src/main/java/com/example/githubfirebaseissue/ui/fragment/IssuesFragment.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ class IssuesFragment : AbstractIssueFragment(), IAdapterCallback {
5353

5454
override fun showLoadingState(loading: Boolean) {
5555
if (loading)
56-
progress.visibility = View.VISIBLE
57-
else
58-
progress.visibility = View.GONE
56+
shimmer_view_container.startShimmerAnimation()
57+
else {
58+
shimmer_view_container.stopShimmerAnimation()
59+
shimmer_view_container.visibility = View.GONE
60+
}
5961
}
6062

6163
override fun onError(message: String) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:padding="@dimen/padding_8"
7+
android:layout_marginBottom="@dimen/margin_8">
8+
9+
10+
<LinearLayout
11+
android:layout_width="wrap_content"
12+
android:layout_height="36dp"
13+
android:orientation="vertical"
14+
app:layout_constraintStart_toStartOf="parent"
15+
app:layout_constraintTop_toTopOf="parent">
16+
17+
<View
18+
android:layout_width="@dimen/dimen_140"
19+
android:layout_height="8dp"
20+
android:background="@android:color/darker_gray" />
21+
22+
<View
23+
android:layout_width="wrap_content"
24+
android:layout_height="@dimen/dimen_8"
25+
android:layout_marginTop="@dimen/margin_16"
26+
android:background="@android:color/darker_gray" />
27+
</LinearLayout>
28+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:shimmer="http://schemas.android.com/apk/res-auto"
45
xmlns:tools="http://schemas.android.com/tools"
56
android:layout_width="match_parent"
67
android:layout_height="match_parent">
78

9+
<com.facebook.shimmer.ShimmerFrameLayout
10+
android:id="@+id/shimmer_view_container"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_gravity="center"
14+
android:layout_marginTop="@dimen/margin_8"
15+
android:orientation="vertical"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent"
18+
shimmer:duration="800">
19+
20+
<LinearLayout
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:orientation="vertical">
24+
25+
<include layout="@layout/data_placeholder_layout" />
26+
<include layout="@layout/data_placeholder_layout" />
27+
<include layout="@layout/data_placeholder_layout" />
28+
<include layout="@layout/data_placeholder_layout" />
29+
<include layout="@layout/data_placeholder_layout" />
30+
<include layout="@layout/data_placeholder_layout" />
31+
<include layout="@layout/data_placeholder_layout" />
32+
<include layout="@layout/data_placeholder_layout" />
33+
<include layout="@layout/data_placeholder_layout" />
34+
<include layout="@layout/data_placeholder_layout" />
35+
</LinearLayout>
36+
37+
</com.facebook.shimmer.ShimmerFrameLayout>
38+
839

940
<androidx.recyclerview.widget.RecyclerView
1041
android:id="@+id/parent_recycler"
@@ -18,15 +49,5 @@
1849
tools:itemCount="10"
1950
tools:listitem="@layout/issue_row_item" />
2051

21-
<ProgressBar
22-
android:id="@+id/progress"
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25-
android:visibility="gone"
26-
app:layout_constraintBottom_toBottomOf="parent"
27-
app:layout_constraintEnd_toEndOf="parent"
28-
app:layout_constraintStart_toStartOf="parent"
29-
app:layout_constraintTop_toTopOf="parent"
30-
tools:visibility="visible" />
3152

3253
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
<dimen name="size_20">20sp</dimen>
77
<dimen name="size_12">12sp</dimen>
88
<dimen name="margin_8">8dp</dimen>
9+
<dimen name="margin_16">16dp</dimen>
10+
<dimen name="dimen_140">140dp</dimen>
11+
<dimen name="dimen_8">8dp</dimen>
912
</resources>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ buildscript {
2121
ktx_version = "1.0.2"
2222
ktx_fragment_version = "1.2.2"
2323
retrofit_version = "2.4.0"
24-
rxJavaVersion = '2.1.0'
24+
rxJavaVersion = '2.1.1'
2525
android_material_version = "1.2.0-alpha05"
2626
gson_version = "2.8.5"
2727
junit_version = '4.12'

0 commit comments

Comments
 (0)