MoreHomeActivity re-arrangements of sizes in layout.
Notifications activity, adapter - dummy data
This commit is contained in:
12
.idea/deploymentTargetDropDown.xml
generated
12
.idea/deploymentTargetDropDown.xml
generated
@@ -4,18 +4,6 @@
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State>
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$PROJECT_DIR$/../.android/avd/Pixel_6_API_27.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-06-10T10:52:42.278299Z" />
|
||||
<targetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
android:theme="@style/Theme.Woka"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".shop.MyOrdersActivity"
|
||||
android:name=".home.notifications.NotificationsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".shop.MyOrdersActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".modules.disclaimer.DisclaimerActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.woka.home.BottomNavigation.Companion.MY_LIST
|
||||
import com.woka.home.fragments.Home1Fragment
|
||||
import com.woka.home.fragments.Home2Fragment
|
||||
import com.woka.home.fragments.MyListFragment
|
||||
import com.woka.home.notifications.NotificationsActivity
|
||||
import com.woka.home.sidebar.aboutwoka.AboutActivity
|
||||
import com.woka.home.sidebar.faqs.FaqActivity
|
||||
import com.woka.home.sidebar.profile.UserProfileActivity
|
||||
@@ -264,6 +265,11 @@ class HomeActivity : WokaBaseActivity(),
|
||||
|
||||
private fun clickEvents() {
|
||||
binding.apply {
|
||||
|
||||
notifications.setOnClickListener {
|
||||
startActivity(Intent(this@HomeActivity, NotificationsActivity::class.java))
|
||||
}
|
||||
|
||||
sideMenu.setOnClickListener {
|
||||
homeDrawer.openDrawer(GravityCompat.END)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.woka.home.notifications
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.woka.databinding.NotificationViewHolderBinding
|
||||
import com.woka.home.notifications.models.NotificationData
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.LocalDate
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class NotificationAdapter(config: AsyncDifferConfig<NotificationData>): ListAdapter<NotificationData, NotificationAdapter.NotificationViewHolder>(config) {
|
||||
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<NotificationData>(){
|
||||
override fun areItemsTheSame(
|
||||
oldItem: NotificationData,
|
||||
newItem: NotificationData
|
||||
): Boolean = oldItem.id == newItem.id
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: NotificationData,
|
||||
newItem: NotificationData
|
||||
): Boolean = oldItem == newItem
|
||||
}
|
||||
|
||||
private val DIFF_CONFIG = AsyncDifferConfig.Builder(DIFF_UTIL)
|
||||
.setBackgroundThreadExecutor(Executors.newSingleThreadExecutor())
|
||||
.build()
|
||||
}
|
||||
|
||||
constructor(): this(DIFF_CONFIG)
|
||||
|
||||
inner class NotificationViewHolder(val binding: NotificationViewHolderBinding): ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NotificationViewHolder {
|
||||
return NotificationViewHolder(
|
||||
NotificationViewHolderBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: NotificationViewHolder, position: Int) {
|
||||
val notification = getItem(position)
|
||||
notification.updated_at?.let {
|
||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'", Locale.getDefault())
|
||||
.parse(it)?.let { notificationDate ->
|
||||
val today = Calendar.getInstance()
|
||||
|
||||
val dayDiffs = (today.time.time - notificationDate.time)/(24 * 60 * 60 * 1000)
|
||||
val daysTxt = "$dayDiffs days ago"
|
||||
holder.binding.daysTxt.text = daysTxt
|
||||
}
|
||||
|
||||
holder.binding.bodyTxt.text = notification.title
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.woka.home.notifications
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.woka.R
|
||||
import com.woka.databinding.ActivityNotificationsBinding
|
||||
import com.woka.home.notifications.models.NotificationData
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
|
||||
class NotificationsActivity : WokaBaseActivity() {
|
||||
|
||||
private lateinit var binding: ActivityNotificationsBinding
|
||||
|
||||
private lateinit var adapter: NotificationAdapter
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
binding = ActivityNotificationsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||
insets
|
||||
}
|
||||
|
||||
adapter = NotificationAdapter()
|
||||
|
||||
initViews()
|
||||
|
||||
adapter.submitList(listOf(
|
||||
NotificationData(
|
||||
created_at = "2024-05-31T10:44:09.000000Z",
|
||||
description = "2024-05-31T10:44:09.000000Z",
|
||||
id = 1,
|
||||
image = null,
|
||||
is_read = 1,
|
||||
link = null,
|
||||
post_type = 2,
|
||||
title = "New Episode has been added toBang Bang Bang",
|
||||
type = "type",
|
||||
updated_at = "2024-05-31T10:44:09.000000Z",
|
||||
user_id = 1
|
||||
),
|
||||
NotificationData(
|
||||
created_at = "2024-05-31T10:44:09.000000Z",
|
||||
description = "2024-05-31T10:44:09.000000Z",
|
||||
id = 2,
|
||||
image = null,
|
||||
is_read = 1,
|
||||
link = null,
|
||||
post_type = 2,
|
||||
title = "New Episode has been added toBang Bang Bang",
|
||||
type = "type",
|
||||
updated_at = "2024-06-01T10:44:09.000000Z",
|
||||
user_id = 1
|
||||
)
|
||||
))
|
||||
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
binding.apply {
|
||||
rvNotifications.adapter = adapter
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.woka.home.notifications.models
|
||||
|
||||
data class NotificationData(
|
||||
val created_at: String?,
|
||||
val description: String?,
|
||||
val id: Int?,
|
||||
val image: String?,
|
||||
val is_read: Int?,
|
||||
val link: Any?,
|
||||
val post_type: Int?,
|
||||
val title: String?,
|
||||
val type: String?,
|
||||
val updated_at: String?,
|
||||
val user_id: Int?
|
||||
)
|
||||
@@ -76,7 +76,7 @@ class WokaSongsAdapter(context: Context): RecyclerView.Adapter<WokaSongsAdapter.
|
||||
|
||||
val lastPosition = currentPlayingPos
|
||||
currentPlayingPos = -1
|
||||
notifyItemChanged(lastPosition, PLAY_BACK_CHANGED)
|
||||
notifyItemChanged(lastPosition)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class WokaSongsAdapter(context: Context): RecyclerView.Adapter<WokaSongsAdapter.
|
||||
|
||||
val lastPosition = currentPlayingPos
|
||||
currentPlayingPos = -1
|
||||
notifyItemChanged(lastPosition, PLAY_BACK_CHANGED)
|
||||
notifyItemChanged(lastPosition)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,11 @@ class WokaSongsAdapter(context: Context): RecyclerView.Adapter<WokaSongsAdapter.
|
||||
progressBar.hide()
|
||||
}
|
||||
}
|
||||
else -> super.onBindViewHolder(holder, position, payloads)
|
||||
else -> {
|
||||
playBtn.show()
|
||||
playBtn.setImageResource(R.drawable.ic_play)
|
||||
progressBar.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,18 @@
|
||||
android:text="@string/coming_soonn_on_woka"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
android:textSize="@dimen/_13ssp"
|
||||
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:visibility="gone"
|
||||
|
||||
/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -91,7 +93,7 @@
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/_100sdp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/img_masila_tn_small"
|
||||
android:contentDescription="@string/masila"
|
||||
android:scaleType="fitXY"
|
||||
@@ -148,9 +150,9 @@
|
||||
android:text="@string/blogs"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
android:textSize="@dimen/_13ssp"
|
||||
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
@@ -175,9 +177,9 @@
|
||||
android:text="@string/woka_songs"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
android:textSize="@dimen/_13ssp"
|
||||
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
62
app/src/main/res/layout/activity_notifications.xml
Normal file
62
app/src/main/res/layout/activity_notifications.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_primary_dark"
|
||||
tools:context=".home.notifications.NotificationsActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="@dimen/_27sdp"
|
||||
android:layout_height="@dimen/_25sdp"
|
||||
android:contentDescription="@string/back_btn"
|
||||
android:src="@drawable/ic_arrow_back_full"
|
||||
android:scaleType="fitXY"
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
android:translationZ="1dp"
|
||||
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="20dp"
|
||||
|
||||
app:tint="@color/white" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:translationZ="1dp"
|
||||
|
||||
android:text="@string/notifications"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_13ssp"
|
||||
|
||||
android:layout_marginStart="10dp"
|
||||
|
||||
app:layout_constraintStart_toEndOf="@id/back_btn"
|
||||
app:layout_constraintTop_toTopOf="@id/back_btn"
|
||||
app:layout_constraintBottom_toBottomOf="@id/back_btn"
|
||||
|
||||
/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_notifications"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/notification_view_holder"
|
||||
|
||||
android:layout_marginTop="10dp"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/back_btn"
|
||||
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.woka.utils.PressableCard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/_150sdp"
|
||||
android:layout_height="@dimen/_130sdp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@drawable/round_bg_5"
|
||||
@@ -21,8 +21,8 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="@dimen/_120sdp"
|
||||
android:layout_height="@dimen/_80sdp"
|
||||
android:layout_width="@dimen/_110sdp"
|
||||
android:layout_height="@dimen/_70sdp"
|
||||
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
@@ -51,6 +51,7 @@
|
||||
tools:text="Sabak Degi Naani: The Lessons of a Wise Grandmother and this is extr"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/color_primary"
|
||||
android:textSize="12sp"
|
||||
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
|
||||
49
app/src/main/res/layout/notification_view_holder.xml
Normal file
49
app/src/main/res/layout/notification_view_holder.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardBackgroundColor="@color/white">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/days_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="12 days ago"
|
||||
android:fontFamily="@font/exo_2"
|
||||
android:textColor="@color/color_primary_dark"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/body_txt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="This is the text that will appear as a text on the notificationn card"
|
||||
android:fontFamily="@font/exo_2_medium"
|
||||
android:textColor="@color/color_primary_dark"
|
||||
|
||||
android:layout_marginTop="3dp"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -165,4 +165,5 @@
|
||||
<string name="do_you_want_to_exit_from_the_woka_app">Do you want to exit from the WOKA app?</string>
|
||||
<string name="_00_00">00:00</string>
|
||||
<string name="slash">/</string>
|
||||
<string name="notifications">Notifications</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user