Skip to content

Commit efe893d

Browse files
committed
Update Gradle, short toast are only supported
1 parent 03e8bb6 commit efe893d

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

app/src/main/java/com/amjadalwareh/ktx/MainActivity.kt

+3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package com.amjadalwareh.ktx
22

33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
5+
import java.text.NumberFormat
56

67
class MainActivity : AppCompatActivity() {
78

89
override fun onCreate(savedInstanceState: Bundle?) {
910
super.onCreate(savedInstanceState)
1011
setContentView(R.layout.activity_main)
12+
val s = NumberFormat.getCurrencyInstance().format("3")
13+
NumberFormat.getCurrencyInstance().currency?.displayName
1114
}
1215
}

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath "com.android.tools.build:gradle:4.1.1"
9+
classpath 'com.android.tools.build:gradle:4.1.2'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111

1212
// NOTE: Do not place your application dependencies here; they belong

cake/src/main/java/com/amjadalwareh/cake/ContextKt.kt

+4-26
Original file line numberDiff line numberDiff line change
@@ -62,50 +62,28 @@ object ContextKt {
6262
else otherwise()
6363
}
6464

65-
/**
66-
* Show [android.widget.Toast] with long duration.
67-
*/
68-
fun Context.longToast(@StringRes string: Int) {
69-
Utils.toast(this, getString(string), false)
70-
}
71-
7265
/**
7366
* Show [android.widget.Toast] with short duration.
7467
*/
75-
fun Context.shortToast(@StringRes string: Int) {
68+
fun Context.toast(@StringRes string: Int) {
7669
Utils.toast(this, getString(string))
7770
}
7871

79-
/**
80-
* Show [android.widget.Toast] with long duration
81-
*/
82-
fun Context.longToast(string: String) {
83-
Utils.toast(this, string, false)
84-
}
85-
8672
/**
8773
* Show [android.widget.Toast] with short duration
8874
*/
89-
fun Context.shortToast(string: String) {
75+
fun Context.toast(string: String) {
9076
Utils.toast(this, string)
9177
}
9278

93-
fun Fragment.shortToast(@StringRes string: Int) {
79+
fun Fragment.toast(@StringRes string: Int) {
9480
Utils.toast(requireContext(), requireContext().getString(string))
9581
}
9682

97-
fun Fragment.longToast(@StringRes string: Int) {
98-
Utils.toast(requireContext(), requireContext().getString(string), false)
99-
}
100-
101-
fun Fragment.shortToast(string: String) {
83+
fun Fragment.toast(string: String) {
10284
Utils.toast(requireContext(), string)
10385
}
10486

105-
fun Fragment.longToast(string: String) {
106-
Utils.toast(requireContext(), string, false)
107-
}
108-
10987
/**
11088
* Check if @param [permission] is granted or not
11189
*/

cake/src/main/java/com/amjadalwareh/cake/Utils.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ object Utils {
6464

6565
fun getDrawable(context: Context, @DrawableRes id: Int): Drawable? = ContextCompat.getDrawable(context, id)
6666

67-
fun toast(context: Context, string: String, isShort: Boolean = true) {
68-
Toast.makeText(context, string, if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG).show()
67+
fun toast(context: Context, string: String) {
68+
Toast.makeText(context, string, Toast.LENGTH_SHORT).show()
6969
}
7070

71-
fun snackbar(view: View, text: String, shortDuration: Boolean, button: String, funct: () -> Unit) {
71+
fun snackbar(view: View, text: String, shortDuration: Boolean, title: String, funct: () -> Unit) {
7272
Snackbar.make(view, text, if (shortDuration) Snackbar.LENGTH_SHORT else Snackbar.LENGTH_LONG)
73-
.setAction(button) { funct() }
73+
.setAction(title) { funct() }
7474
.show()
7575
}
7676

0 commit comments

Comments
 (0)