properly display the albums at album picker

This commit is contained in:
tibbi 2016-11-17 13:46:24 +01:00
parent af246cdcf0
commit c525a0ebc7

View file

@ -1,20 +1,24 @@
package com.simplemobiletools.gallery.dialogs package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater import android.view.LayoutInflater
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.activities.SimpleActivity
import com.simplemobiletools.gallery.adapters.DirectoryAdapter import com.simplemobiletools.gallery.adapters.DirectoryAdapter
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Directory
import kotlinx.android.synthetic.main.dialog_album_picker.view.*
import java.util.* import java.util.*
class PickAlbumDialog(val activity: SimpleActivity, val listener: OnPickAlbumListener) : GetDirectoriesAsynctask.GetDirectoriesListener { class PickAlbumDialog(val activity: SimpleActivity, val listener: OnPickAlbumListener) : GetDirectoriesAsynctask.GetDirectoriesListener {
val context = activity.applicationContext val context = activity.applicationContext
var dialog: AlertDialog var dialog: AlertDialog
var directoriesGrid: RecyclerView
init { init {
val view = LayoutInflater.from(context).inflate(R.layout.dialog_album_picker, null) val view = LayoutInflater.from(context).inflate(R.layout.dialog_album_picker, null)
directoriesGrid = view.directories_grid
dialog = AlertDialog.Builder(activity) dialog = AlertDialog.Builder(activity)
.setTitle(context.resources.getString(R.string.select_destination)) .setTitle(context.resources.getString(R.string.select_destination))
@ -24,15 +28,15 @@ class PickAlbumDialog(val activity: SimpleActivity, val listener: OnPickAlbumLis
.create() .create()
dialog.show() dialog.show()
GetDirectoriesAsynctask(context, false, false, ArrayList<String>(), this).execute() GetDirectoriesAsynctask(context, false, false, ArrayList<String>(), this).execute()
} }
override fun gotDirectories(dirs: ArrayList<Directory>) { override fun gotDirectories(dirs: ArrayList<Directory>) {
DirectoryAdapter(activity, dirs, null) { val adapter = DirectoryAdapter(activity, dirs, null) {
listener.onSuccess(it.path) listener.onSuccess(it.path)
dialog.dismiss() dialog.dismiss()
} }
directoriesGrid.adapter = adapter
} }
interface OnPickAlbumListener { interface OnPickAlbumListener {