use the proper request code at returning result from SelectFolderDialog

This commit is contained in:
tibbi 2016-10-12 23:28:27 +02:00
parent af8b43a6f6
commit a3277190e5
2 changed files with 4 additions and 3 deletions

View File

@ -18,7 +18,6 @@ import java.util.*
import kotlin.comparisons.compareBy
class SelectFolderDialog : DialogFragment(), Breadcrumbs.BreadcrumbsListener {
val SELECT_FOLDER_REQUEST = 1
val SELECT_FOLDER_PATH = "path"
companion object {
@ -37,9 +36,11 @@ class SelectFolderDialog : DialogFragment(), Breadcrumbs.BreadcrumbsListener {
}
lateinit var dialog: View
var requestCode = 0
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
dialog = activity.layoutInflater.inflate(R.layout.smtfp_directory_picker, null)
requestCode = targetRequestCode
updateItems()
setupBreadcrumbs()
@ -78,7 +79,7 @@ class SelectFolderDialog : DialogFragment(), Breadcrumbs.BreadcrumbsListener {
private fun sendResult() {
val intent = Intent()
intent.putExtra(SELECT_FOLDER_PATH, mPath)
targetFragment.onActivityResult(SELECT_FOLDER_REQUEST, Activity.RESULT_OK, intent)
targetFragment.onActivityResult(requestCode, Activity.RESULT_OK, intent)
dismiss()
}

View File

@ -128,7 +128,7 @@ class Breadcrumbs(context: Context, attrs: AttributeSet) : LinearLayout(context,
}
}
fun addBreadcrumb(item: FileDirItem, addPrefix: Boolean) {
private fun addBreadcrumb(item: FileDirItem, addPrefix: Boolean) {
val view = mInflater!!.inflate(R.layout.smtfp_breadcrumb_item, null, false)
var textToAdd = item.name
if (addPrefix)