lets use Glide for loading images at the SD and OTG write permissions
This commit is contained in:
parent
f8ff042513
commit
6796e84965
3 changed files with 17 additions and 13 deletions
|
@ -2,9 +2,13 @@ package com.simplemobiletools.commons.dialogs
|
|||
|
||||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_write_permission.view.*
|
||||
import kotlinx.android.synthetic.main.dialog_write_permission_otg.view.*
|
||||
|
||||
class WritePermissionDialog(activity: Activity, val isOTG: Boolean, val callback: () -> Unit) {
|
||||
var dialog: AlertDialog
|
||||
|
@ -13,8 +17,17 @@ class WritePermissionDialog(activity: Activity, val isOTG: Boolean, val callback
|
|||
val layout = if (isOTG) R.layout.dialog_write_permission_otg else R.layout.dialog_write_permission
|
||||
val view = activity.layoutInflater.inflate(layout, null)
|
||||
|
||||
val glide = Glide.with(activity)
|
||||
val crossFade = DrawableTransitionOptions.withCrossFade()
|
||||
if (isOTG) {
|
||||
glide.load(R.drawable.img_write_storage_otg).transition(crossFade).into(view.write_permissions_dialog_otg_image)
|
||||
} else {
|
||||
glide.load(R.drawable.img_write_storage).transition(crossFade).into(view.write_permissions_dialog_image)
|
||||
glide.load(R.drawable.img_write_storage_sd).transition(crossFade).into(view.write_permissions_dialog_image_sd)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setOnCancelListener { BaseSimpleActivity.funAfterSAFPermission = null }
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.confirm_storage_access_title)
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
<ImageView
|
||||
android:id="@+id/write_permissions_dialog_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/img_write_storage"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/write_permissions_dialog_text_sd"
|
||||
|
@ -33,9 +30,6 @@
|
|||
<ImageView
|
||||
android:id="@+id/write_permissions_dialog_image_sd"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/img_write_storage_sd"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
<ImageView
|
||||
android:id="@+id/write_permissions_dialog_otg_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/img_write_storage_otg"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue