Commit a4b84542 authored by shohboz's avatar shohboz

[UPD] MUS-266 Feature, updated merged codes

parents 7f12dde6 ede7a417
package uz.mobiuz.mobiservice.dev.ui.global
import android.annotation.SuppressLint
import java.text.SimpleDateFormat
object CONSTANTS {
const val IS_SAVED_CARD = 1
......@@ -86,7 +89,6 @@ object CONSTANTS {
const val CONFIRM_CHANGE_NEW_PIN = "CONFIRM_CHANGE_NEW_PIN"
//urls
const val API_LOGIN = "customer/login"
const val API_REGISTER = "customer/register"
......@@ -111,4 +113,8 @@ object CONSTANTS {
const val PAY_SAVE_CARD = "PAYMENT_SAVE_CARD"
const val PAY_CARD_NUMBER = "PAYMENT_CARD_NUMBER"
const val PAY_MONITORING = "PAY_MONITORING"
@SuppressLint("SimpleDateFormat")
val DATE_FORMAT = SimpleDateFormat("dd-MM-yyyy")
val HOUR_FORMAT = SimpleDateFormat("hh:mm")
}
......@@ -8,6 +8,7 @@ import com.hannesdorfmann.adapterdelegates4.AdapterDelegate
import kotlinx.android.synthetic.main.item_history_header.view.*
import uz.agr.sdk.coreui.extension.inflate
import uz.mobiuz.mobiservice.dev.R
import uz.mobiuz.mobiservice.dev.utils.extensions.getDate
import uz.mobiuz.mobiservice.dev.model.Tuple2
import java.text.ParseException
import java.text.SimpleDateFormat
......@@ -31,7 +32,7 @@ class HistoryHeaderDelegate : AdapterDelegate<MutableList<Any>>() {
@SuppressLint("SetTextI18n")
fun bind(header: Tuple2) {
try {
containerView.tvTitle.text = header.first
containerView.tvTitle.text = header.first.getDate(context = containerView.context)
if (header.second.isNotEmpty() && header.second.length > 4) {
if (header.second != "0") {
if (header.second[0] == '-') {
......
......@@ -9,6 +9,9 @@ import uz.agr.sdk.coreui.ui.list.ProgressAdapterDelegate
import uz.agr.sdk.coreui.ui.list.ProgressItem
import uz.mobiuz.mobiservice.dev.model.Monitoring
import uz.mobiuz.mobiservice.dev.model.Tuple2
import uz.mobiuz.mobiservice.dev.ui.global.CONSTANTS
import java.util.*
import kotlin.collections.HashMap
class MonitoringAdapter : ListDelegationAdapter<MutableList<Any>>() {
......@@ -30,28 +33,30 @@ class MonitoringAdapter : ListDelegationAdapter<MutableList<Any>>() {
val hashMap = HashMap<String, String>()
for (item in historyList) {
val it = hashMap[item.date.toString()]
val todayDate = CONSTANTS.DATE_FORMAT.format((Date(item.date)))
val it = hashMap[todayDate]
summa -= item.amount
if (it != null) {
val i = (it.toLong() + summa).toString()
hashMap[item.date.toString()] = i
hashMap[todayDate] = i
} else {
hashMap[item.date.toString()] = "$summa"
hashMap[todayDate] = "$summa"
}
summa = 0
}
var tempDate = ""
for (item in historyList) {
if (tempDate != item.date.toString()) {
val value = hashMap[item.date.toString()]
val todayDate = CONSTANTS.DATE_FORMAT.format((Date(item.date)))
if (tempDate != todayDate) {
val value = hashMap[todayDate]
items.add(
Tuple2(
item.date.toString(),
todayDate,
((value?.replaceRange(value.length - 2, value.length, "") ?: "0").toInt() * 100).formattedMoney(false) + " UZS"
)
)
tempDate = item.date.toString()
tempDate = todayDate
}
items.add(item)
}
......
......@@ -10,6 +10,7 @@ import uz.agr.sdk.coreui.extension.formattedMoney
import uz.agr.sdk.coreui.extension.inflate
import uz.mobiuz.mobiservice.dev.R
import uz.mobiuz.mobiservice.dev.model.Monitoring
import uz.mobiuz.mobiservice.dev.ui.global.CONSTANTS
import uz.mobiuz.mobiservice.dev.utils.extensions.formatCard
import uz.mobiuz.mobiservice.dev.utils.extensions.formatPhone
import java.text.SimpleDateFormat
......@@ -40,7 +41,7 @@ class MonitoringDelegate : AdapterDelegate<MutableList<Any>>() {
containerView.cardPan.text = history.pan.formatCard()
containerView.tvAmount.text = "- " + (history.amount * 100).formattedMoney(false) + " " + itemView.context.getString(R.string.agr_mobi_uz_curr)
// val date = timeFormat.format(history.date)
val date = history.date.toString()
val date = CONSTANTS.HOUR_FORMAT.format((Date(history.date)))
containerView.tvTime.text = date
containerView.tvTransType.text = history.phone.formatPhone()
}
......
package uz.mobiuz.mobiservice.dev.utils.extensions
import android.content.Context
import uz.mobiuz.mobiservice.dev.R
/**
* Created by DostonbekIbragimov on 07/01/2022.
*/
fun String.getDate(context: Context): String {
val day = this.substring(0, 2).toInt()
val month = this.substring(3, 5).toInt()
val year = this.substring(6, 10).toInt()
return "$day ${getMonth(month, context)} $year"
}
fun getMonth(month: Int, context: Context): String {
return when (month) {
1 -> context.getString(R.string.agr_mobi_uz_month_1)
2 -> context.getString(R.string.agr_mobi_uz_month_2)
3 -> context.getString(R.string.agr_mobi_uz_month_3)
4 -> context.getString(R.string.agr_mobi_uz_month_4)
5 -> context.getString(R.string.agr_mobi_uz_month_5)
6 -> context.getString(R.string.agr_mobi_uz_month_6)
7 -> context.getString(R.string.agr_mobi_uz_month_7)
8 -> context.getString(R.string.agr_mobi_uz_month_8)
9 -> context.getString(R.string.agr_mobi_uz_month_9)
10 -> context.getString(R.string.agr_mobi_uz_month_10)
11 -> context.getString(R.string.agr_mobi_uz_month_11)
else -> context.getString(R.string.agr_mobi_uz_month_12)
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/agr_ToolbarStyle"
......@@ -18,7 +17,6 @@
app:navigationIcon="@drawable/ic_baseline_arrow_back"
app:title="@string/agr_mobi_uz_history_title" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
......@@ -32,6 +30,7 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
tools:listitem="@layout/monitoring_item" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment