diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt index fb8ed7c0..1010090b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt @@ -6,11 +6,11 @@ import android.support.v4.app.DialogFragment import android.support.v7.app.AlertDialog import android.text.format.DateFormat import android.view.View -import android.widget.TextView import com.simplemobiletools.filemanager.Config import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.extensions.formatSize import com.simplemobiletools.filepicker.models.FileDirItem +import kotlinx.android.synthetic.main.item_properties.view.* import java.io.File import java.util.* @@ -28,33 +28,34 @@ class PropertiesDialog : DialogFragment() { } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - mShowHidden = Config.newInstance(context).showHidden val title = if (mItem.isDirectory) R.string.directory_properties else R.string.file_properties - val infoView = activity.layoutInflater.inflate(R.layout.item_properties, null) - (infoView.findViewById(R.id.properties_name) as TextView).text = mItem.name - (infoView.findViewById(R.id.properties_path) as TextView).text = mItem.path - (infoView.findViewById(R.id.properties_size) as TextView).text = getItemSize() - if (mItem.isDirectory) { - infoView.findViewById(R.id.properties_files_count_label).visibility = View.VISIBLE - infoView.findViewById(R.id.properties_files_count).visibility = View.VISIBLE - (infoView.findViewById(R.id.properties_files_count) as TextView).text = mFilesCnt.toString() + infoView.apply { + properties_name.text = mItem.name + properties_path.text = mItem.path + properties_size.text = getItemSize() + + if (mItem.isDirectory) { + properties_files_count_label.visibility = View.VISIBLE + properties_files_count.visibility = View.VISIBLE + properties_files_count.text = mFilesCnt.toString() + } + + val file = File(mItem.path) + properties_last_modified.text = formatLastModified(file.lastModified()) } - val file = File(mItem.path) - (infoView.findViewById(R.id.properties_last_modified) as TextView).text = formatLastModified(file.lastModified()) - - val builder = AlertDialog.Builder(context) - builder.setTitle(resources.getString(title)) - builder.setView(infoView) - builder.setPositiveButton(R.string.ok, null) - - return builder.create() + return AlertDialog.Builder(context) + .setTitle(resources.getString(title)) + .setView(infoView) + .setPositiveButton(R.string.ok, null) + .create() } fun getItemSize(): String { if (mItem.isDirectory) { + mShowHidden = Config.newInstance(context).showHidden return getDirectorySize(File(mItem.path)).formatSize() }