adjust resize problem when keyboard is opened in OrderSummaryFragment Solving.

Completed Ui for OrderSummaryFragment.

TV ui on home fragment 1 updates and cleaning.

Masila trailer added to WebSeriesFragment
This commit is contained in:
2024-07-24 20:59:54 +05:30
parent 9742f34fff
commit 6eaa554d8c
10 changed files with 361 additions and 47 deletions

View File

@@ -11,7 +11,7 @@ import com.woka.shop.models.cartlisting.CartItem
import com.woka.utils.show
import java.util.concurrent.Executors
class CartAdapter(private val showFullData: Boolean = true): ListAdapter<CartItem, CartAdapter.CartViewHolder>(ASYNC_DIFF_UTIL) {
class CartAdapter: ListAdapter<CartItem, CartAdapter.CartViewHolder>(ASYNC_DIFF_UTIL) {
companion object{
private val DIFF_UTIL = object :DiffUtil.ItemCallback<CartItem>(){
@@ -47,18 +47,15 @@ class CartAdapter(private val showFullData: Boolean = true): ListAdapter<CartIte
title.text = cartItem.product_name
price.text = "${cartItem.product_price}"
quantityTag.show()
quantity.text = "${cartItem.product_quantity}"
if (showFullData){
quantityTag.show()
quantity.text = "${cartItem.product_quantity}"
statusTag.show()
status.text = "${cartItem.stock_status}"
statusTag.show()
status.text = "${cartItem.stock_status}"
delete.show()
delete.setOnClickListener {
cartItem.id?.let { id -> onCartItemDeleteListener?.invoke(id, holder.absoluteAdapterPosition) }
}
delete.show()
delete.setOnClickListener {
cartItem.id?.let { id -> onCartItemDeleteListener?.invoke(id, holder.absoluteAdapterPosition) }
}
}
}

View File

@@ -0,0 +1,48 @@
package com.woka.shop.adapters
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.SummaryCartItemViewHolderBinding
import com.woka.shop.models.cartlisting.CartItem
import java.util.concurrent.Executors
class SummaryCartAdapter: ListAdapter<CartItem, SummaryCartAdapter.CartViewHolder>(ASYNC_DIFF_UTIL) {
companion object{
private val DIFF_UTIL = object :DiffUtil.ItemCallback<CartItem>(){
override fun areItemsTheSame(oldItem: CartItem, newItem: CartItem): Boolean = oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: CartItem, newItem: CartItem): Boolean = oldItem == newItem
}
private val ASYNC_DIFF_UTIL = AsyncDifferConfig.Builder(DIFF_UTIL)
.setBackgroundThreadExecutor(Executors.newSingleThreadExecutor())
.build()
}
inner class CartViewHolder(val binding: SummaryCartItemViewHolderBinding): ViewHolder(binding.root)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CartViewHolder {
return CartViewHolder(
SummaryCartItemViewHolderBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
)
}
override fun onBindViewHolder(holder: CartViewHolder, position: Int) {
val cartItem = getItem(holder.absoluteAdapterPosition)
with(holder.binding){
if (cartItem.shop_image?.isNotEmpty() == true)
image.loadImage(cartItem.shop_image.first())
title.text = cartItem.product_name
price.text = "${cartItem.product_price}"
}
}
}

View File

@@ -4,14 +4,15 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.woka.R
import com.woka.databinding.FragmentOrderSummaryBinding
import com.woka.networking.ApiResult
import com.woka.shop.adapters.CartAdapter
import com.woka.shop.adapters.CouponAdapter
import com.woka.shop.adapters.SummaryCartAdapter
import com.woka.shop.viewmodels.CartViewModel
import com.woka.utils.hide
import com.woka.utils.show
@@ -21,7 +22,7 @@ class OrderSummaryFragment : Fragment() {
private lateinit var binding: FragmentOrderSummaryBinding
private lateinit var viewModel: CartViewModel
private lateinit var adapter: CartAdapter
private lateinit var adapter: SummaryCartAdapter
private lateinit var couponAdapter: CouponAdapter
override fun onCreateView(
@@ -31,7 +32,7 @@ class OrderSummaryFragment : Fragment() {
binding = FragmentOrderSummaryBinding.inflate(inflater, container, false)
viewModel = ViewModelProvider(requireActivity())[CartViewModel::class.java]
adapter = CartAdapter(false)
adapter = SummaryCartAdapter()
couponAdapter = CouponAdapter()
return binding.root
@@ -42,6 +43,8 @@ class OrderSummaryFragment : Fragment() {
initViews()
clickEvents()
setObservers()
loadCoupons()
@@ -56,6 +59,20 @@ class OrderSummaryFragment : Fragment() {
}
}
private fun clickEvents(){
binding.apply {
showCoupons.setOnClickListener{
if (rvCoupons.isVisible){
rvCoupons.hide()
showCouponIndicator.setImageResource(R.drawable.ic_half_arrow_right)
}else{
rvCoupons.show()
showCouponIndicator.setImageResource(R.drawable.ic_half_arrow_up)
}
}
}
}
private fun loadCoupons(){
lifecycleScope.launch {
when (val response = viewModel.loadCoupons()){

View File

@@ -114,6 +114,29 @@ class WebSeriesFragment private constructor(): Fragment() {
viewModel?.loadMoreWebSeries(it)
}
}
trailerBtn.setOnClickListener {
activity?.let {
it.startActivity(Intent(it, PlayerActivity::class.java).apply {
putExtra(
EXTRA_PLAY_LIST,
VideoPlayList(
ArrayList<PlaylistItem>().apply {
add(
PlaylistItem.Builder()
.file("https://cdn.jwplayer.com/manifests/Iygt11AD.m3u8")
.image("https://cdn.jwplayer.com/manifests/Iygt11AD.m3u8")
.title("Masila")
.build()
)
},
null
)
)
putExtra(EXTRA_PLAY_INDEX, 0)
})
}
}
}
}
private fun initViews(){

View File

@@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginVertical="5dp"
android:layout_marginBottom="10dp"
android:layout_marginHorizontal="15dp"
app:cardCornerRadius="1dp"
app:cardBackgroundColor="@color/color_primary">
@@ -16,13 +16,13 @@
android:layout_height="wrap_content"
tools:text="This is the text"
android:fontFamily="@font/exo_2"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary"
android:textSize="@dimen/_12ssp"
android:textSize="@dimen/_10ssp"
android:layout_marginStart="10dp"
android:layout_marginStart="15dp"
android:paddingHorizontal="15dp"
android:paddingVertical="8dp"
android:paddingVertical="15dp"
android:background="@color/white"

View File

@@ -177,9 +177,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="@dimen/_15sdp"
android:layout_marginTop="@dimen/_15sdp"
android:contentDescription="@string/live_tv"
android:layout_marginTop="@dimen/_15sdp"
android:src="@drawable/img_tv_border"
android:translationZ="1dp" />
@@ -188,16 +187,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/_28sdp"
android:layout_marginTop="@dimen/_44sdp"
android:layout_marginBottom="@dimen/_10sdp"
android:background="@color/white"
android:contentDescription="@string/image"
android:paddingHorizontal="@dimen/_15sdp"
android:src="@color/black"
android:layout_marginHorizontal="@dimen/_37sdp"
android:layout_marginTop="@dimen/_47sdp"
android:layout_marginBottom="@dimen/_12sdp"
android:src="@android:color/black"
android:visibility="visible"
/>
@@ -207,14 +203,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/_40sdp"
android:layout_marginTop="@dimen/_51sdp"
android:layout_marginBottom="@dimen/_12sdp"
android:layout_marginHorizontal="@dimen/_39sdp"
android:layout_marginTop="@dimen/_48sdp"
android:layout_marginBottom="@dimen/_11sdp"
app:resize_mode="fill"
android:background="@color/black"
android:visibility="visible"
/>
android:visibility="visible" />
</RelativeLayout>

View File

@@ -44,24 +44,26 @@
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
android:layout_marginHorizontal="15dp"
android:orientation="horizontal">
<EditText
android:id="@+id/coupon_code"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_height="45dp"
android:layout_weight="0.75"
android:hint="@string/enter_a_coupon_code"
android:textColorHint="@android:color/darker_gray"
android:imeOptions="actionDone"
android:fontFamily="@font/exo_2"
android:textColor="@color/black"
android:textSize="@dimen/_12ssp"
android:paddingHorizontal="15dp"
android:background="@drawable/round_25"
android:paddingHorizontal="20dp"
android:background="@drawable/round_25_shadow"
android:singleLine="true"
android:autofillHints="@null"
@@ -72,7 +74,7 @@
<Button
android:id="@+id/apply_btn"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_height="45dp"
android:layout_weight="0.25"
android:text="@string/apply"
@@ -94,16 +96,15 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white"
android:layout_marginTop="15dp"
android:background="@color/white_50"
/>
<RelativeLayout
android:id="@+id/show_coupons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="10dp">
android:paddingVertical="15dp"
android:layout_marginHorizontal="15dp">
<TextView
android:layout_width="wrap_content"
@@ -118,10 +119,11 @@
/>
<ImageView
android:id="@+id/show_coupon_indicator"
android:layout_width="15dp"
android:layout_height="15dp"
android:contentDescription="@string/image"
android:src="@drawable/ic_half_arrow_right"
android:src="@drawable/ic_half_arrow_up"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
app:tint="@color/color_primary" />
@@ -130,17 +132,176 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_coupons"
android:visibility="visible"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
tools:itemCount="3"
tools:listitem="@layout/coupon_view_holderr"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/discount_view"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white_50"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/sub_total_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subtotal"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
/>
<TextView
android:id="@+id/sub_total_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="$ 299"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintTop_toTopOf="@id/sub_total_tag"
app:layout_constraintBottom_toBottomOf="@id/sub_total_tag"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="15dp"
/>
<TextView
android:id="@+id/discount_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/discount"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/sub_total_tag"
android:layout_marginStart="15dp"
android:layout_marginTop="5dp"
/>
<TextView
android:id="@+id/discount_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="$ 299"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintTop_toTopOf="@id/discount_tag"
app:layout_constraintBottom_toBottomOf="@id/discount_tag"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="15dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white_50"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="25dp"
>
<TextView
android:id="@+id/total_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/total_amount"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="15dp"
/>
<TextView
android:id="@+id/total_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="$ 299"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_14ssp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="15dp"
/>
<Button
android:id="@+id/checkout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/confirm"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/white"
android:textSize="@dimen/_10ssp"
android:layout_marginHorizontal="15dp"
android:layout_marginBottom="15dp"
android:background="@drawable/round_bg_25"
android:backgroundTint="@color/color_primary"
app:layout_constraintTop_toBottomOf="@id/total_amount"
android:layout_marginTop="15dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -181,6 +181,7 @@
/>
<Button
android:id="@+id/trailer_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -0,0 +1,67 @@
<?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"
android:layout_marginHorizontal="15dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@android:color/transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_marginVertical="10dp"
android:orientation="horizontal">
<com.woka.utils.AdiImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="0.25"
app:imageCornerRadius="5dp"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.75"
android:layout_marginStart="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/color_primary"
android:fontFamily="@font/exo_2_bold"
android:textSize="@dimen/_12ssp"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/exo_2_bold"
android:textColor="@color/color_primary"
android:textSize="@dimen/_12ssp"
android:layout_centerVertical="true"
android:layout_marginTop="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@@ -234,4 +234,8 @@
<string name="enter_a_coupon_code">Enter a coupon code</string>
<string name="apply">Apply</string>
<string name="all_offers_coupons"><![CDATA[All Offers & Coupons]]></string>
<string name="total_amount">Total Amount:</string>
<string name="confirm">CONFIRM</string>
<string name="subtotal">Subtotal:</string>
<string name="discount">Discount:</string>
</resources>