Skip to content

Commit d423959

Browse files
committed
toast and snackbar
1 parent 3b8549e commit d423959

8 files changed

Lines changed: 34 additions & 9 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@file:Suppress("NOTHING_TO_INLINE", "unused")
2+
3+
package com.commit451.addendum.design
4+
5+
import android.view.View
6+
import androidx.annotation.StringRes
7+
import com.google.android.material.snackbar.Snackbar
8+
9+
10+
inline fun View.snackbar(@StringRes resId: Int, length: Int = Snackbar.LENGTH_SHORT, shouldShow: Boolean = true): Snackbar {
11+
return snackbar(resources.getText(resId), length, shouldShow)
12+
}
13+
14+
inline fun View.snackbar(text: CharSequence, length: Int = Snackbar.LENGTH_SHORT, shouldShow: Boolean = true): Snackbar {
15+
val snackbar = Snackbar.make(this, text, length)
16+
if (shouldShow) {
17+
snackbar.show()
18+
}
19+
return snackbar
20+
}

addendum-threetenabp/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
}
1414

1515
dependencies {
16-
api "com.jakewharton.threetenabp:threetenabp:1.1.1"
16+
api "com.jakewharton.threetenabp:threetenabp:1.2.1"
1717
implementation project(':addendum')
1818
}
1919

addendum/src/main/java/com/commit451/addendum/Context.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ import android.content.Context
88
import android.graphics.Color
99
import android.graphics.drawable.Drawable
1010
import android.util.TypedValue
11+
import android.widget.Toast
1112
import androidx.annotation.AttrRes
1213
import androidx.annotation.ColorInt
1314
import androidx.annotation.ColorRes
1415
import androidx.core.content.ContextCompat
1516

17+
inline fun Context.toast(text: String, length: Int = Toast.LENGTH_SHORT) {
18+
Toast.makeText(this, text, length)
19+
.show()
20+
}
1621

1722
@ColorInt
18-
inline fun Context.color(@ColorRes color: Int) : Int {
23+
inline fun Context.color(@ColorRes color: Int): Int {
1924
return ContextCompat.getColor(this, color)
2025
}
2126

@@ -68,4 +73,4 @@ inline fun Context.themeAttrDimen(@AttrRes attributeDimen: Int): Float {
6873
value = TypedValue.complexToDimensionPixelSize(tv.data, resources.displayMetrics)
6974
}
7075
return value.toFloat()
71-
}
76+
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.21'
2+
ext.kotlin_version = '1.3.31'
33
repositories {
44
google()
55
jcenter()
66
}
77
dependencies {
88
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9-
classpath 'com.android.tools.build:gradle:3.3.1'
9+
classpath 'com.android.tools.build:gradle:3.4.1'
1010
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1111
}
1212
}
1313

1414
plugins {
15-
id 'com.github.ben-manes.versions' version '0.20.0'
15+
id 'com.github.ben-manes.versions' version '0.21.0'
1616
}
1717

1818
allprojects {

gradle/wrapper/gradle-wrapper.jar

-987 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)