From ac950ab43854d06ac8ceee3c2402bdee5e13870e Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 22 Feb 2021 20:55:37 +0100 Subject: SwipeRefresh implemented and added to mangas. --- app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/src/main/java/xyz/adjutor/aniki') 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 -- cgit v1.2.3 From d54ff3be42662f304879d5bd851641554ad1013c Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 22 Feb 2021 20:56:09 +0100 Subject: SwipeRefresh added to top anime. --- app/src/main/java/xyz/adjutor/aniki/topanime/TopAnimePage.kt | 12 ++++++++++++ app/src/main/res/layout/top_anime_page.xml | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/xyz/adjutor/aniki') 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/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"> + + tools:listitem="@layout/item_layout" + android:scrollbars="vertical" /> +