Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaderboard refresh animation #513

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dinuscxj.refresh.RecyclerRefreshLayout
import kotlinx.android.synthetic.main.fragment_leaderboard.view.*
import org.hackillinois.android.R
import org.hackillinois.android.database.entity.Leaderboard
Expand All @@ -31,6 +32,7 @@ class LeaderboardFragment : Fragment() {
private lateinit var recyclerView: RecyclerView
private lateinit var mLayoutManager: LinearLayoutManager
private lateinit var mAdapter: LeaderboardAdapter
private lateinit var refreshLayout: RecyclerRefreshLayout

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -44,6 +46,7 @@ class LeaderboardFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_leaderboard, container, false)
refreshLayout = view.findViewById(R.id.refresh_layout)

mAdapter = LeaderboardAdapter(leaderboard)

Expand All @@ -54,6 +57,17 @@ class LeaderboardFragment : Fragment() {
addItemDecorationWithoutLastItem()
}

refreshLayout.setOnRefreshListener {
// code to refresh list
viewModel.leaderboardLiveData.observe(
viewLifecycleOwner,
Observer {
updateLeaderboard(it)
}
)
refreshLayout.setRefreshing(false)
}

viewModel.leaderboardLiveData.observe(
viewLifecycleOwner,
Observer {
Expand Down
35 changes: 19 additions & 16 deletions app/src/main/res/layout/fragment_leaderboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,24 @@
android:fontFamily="@font/montserrat_bold"
android:textColor="@color/white"
android:text="@string/leaderboard"
/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_leaderboard"
/>
<com.dinuscxj.refresh.RecyclerRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_textview_leaderboard"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingEnd="31dp"
android:paddingStart="31dp"
android:paddingBottom="30dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_leaderboard"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="50dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_textview_leaderboard"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingEnd="31dp"
android:paddingStart="31dp"
android:paddingBottom="30dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.dinuscxj.refresh.RecyclerRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Jan 27 12:34:14 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Loading
Loading