summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-22 21:01:24 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-22 21:01:24 +0100
commitb64a89d8b90c0ca537dfe2fad83ac32e7deeffb1 (patch)
treed080b3918bf10532b482fde398676a6d13e31f82 /app/src/main
parent4012256bf91ccf02eb1871229f755beb26dad3de (diff)
parentd54ff3be42662f304879d5bd851641554ad1013c (diff)
Merge branch 'feature/swipe_to_refresh' into develop
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt12
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt12
-rw-r--r--app/src/main/res/layout/top_anime_page.xml8
-rw-r--r--app/src/main/res/layout/top_manga_page.xml8
4 files changed, 38 insertions, 2 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt b/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt
index f2d5e4c..91a33ef 100644
--- a/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt
@@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
@@ -70,6 +71,17 @@ class TopAnimePage : Fragment() {
findNavController().navigate(R.id.action_TopAnimePage_to_HomePage)
}
+ fun updateList() {
+ makeApiCall(view,base_url)
+ Snackbar.make(requireView(), "Data refreshed", Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show()
+ }
+ val swipeRefresh: SwipeRefreshLayout = view.findViewById(R.id.swiperefresh)
+ swipeRefresh.setOnRefreshListener{
+ updateList()
+ swipeRefresh.isRefreshing = false
+ }
+
}
//display the recyclerview
diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt
index f99cd9a..c8075b2 100644
--- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt
@@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
@@ -70,6 +71,17 @@ class TopMangaPage : Fragment() {
findNavController().navigate(R.id.action_TopMangaPage_to_HomePage)
}
+ fun updateList() {
+ makeApiCall(view,base_url)
+ Snackbar.make(requireView(), "Data refreshed", Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show()
+ }
+ val swipeRefresh: SwipeRefreshLayout = view.findViewById(R.id.swiperefresh)
+ swipeRefresh.setOnRefreshListener{
+ updateList()
+ swipeRefresh.isRefreshing = false
+ }
+
}
//display the recyclerview
diff --git a/app/src/main/res/layout/top_anime_page.xml b/app/src/main/res/layout/top_anime_page.xml
index 4b6a58f..4bcc377 100644
--- a/app/src/main/res/layout/top_anime_page.xml
+++ b/app/src/main/res/layout/top_anime_page.xml
@@ -8,6 +8,10 @@
tools:context=".topanime.TopAnimePage"
android:background="@color/very_dark_purple">
+ <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+ android:id="@+id/swiperefresh"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
@@ -16,7 +20,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
- tools:listitem="@layout/item_layout" />
+ tools:listitem="@layout/item_layout"
+ android:scrollbars="vertical" />
+ </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<Button
android:id="@+id/button_home"
diff --git a/app/src/main/res/layout/top_manga_page.xml b/app/src/main/res/layout/top_manga_page.xml
index 95c9161..37150f7 100644
--- a/app/src/main/res/layout/top_manga_page.xml
+++ b/app/src/main/res/layout/top_manga_page.xml
@@ -8,6 +8,10 @@
tools:context=".topmanga.TopMangaPage"
android:background="@color/very_dark_purple">
+ <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+ android:id="@+id/swiperefresh"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
@@ -16,7 +20,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
- tools:listitem="@layout/item_layout" />
+ tools:listitem="@layout/item_layout"
+ android:scrollbars="vertical"/>
+ </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<Button
android:id="@+id/button_home"