diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 7 | ||||
-rw-r--r-- | app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaPage.kt | 12 | ||||
-rw-r--r-- | app/src/main/res/layout/top_manga_page.xml | 8 |
3 files changed, 24 insertions, 3 deletions
diff --git a/app/build.gradle b/app/build.gradle index d1d101c..6a990f2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,11 +56,14 @@ dependencies { testImplementation 'junit:junit:4.13.2' // Required for instrumented tests - androidTestImplementation 'com.android.support:support-annotations:28.0.0' - androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'androidx.annotation:annotation:1.1.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' //Glide to display images properly implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' + //swipe feature + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + }
\ No newline at end of file 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_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" |