summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-16 11:37:58 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-16 11:37:58 +0100
commit7288d5ae154f895d71727acc92828aa555e8108b (patch)
tree367d04058f951c24a1bc4778b85873df89bf67f8
parent97ff499413e5dae958ac3741616e2ee84a188871 (diff)
Starting to work on recycler view feature
-rw-r--r--app/build.gradle7
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt45
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/MainActivity.kt1
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt1
-rw-r--r--app/src/main/res/layout/activity_main.xml3
-rw-r--r--app/src/main/res/layout/item_layout.xml63
-rw-r--r--app/src/main/res/layout/row_layout.xml47
-rw-r--r--app/src/main/res/layout/top_manga_page.xml21
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--gradle/wrapper/gradle-wrapper.properties4
10 files changed, 180 insertions, 15 deletions
diff --git a/app/build.gradle b/app/build.gradle
index aa8bfbb..5de4ebb 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -35,13 +35,16 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.2.0'
+ implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.3'
- testImplementation 'junit:junit:4.+'
+ testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
+ implementation "androidx.recyclerview:recyclerview:1.1.0"
+
} \ No newline at end of file
diff --git a/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt
new file mode 100644
index 0000000..74ba9c4
--- /dev/null
+++ b/app/src/main/java/xyz/adjutor/aniki/ListAdapter.kt
@@ -0,0 +1,45 @@
+package xyz.adjutor.aniki
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+
+class ListAdapter(private val dataSet: Array<String>) :
+ RecyclerView.Adapter<ListAdapter.ViewHolder>() {
+
+ /**
+ * Provide a reference to the type of views that you are using
+ * (custom ViewHolder).
+ */
+ class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ // Define click listener for the ViewHolder's View.
+ val firstLine: TextView = view.findViewById(R.id.firstLine)
+ val secondLine: TextView = view.findViewById(R.id.secondLine)
+
+ }
+
+ // Create new views (invoked by the layout manager)
+ override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
+ // Create a new view, which defines the UI of the list item
+ val view = LayoutInflater.from(viewGroup.context)
+ .inflate(R.layout.row_layout, viewGroup, false)
+
+ return ViewHolder(view)
+ }
+
+ // Replace the contents of a view (invoked by the layout manager)
+ override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
+
+ // Get element from your dataset at this position and replace the
+ // contents of the view with that element
+ viewHolder.firstLine.text = dataSet[position]
+ viewHolder.secondLine.text = dataSet[position]
+ }
+
+ // Return the size of your dataset (invoked by the layout manager)
+ override fun getItemCount() = dataSet.size
+
+}
+
diff --git a/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt b/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
index 4ccae64..3ae1bf2 100644
--- a/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/MainActivity.kt
@@ -6,6 +6,7 @@ import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
+import androidx.recyclerview.widget.RecyclerView
class MainActivity : AppCompatActivity() {
diff --git a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
index c64b9fe..a59e038 100644
--- a/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/TopMangaPage.kt
@@ -27,5 +27,6 @@ class TopMangaPage : Fragment() {
view.findViewById<Button>(R.id.home).setOnClickListener {
findNavController().navigate(R.id.action_TopMangaPage_to_HomePage)
}
+
}
} \ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index b0826f8..12a61d8 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.coordinatorlayout.widget.CoordinatorLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_layout.xml b/app/src/main/res/layout/item_layout.xml
new file mode 100644
index 0000000..e03e874
--- /dev/null
+++ b/app/src/main/res/layout/item_layout.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.cardview.widget.CardView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/cv_cardView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="4dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:foreground="?selectableItemBackground"
+ app:cardCornerRadius="10dp"
+ >
+
+ <RelativeLayout
+ android:id="@+id/rl_wrapper"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="20dp"
+ >
+
+ <ImageView
+ android:id="@+id/iv_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_margin="10dp"
+ android:src="@mipmap/ic_launcher_round"
+ android:contentDescription="@string/rv_image" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignTop="@id/iv_image"
+ android:layout_alignBottom="@id/iv_image"
+ android:layout_toEndOf="@id/iv_image"
+ android:orientation="vertical"
+ >
+
+ <TextView
+ android:id="@+id/tv_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:text="@string/rv_title"
+ android:textColor="@color/strong_pink"
+ android:textSize="20sp"/>
+
+ <TextView
+ android:id="@+id/tv_description"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:text="@string/rv_description"
+ android:textColor="@color/slightly_desaturated_magenta"
+ android:textSize="20sp"
+ />
+
+ </LinearLayout>
+
+
+ </RelativeLayout>
+</androidx.cardview.widget.CardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/row_layout.xml b/app/src/main/res/layout/row_layout.xml
new file mode 100644
index 0000000..1c74476
--- /dev/null
+++ b/app/src/main/res/layout/row_layout.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:layout_marginStart="?android:attr/listPreferredItemPaddingLeft"
+ android:layout_marginEnd="?android:attr/listPreferredItemPaddingRight"
+ android:gravity="center_vertical"
+ android:padding="6dip">
+
+<ImageView
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentTop="true"
+ android:layout_marginEnd="6dip"
+ android:contentDescription="@string/rv_image"
+ android:src="@mipmap/ic_launcher"
+ tools:ignore="MissingConstraints" />
+
+<TextView
+ android:id="@+id/secondLine"
+ android:layout_height="26dip"
+ android:ellipsize="marquee"
+ android:text="@string/rv_description"
+ android:textSize="12sp"
+ app:layout_constraintStart_toEndOf="@id/icon"
+ app:layout_constraintTop_toBottomOf="@id/firstLine"
+ android:layout_width="0dp" />
+
+<TextView
+ android:id="@+id/firstLine"
+ android:layout_height="wrap_content"
+ android:layout_toEndOf="@id/icon"
+ android:gravity="center_vertical"
+ android:text="@string/rv_title"
+ android:textSize="16sp"
+ app:layout_constraintStart_toEndOf="@id/icon"
+ app:layout_constraintEnd_toEndOf="parent"
+ android:layout_width="0dp"
+ tools:ignore="MissingConstraints" />
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/app/src/main/res/layout/top_manga_page.xml b/app/src/main/res/layout/top_manga_page.xml
index 6a2f86b..f8d2510 100644
--- a/app/src/main/res/layout/top_manga_page.xml
+++ b/app/src/main/res/layout/top_manga_page.xml
@@ -5,17 +5,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TopMangaPage"
- android:background="@color/very_dark_purple"
- >
+ android:background="@color/very_dark_purple">
- <TextView
- android:id="@+id/textview_second"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintBottom_toTopOf="@id/home"
- app:layout_constraintEnd_toEndOf="parent"
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/recycler_view"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/home"
+ tools:listitem="@layout/item_layout" />
<Button
android:id="@+id/home"
@@ -25,5 +25,6 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/textview_second" />
+ />
+
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e076855..a16e804 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -13,4 +13,7 @@
<string name="news_page_label">News Page</string>
<string name="article_page_label">Article Page</string>
<string name="top_manga_page_label">Top Manga Page</string>
+ <string name="rv_title">Title</string>
+ <string name="rv_description">This is a description</string>
+ <string name="rv_image">image</string>
</resources> \ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3f5e8f1..356bc93 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Feb 09 10:05:45 CET 2021
+#Sat Feb 13 10:18:54 CET 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip