Manga in Kotlin. Expect some errors yet

This commit is contained in:
len
2016-03-13 22:06:32 +01:00
parent a87c65872c
commit f49577bc77
36 changed files with 1928 additions and 2196 deletions

View File

@@ -17,6 +17,15 @@ fun Context.toast(@StringRes resource: Int, duration: Int = Toast.LENGTH_SHORT)
Toast.makeText(this, resource, duration).show()
}
/**
* Display a toast in this context.
* @param text the text to display.
* @param duration the duration of the toast. Defaults to short.
*/
fun Context.toast(text: String?, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(this, text, duration).show()
}
/**
* Helper method to create a notification.
* @param func the function that will execute inside the builder.

View File

@@ -0,0 +1,18 @@
package eu.kanade.tachiyomi.util
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import android.widget.ImageView
/**
* Set a drawable on a [ImageView] using [ContextCompat] for backwards compatibility.
*
* @param drawable id of drawable resource
*/
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) {
if (drawable != null) {
setImageDrawable(ContextCompat.getDrawable(context, drawable))
} else {
setImageResource(android.R.color.transparent)
}
}