store dialog holders as views, not viewgroups

This commit is contained in:
tibbi 2016-12-29 23:48:34 +01:00
parent 5eb44b5bcf
commit 23768d847f
6 changed files with 14 additions and 17 deletions

View file

@ -3,7 +3,7 @@ package com.simplemobiletools.gallery.dialogs
import android.content.DialogInterface import android.content.DialogInterface
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.View
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.activities.SimpleActivity
@ -15,12 +15,12 @@ class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting:
private var currSorting = 0 private var currSorting = 0
lateinit var config: Config lateinit var config: Config
lateinit var view: ViewGroup lateinit var view: View
} }
init { init {
config = Config.newInstance(activity) config = Config.newInstance(activity)
view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null) as ViewGroup view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null)
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, this) .setPositiveButton(R.string.ok, this)

View file

@ -3,7 +3,7 @@ package com.simplemobiletools.gallery.dialogs
import android.support.v4.util.Pair import android.support.v4.util.Pair
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.View
import com.simplemobiletools.commons.asynctasks.CopyMoveTask import com.simplemobiletools.commons.asynctasks.CopyMoveTask
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -15,11 +15,11 @@ import java.util.*
class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val copyMoveListener: CopyMoveTask.CopyMoveListener) { class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val copyMoveListener: CopyMoveTask.CopyMoveListener) {
companion object { companion object {
lateinit var view: ViewGroup lateinit var view: View
} }
init { init {
view = LayoutInflater.from(activity).inflate(R.layout.dialog_copy_move, null) as ViewGroup view = LayoutInflater.from(activity).inflate(R.layout.dialog_copy_move, null)
val sourcePath = files[0].parent.trimEnd('/') val sourcePath = files[0].parent.trimEnd('/')
var destinationPath = "" var destinationPath = ""

View file

@ -4,7 +4,6 @@ import android.os.Environment
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -19,7 +18,7 @@ class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String)
var directoriesGrid: RecyclerView var directoriesGrid: RecyclerView
init { init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_album_picker, null) as ViewGroup val view = LayoutInflater.from(activity).inflate(R.layout.dialog_album_picker, null)
directoriesGrid = view.directories_grid directoriesGrid = view.directories_grid
AlertDialog.Builder(activity) AlertDialog.Builder(activity)

View file

@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -14,9 +13,10 @@ import java.util.*
class RenameDirectoryDialog(val activity: SimpleActivity, val dir: File, val callback: (changedPaths: ArrayList<String>) -> Unit) { class RenameDirectoryDialog(val activity: SimpleActivity, val dir: File, val callback: (changedPaths: ArrayList<String>) -> Unit) {
init { init {
val view = LayoutInflater.from(activity).inflate(R.layout.rename_directory, null) as ViewGroup val view = LayoutInflater.from(activity).inflate(R.layout.rename_directory, null).apply {
view.directory_name.setText(dir.name) directory_name.setText(dir.name)
view.directory_path.text = "${activity.humanizePath(dir.parent)}/" directory_path.text = "${activity.humanizePath(dir.parent)}/"
}
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)

View file

@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -14,7 +13,7 @@ import java.io.File
class RenameFileDialog(val activity: SimpleActivity, val file: File, val callback: (newFile: File) -> Unit) { class RenameFileDialog(val activity: SimpleActivity, val file: File, val callback: (newFile: File) -> Unit) {
init { init {
val view = LayoutInflater.from(activity).inflate(R.layout.rename_file, null) as ViewGroup val view = LayoutInflater.from(activity).inflate(R.layout.rename_file, null)
val fullName = file.name val fullName = file.name
val dotAt = fullName.lastIndexOf(".") val dotAt = fullName.lastIndexOf(".")
var name = fullName var name = fullName

View file

@ -14,8 +14,7 @@ class SaveAsDialog(val activity: Activity, val path: String, val callback: (save
init { init {
var realPath = File(path).parent.trimEnd('/') var realPath = File(path).parent.trimEnd('/')
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null) val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
view.apply {
file_path.text = activity.humanizePath(realPath) file_path.text = activity.humanizePath(realPath)
val fullName = path.getFilenameFromPath() val fullName = path.getFilenameFromPath()
@ -25,7 +24,7 @@ class SaveAsDialog(val activity: Activity, val path: String, val callback: (save
if (dotAt > 0) { if (dotAt > 0) {
name = fullName.substring(0, dotAt) name = fullName.substring(0, dotAt)
val extension = fullName.substring(dotAt + 1) val extension = fullName.substring(dotAt + 1)
view.file_extension.setText(extension) file_extension.setText(extension)
} }
file_name.setText(name) file_name.setText(name)