This commit is contained in:
InsanusMokrassar 2021-06-06 01:46:33 +06:00
parent e0d5eb45b7
commit 04a95867e2
4 changed files with 57 additions and 2 deletions

View File

@ -2,6 +2,14 @@
## 0.5.7
* `Android`
* `Alerts`
* `Common`
* New extension `progressBarAlertDialog`
* `Pagination`
* `Ktor`
* `Server`
* Fixes in extension `extractPagination`
* `Repos`
* `Cache`
* All standard cache repos have been separated to read and read/write repos

View File

@ -0,0 +1,27 @@
package dev.inmo.micro_utils.android.alerts.common
import android.content.Context
import android.view.LayoutInflater
import android.widget.TextView
import androidx.annotation.StringRes
fun Context.createProgressBarAlertDialog(
text: String? = null,
onClick: (() -> Unit)? = null
) = createCustomViewAlertDialog {
(it.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(
R.layout.alert_dialog_progress_bar, null, false
).apply {
onClick ?.let {
setOnClickListener { onClick() }
} ?: setOnClickListener { /* do nothing */ }
text ?.let {
findViewById<TextView>(R.id.alertDialogProgressBarTitle).text = it
}
}
}
fun Context.createProgressBarAlertDialog(
@StringRes textRes: Int,
onClick: (() -> Unit)? = null
) = createProgressBarAlertDialog(getString(textRes), onClick)

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ProgressBar
android:id="@+id/alertDialogProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/alertDialogProgressBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
</LinearLayout>

View File

@ -5,8 +5,8 @@ import io.ktor.http.Parameters
val Parameters.extractPagination: Pagination
get() = SimplePagination(
get("page") ?.toIntOrNull() ?: 0,
get("size") ?.toIntOrNull() ?: defaultPaginationPageSize
get(paginationPageKey) ?.toIntOrNull() ?: 0,
get(paginationSizeKey) ?.toIntOrNull() ?: defaultPaginationPageSize
)
val ApplicationCall.extractPagination: Pagination