pull/90/head^2
kunfei 5 years ago
parent 97da203675
commit 1dc55667e3
  1. 5
      app/src/main/java/io/legado/app/lib/theme/TintHelper.kt
  2. 4
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt
  3. 2
      app/src/main/java/io/legado/app/ui/explore/ExploreShowViewModel.kt
  4. 2
      app/src/main/java/io/legado/app/ui/filechooser/adapter/FileAdapter.kt
  5. 1
      app/src/main/java/io/legado/app/ui/filechooser/adapter/PathAdapter.kt
  6. 40
      app/src/main/java/io/legado/app/ui/filechooser/utils/FileUtils.kt
  7. 10
      app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt
  8. 23
      app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt
  9. 158
      app/src/main/java/io/legado/app/utils/Snackbars.kt
  10. 8
      app/src/main/java/io/legado/app/utils/Toasts.kt

@ -254,11 +254,10 @@ object TintHelper {
if (!skipIndeterminate) if (!skipIndeterminate)
progressBar.indeterminateTintList = sl progressBar.indeterminateTintList = sl
} else { } else {
val mode = PorterDuff.Mode.SRC_IN
if (!skipIndeterminate && progressBar.indeterminateDrawable != null) if (!skipIndeterminate && progressBar.indeterminateDrawable != null)
progressBar.indeterminateDrawable.setColorFilter(color, mode) progressBar.indeterminateDrawable.setTint(color)
if (progressBar.progressDrawable != null) if (progressBar.progressDrawable != null)
progressBar.progressDrawable.setColorFilter(color, mode) progressBar.progressDrawable.setTint(color)
} }
} }

@ -74,8 +74,6 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
} }
override fun delBookmark(bookmark: Bookmark) { override fun delBookmark(bookmark: Bookmark) {
bookmark?.let { App.db.bookmarkDao().delByBookmark(bookmark.bookUrl, bookmark.chapterName)
App.db.bookmarkDao().delByBookmark(it.bookUrl, it.chapterName)
}
} }
} }

@ -21,7 +21,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
execute { execute {
val sourceUrl = intent.getStringExtra("sourceUrl") val sourceUrl = intent.getStringExtra("sourceUrl")
exploreUrl = intent.getStringExtra("exploreUrl") exploreUrl = intent.getStringExtra("exploreUrl")
if (bookSource == null) { if (bookSource == null && sourceUrl != null) {
bookSource = App.db.bookSourceDao().getBookSource(sourceUrl) bookSource = App.db.bookSourceDao().getBookSource(sourceUrl)
} }
explore() explore()

@ -64,7 +64,7 @@ class FileAdapter(context: Context, val callBack: CallBack) :
fileParent.icon = upIcon fileParent.icon = upIcon
fileParent.name = DIR_PARENT fileParent.name = DIR_PARENT
fileParent.size = 0 fileParent.size = 0
fileParent.path = File(path).parent fileParent.path = File(path).parent ?: ""
data.add(fileParent) data.add(fileParent)
} }
currentPath?.let { currentPath -> currentPath?.let { currentPath ->

@ -15,6 +15,7 @@ import java.util.*
class PathAdapter(context: Context, val callBack: CallBack) : class PathAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<String>(context, R.layout.item_path_filepicker) { SimpleRecyclerAdapter<String>(context, R.layout.item_path_filepicker) {
private val paths = LinkedList<String>() private val paths = LinkedList<String>()
@Suppress("DEPRECATION")
private val sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath private val sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath
private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getARROW()) private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getARROW())

@ -34,13 +34,13 @@ object FileUtils {
* 将目录分隔符统一为平台默认的分隔符并为目录结尾添加分隔符 * 将目录分隔符统一为平台默认的分隔符并为目录结尾添加分隔符
*/ */
fun separator(path: String): String { fun separator(path: String): String {
var path = path var path1 = path
val separator = File.separator val separator = File.separator
path = path.replace("\\", separator) path1 = path1.replace("\\", separator)
if (!path.endsWith(separator)) { if (!path1.endsWith(separator)) {
path += separator path1 += separator
} }
return path return path1
} }
fun closeSilently(c: Closeable?) { fun closeSilently(c: Closeable?) {
@ -62,7 +62,7 @@ object FileUtils {
startDirPath: String, startDirPath: String,
excludeDirs: Array<String?>? = null, @SortType sortType: Int = BY_NAME_ASC excludeDirs: Array<String?>? = null, @SortType sortType: Int = BY_NAME_ASC
): Array<File?> { ): Array<File?> {
var excludeDirs = excludeDirs var excludeDirs1 = excludeDirs
val dirList = ArrayList<File>() val dirList = ArrayList<File>()
val startDir = File(startDirPath) val startDir = File(startDirPath)
if (!startDir.isDirectory) { if (!startDir.isDirectory) {
@ -75,12 +75,12 @@ object FileUtils {
f.isDirectory f.isDirectory
}) })
?: return arrayOfNulls(0) ?: return arrayOfNulls(0)
if (excludeDirs == null) { if (excludeDirs1 == null) {
excludeDirs = arrayOfNulls(0) excludeDirs1 = arrayOfNulls(0)
} }
for (dir in dirs) { for (dir in dirs) {
val file = dir.absoluteFile val file = dir.absoluteFile
if (!excludeDirs.contentDeepToString().contains(file.name)) { if (!excludeDirs1.contentDeepToString().contains(file.name)) {
dirList.add(file) dirList.add(file)
} }
} }
@ -191,7 +191,7 @@ object FileUtils {
*/ */
fun listFiles(startDirPath: String, allowExtensions: Array<String?>): Array<File?>? { fun listFiles(startDirPath: String, allowExtensions: Array<String?>): Array<File?>? {
val file = File(startDirPath) val file = File(startDirPath)
return file.listFiles { dir, name -> return file.listFiles { _, name ->
//返回当前目录所有以某些扩展名结尾的文件 //返回当前目录所有以某些扩展名结尾的文件
val extension = getExtension(name) val extension = getExtension(name)
allowExtensions.contentDeepToString().contains(extension) allowExtensions.contentDeepToString().contains(extension)
@ -294,10 +294,8 @@ object FileUtils {
bis.close() bis.close()
bos.close() bos.close()
} else if (src.isDirectory) { } else if (src.isDirectory) {
val files = src.listFiles()
tar.mkdirs() tar.mkdirs()
for (file in files) { src.listFiles()?.forEach { file ->
copy(file.absoluteFile, File(tar.absoluteFile, file.name)) copy(file.absoluteFile, File(tar.absoluteFile, file.name))
} }
} }
@ -399,18 +397,16 @@ object FileUtils {
fun writeBytes(filepath: String, data: ByteArray): Boolean { fun writeBytes(filepath: String, data: ByteArray): Boolean {
val file = File(filepath) val file = File(filepath)
var fos: FileOutputStream? = null var fos: FileOutputStream? = null
try { return try {
if (!file.exists()) { if (!file.exists()) {
file.parentFile?.mkdirs()
file.parentFile.mkdirs()
file.createNewFile() file.createNewFile()
} }
fos = FileOutputStream(filepath) fos = FileOutputStream(filepath)
fos.write(data) fos.write(data)
return true true
} catch (e: IOException) { } catch (e: IOException) {
return false false
} finally { } finally {
closeSilently(fos) closeSilently(fos)
} }
@ -422,16 +418,16 @@ object FileUtils {
fun appendText(path: String, content: String): Boolean { fun appendText(path: String, content: String): Boolean {
val file = File(path) val file = File(path)
var writer: FileWriter? = null var writer: FileWriter? = null
try { return try {
if (!file.exists()) { if (!file.exists()) {
file.createNewFile() file.createNewFile()
} }
writer = FileWriter(file, true) writer = FileWriter(file, true)
writer.write(content) writer.write(content)
return true true
} catch (e: IOException) { } catch (e: IOException) {
return false false
} finally { } finally {
closeSilently(writer) closeSilently(writer)
} }

@ -23,13 +23,11 @@ import java.util.*
class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rect) : class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rect) :
ValueAnimator() { ValueAnimator() {
private val mPaint: Paint private val mPaint: Paint = Paint()
private val mParticles: Array<Particle?> private val mParticles: Array<Particle?>
private val mBound: Rect private val mBound: Rect = Rect(bound)
init { init {
mPaint = Paint()
mBound = Rect(bound)
val partLen = 15 val partLen = 15
mParticles = arrayOfNulls(partLen * partLen) mParticles = arrayOfNulls(partLen * partLen)
val random = Random(System.currentTimeMillis()) val random = Random(System.currentTimeMillis())
@ -97,7 +95,7 @@ class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rec
override fun start() { override fun start() {
super.start() super.start()
mContainer.invalidate(mBound) mContainer.invalidate()
} }
private inner class Particle { private inner class Particle {
@ -141,7 +139,7 @@ class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rec
internal var DEFAULT_DURATION: Long = 0x400 internal var DEFAULT_DURATION: Long = 0x400
private val DEFAULT_INTERPOLATOR = AccelerateInterpolator(0.6f) private val DEFAULT_INTERPOLATOR = AccelerateInterpolator(0.6f)
private val END_VALUE = 1.4f private const val END_VALUE = 1.4f
private val X = Utils.dp2Px(5).toFloat() private val X = Utils.dp2Px(5).toFloat()
private val Y = Utils.dp2Px(20).toFloat() private val Y = Utils.dp2Px(20).toFloat()
private val V = Utils.dp2Px(2).toFloat() private val V = Utils.dp2Px(2).toFloat()

@ -482,18 +482,17 @@ class FastScroller : LinearLayout {
var showTrack = true var showTrack = true
if (attrs != null) { if (attrs != null) {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.FastScroller, 0, 0) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.FastScroller, 0, 0)
if (typedArray != null) { try {
try { bubbleColor = typedArray.getColor(R.styleable.FastScroller_bubbleColor, bubbleColor)
bubbleColor = typedArray.getColor(R.styleable.FastScroller_bubbleColor, bubbleColor) handleColor = typedArray.getColor(R.styleable.FastScroller_handleColor, handleColor)
handleColor = typedArray.getColor(R.styleable.FastScroller_handleColor, handleColor) trackColor = typedArray.getColor(R.styleable.FastScroller_trackColor, trackColor)
trackColor = typedArray.getColor(R.styleable.FastScroller_trackColor, trackColor) textColor = typedArray.getColor(R.styleable.FastScroller_bubbleTextColor, textColor)
textColor = typedArray.getColor(R.styleable.FastScroller_bubbleTextColor, textColor) fadeScrollbar =
fadeScrollbar = typedArray.getBoolean(R.styleable.FastScroller_fadeScrollbar, fadeScrollbar) typedArray.getBoolean(R.styleable.FastScroller_fadeScrollbar, fadeScrollbar)
showBubble = typedArray.getBoolean(R.styleable.FastScroller_showBubble, showBubble) showBubble = typedArray.getBoolean(R.styleable.FastScroller_showBubble, showBubble)
showTrack = typedArray.getBoolean(R.styleable.FastScroller_showTrack, showTrack) showTrack = typedArray.getBoolean(R.styleable.FastScroller_showTrack, showTrack)
} finally { } finally {
typedArray.recycle() typedArray.recycle()
}
} }
} }
setTrackColor(trackColor) setTrackColor(trackColor)

@ -4,139 +4,13 @@ import android.view.View
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
/**
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.snackbar(Int)' instead.", ReplaceWith("view.snackbar(message)"))
inline fun snackbar(view: View, message: Int) = Snackbar
.make(view, message, Snackbar.LENGTH_SHORT)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.longSnackbar(Int)' instead.", ReplaceWith("view.longSnackbar(message)"))
inline fun longSnackbar(view: View, message: Int) = Snackbar
.make(view, message, Snackbar.LENGTH_LONG)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.indefiniteSnackbar(Int)' instead.", ReplaceWith("view.indefiniteSnackbar(message)"))
inline fun indefiniteSnackbar(view: View, message: Int) = Snackbar
.make(view, message, Snackbar.LENGTH_INDEFINITE)
.apply { show() }
/**
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.snackbar(CharSequence)' instead.", ReplaceWith("view.snackbar(message)"))
inline fun snackbar(view: View, message: CharSequence) = Snackbar
.make(view, message, Snackbar.LENGTH_SHORT)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.longSnackbar(CharSequence)' instead.", ReplaceWith("view.longSnackbar(message)"))
inline fun longSnackbar(view: View, message: CharSequence) = Snackbar
.make(view, message, Snackbar.LENGTH_LONG)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.indefiniteSnackbar(CharSequence)' instead.", ReplaceWith("view.indefiniteSnackbar(message)"))
inline fun indefiniteSnackbar(view: View, message: CharSequence) = Snackbar
.make(view, message, Snackbar.LENGTH_INDEFINITE)
.apply { show() }
/**
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.snackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.snackbar(message, actionText, action)"))
inline fun snackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_SHORT)
.setAction(actionText, action)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.longSnackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.longSnackbar(message, actionText, action)"))
inline fun longSnackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_LONG)
.setAction(actionText, action)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
*
* @param message the message text resource.
*/
@Deprecated("Use 'View.indefiniteSnackbar(Int, Int, (View) -> Unit)' instead.", ReplaceWith("view.indefiniteSnackbar(message, actionText, action)"))
inline fun indefiniteSnackbar(view: View, message: Int, actionText: Int, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_INDEFINITE)
.setAction(actionText, action)
.apply { show() }
/**
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.snackbar(CharSequence, CharSequence, (View) -> Unit)' instead.", ReplaceWith("view.snackbar(message, actionText, action)"))
inline fun snackbar(view: View, message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_SHORT)
.setAction(actionText, action)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_LONG] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.longSnackbar(CharSequence, CharSequence, (View) -> Unit)' instead.", ReplaceWith("view.longSnackbar(message, actionText, action)"))
inline fun longSnackbar(view: View, message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_LONG)
.setAction(actionText, action)
.apply { show() }
/**
* Display Snackbar with the [Snackbar.LENGTH_INDEFINITE] duration.
*
* @param message the message text.
*/
@Deprecated("Use 'View.indefiniteSnackbar(CharSequence, CharSequence, (View) -> Unit)' instead.", ReplaceWith("view.indefiniteSnackbar(message, actionText, action)"))
inline fun indefiniteSnackbar(view: View, message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar
.make(view, message, Snackbar.LENGTH_INDEFINITE)
.setAction(actionText, action)
.apply { show() }
/** /**
* Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration. * Display the Snackbar with the [Snackbar.LENGTH_SHORT] duration.
* *
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("snackbar2") @JvmName("snackbar2")
inline fun View.snackbar(@StringRes message: Int) = Snackbar fun View.snackbar(@StringRes message: Int) = Snackbar
.make(this, message, Snackbar.LENGTH_SHORT) .make(this, message, Snackbar.LENGTH_SHORT)
.apply { show() } .apply { show() }
@ -146,7 +20,7 @@ inline fun View.snackbar(@StringRes message: Int) = Snackbar
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("longSnackbar2") @JvmName("longSnackbar2")
inline fun View.longSnackbar(@StringRes message: Int) = Snackbar fun View.longSnackbar(@StringRes message: Int) = Snackbar
.make(this, message, Snackbar.LENGTH_LONG) .make(this, message, Snackbar.LENGTH_LONG)
.apply { show() } .apply { show() }
@ -156,7 +30,7 @@ inline fun View.longSnackbar(@StringRes message: Int) = Snackbar
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("indefiniteSnackbar2") @JvmName("indefiniteSnackbar2")
inline fun View.indefiniteSnackbar(@StringRes message: Int) = Snackbar fun View.indefiniteSnackbar(@StringRes message: Int) = Snackbar
.make(this, message, Snackbar.LENGTH_INDEFINITE) .make(this, message, Snackbar.LENGTH_INDEFINITE)
.apply { show() } .apply { show() }
@ -166,7 +40,7 @@ inline fun View.indefiniteSnackbar(@StringRes message: Int) = Snackbar
* @param message the message text. * @param message the message text.
*/ */
@JvmName("snackbar2") @JvmName("snackbar2")
inline fun View.snackbar(message: CharSequence) = Snackbar fun View.snackbar(message: CharSequence) = Snackbar
.make(this, message, Snackbar.LENGTH_SHORT) .make(this, message, Snackbar.LENGTH_SHORT)
.apply { show() } .apply { show() }
@ -176,7 +50,7 @@ inline fun View.snackbar(message: CharSequence) = Snackbar
* @param message the message text. * @param message the message text.
*/ */
@JvmName("longSnackbar2") @JvmName("longSnackbar2")
inline fun View.longSnackbar(message: CharSequence) = Snackbar fun View.longSnackbar(message: CharSequence) = Snackbar
.make(this, message, Snackbar.LENGTH_LONG) .make(this, message, Snackbar.LENGTH_LONG)
.apply { show() } .apply { show() }
@ -186,7 +60,7 @@ inline fun View.longSnackbar(message: CharSequence) = Snackbar
* @param message the message text. * @param message the message text.
*/ */
@JvmName("indefiniteSnackbar2") @JvmName("indefiniteSnackbar2")
inline fun View.indefiniteSnackbar(message: CharSequence) = Snackbar fun View.indefiniteSnackbar(message: CharSequence) = Snackbar
.make(this, message, Snackbar.LENGTH_INDEFINITE) .make(this, message, Snackbar.LENGTH_INDEFINITE)
.apply { show() } .apply { show() }
@ -196,7 +70,7 @@ inline fun View.indefiniteSnackbar(message: CharSequence) = Snackbar
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("snackbar2") @JvmName("snackbar2")
inline fun View.snackbar(message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar fun View.snackbar(message: Int, @StringRes actionText: Int, action: (View) -> Unit) = Snackbar
.make(this, message, Snackbar.LENGTH_SHORT) .make(this, message, Snackbar.LENGTH_SHORT)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }
@ -207,7 +81,8 @@ inline fun View.snackbar(message: Int, @StringRes actionText: Int, noinline acti
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("longSnackbar2") @JvmName("longSnackbar2")
inline fun View.longSnackbar(@StringRes message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar fun View.longSnackbar(@StringRes message: Int, @StringRes actionText: Int, action: (View) -> Unit) =
Snackbar
.make(this, message, Snackbar.LENGTH_LONG) .make(this, message, Snackbar.LENGTH_LONG)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }
@ -218,7 +93,8 @@ inline fun View.longSnackbar(@StringRes message: Int, @StringRes actionText: Int
* @param message the message text resource. * @param message the message text resource.
*/ */
@JvmName("indefiniteSnackbar2") @JvmName("indefiniteSnackbar2")
inline fun View.indefiniteSnackbar(@StringRes message: Int, @StringRes actionText: Int, noinline action: (View) -> Unit) = Snackbar fun View.indefiniteSnackbar(@StringRes message: Int, @StringRes actionText: Int, action: (View) -> Unit) =
Snackbar
.make(this, message, Snackbar.LENGTH_INDEFINITE) .make(this, message, Snackbar.LENGTH_INDEFINITE)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }
@ -229,7 +105,8 @@ inline fun View.indefiniteSnackbar(@StringRes message: Int, @StringRes actionTex
* @param message the message text. * @param message the message text.
*/ */
@JvmName("snackbar2") @JvmName("snackbar2")
inline fun View.snackbar(message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar fun View.snackbar(message: CharSequence, actionText: CharSequence, action: (View) -> Unit) =
Snackbar
.make(this, message, Snackbar.LENGTH_SHORT) .make(this, message, Snackbar.LENGTH_SHORT)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }
@ -240,7 +117,8 @@ inline fun View.snackbar(message: CharSequence, actionText: CharSequence, noinli
* @param message the message text. * @param message the message text.
*/ */
@JvmName("longSnackbar2") @JvmName("longSnackbar2")
inline fun View.longSnackbar(message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar fun View.longSnackbar(message: CharSequence, actionText: CharSequence, action: (View) -> Unit) =
Snackbar
.make(this, message, Snackbar.LENGTH_LONG) .make(this, message, Snackbar.LENGTH_LONG)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }
@ -251,7 +129,11 @@ inline fun View.longSnackbar(message: CharSequence, actionText: CharSequence, no
* @param message the message text. * @param message the message text.
*/ */
@JvmName("indefiniteSnackbar2") @JvmName("indefiniteSnackbar2")
inline fun View.indefiniteSnackbar(message: CharSequence, actionText: CharSequence, noinline action: (View) -> Unit) = Snackbar fun View.indefiniteSnackbar(
message: CharSequence,
actionText: CharSequence,
action: (View) -> Unit
) = Snackbar
.make(this, message, Snackbar.LENGTH_INDEFINITE) .make(this, message, Snackbar.LENGTH_INDEFINITE)
.setAction(actionText, action) .setAction(actionText, action)
.apply { show() } .apply { show() }

@ -11,25 +11,25 @@ import org.jetbrains.anko.toast
* *
* @param message the message text resource. * @param message the message text resource.
*/ */
inline fun Fragment.toast(message: Int) = requireActivity().toast(message) fun Fragment.toast(message: Int) = requireActivity().toast(message)
/** /**
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration. * Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
* *
* @param message the message text. * @param message the message text.
*/ */
inline fun Fragment.toast(message: CharSequence) = requireActivity().toast(message) fun Fragment.toast(message: CharSequence) = requireActivity().toast(message)
/** /**
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration. * Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
* *
* @param message the message text resource. * @param message the message text resource.
*/ */
inline fun Fragment.longToast(message: Int) = requireActivity().longToast(message) fun Fragment.longToast(message: Int) = requireActivity().longToast(message)
/** /**
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration. * Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
* *
* @param message the message text. * @param message the message text.
*/ */
inline fun Fragment.longToast(message: CharSequence) = requireActivity().longToast(message) fun Fragment.longToast(message: CharSequence) = requireActivity().longToast(message)

Loading…
Cancel
Save