Skip to content

Commit

Permalink
District Shimmer effect Added
Browse files Browse the repository at this point in the history
  • Loading branch information
whoishusni committed Apr 20, 2020
1 parent 17a7cd4 commit d109419
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ dependencies {
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//Facebook Shimmer
implementation 'com.facebook.shimmer:shimmer:0.5.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package id.husni.sultengcovid.fragment

import android.opengl.Visibility
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
Expand Down Expand Up @@ -41,10 +42,23 @@ class DistrictFragment : Fragment() {

val viewModel : DistrictViewModel = ViewModelProvider(this,ViewModelProvider.NewInstanceFactory()).get(DistrictViewModel::class.java)
viewModel.setDistrictData()
showShimmer(true)
viewModel.getDistrictData().observe(this, Observer<ArrayList<District>> {
adapter.districts = it
showShimmer(false)
})

}

private fun showShimmer(isShow: Boolean) {
if (isShow){
districtShimmer.showShimmer(true)
districtShimmer.visibility = View.VISIBLE
}
else{
districtShimmer.showShimmer(false)
districtShimmer.visibility = View.GONE
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class AppsUtilities {
companion object{
const val BASE_URL = "https://banuacoders.com/api/pico/"
const val ENDPOINT_PROVINCE = "provinsi/72"
//TODO : NEXT
const val ENDPOINT_DISTRICT = "kabupaten"
const val ENDPOINT_HOSPITAL = "rumahsakit"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DistrictViewModel : ViewModel(){
}

override fun onFailure(call: Call<DistrictResponse>, t: Throwable) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.

}

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProvinceViewModel : ViewModel() {
}

override fun onFailure(call: Call<Province>, t: Throwable) {
TODO("not implemented")

}
})
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_placeholder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
~ Copyright (c) 2020.
~ Made with ❤ by Moh Husni Mubaraq
~ Not For Commercial Purpose
-->

<vector android:height="27dp" android:tint="#A9A9A9"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="27dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
</vector>
64 changes: 64 additions & 0 deletions app/src/main/res/layout/district_item_placeholder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AppTheme.cardItemStyle">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="@dimen/inner_margin">

<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="@dimen/districtNameTextSize"
android:layout_marginBottom="14dp"
android:background="@android:color/darker_gray"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="10dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@android:color/darker_gray"
android:drawableTop="@drawable/ic_placeholder"
android:textColor="@android:color/black"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:drawableTop="@drawable/ic_placeholder"
android:textColor="@android:color/black" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:drawableTop="@drawable/ic_placeholder"
android:textColor="@android:color/black"/>
</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="40dp"
android:backgroundTint="@android:color/darker_gray" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
26 changes: 23 additions & 3 deletions app/src/main/res/layout/fragment_district.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@
android:layout_height="match_parent"
tools:context=".fragment.DistrictFragment">

<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/districtShimmer"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/districtRecyclerView" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/district_item_placeholder"/>
<include layout="@layout/district_item_placeholder"/>
<include layout="@layout/district_item_placeholder"/>
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>

<LinearLayout
android:id="@+id/linearLayout"
Expand All @@ -26,23 +46,23 @@
android:layout_weight="1"
android:drawableStart="@drawable/ic_positive_emoji_mini"
android:text="@string/positive"
android:textColor="@android:color/black"/>
android:textColor="@android:color/black" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableStart="@drawable/ic_negative_emoji_mini"
android:text="@string/negative"
android:textColor="@android:color/black"/>
android:textColor="@android:color/black" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableStart="@drawable/ic_death_emoji_mini"
android:text="@string/death"
android:textColor="@android:color/black"/>
android:textColor="@android:color/black" />
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/fragment_hospital.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.HospitalFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down

0 comments on commit d109419

Please sign in to comment.