mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 11:32:00 +00:00
use default constructor for fragment
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parent
b70b6dfba9
commit
1881676538
@ -2976,11 +2976,13 @@ class ChatActivity :
|
||||
filenamesWithLineBreaks.append(filename).append("\n")
|
||||
}
|
||||
|
||||
val newFragment: DialogFragment = FileAttachmentPreviewFragment.newInstance(
|
||||
val newFragment = FileAttachmentPreviewFragment.newInstance(
|
||||
filenamesWithLineBreaks.toString(),
|
||||
filesToUpload,
|
||||
this::uploadFiles
|
||||
filesToUpload
|
||||
)
|
||||
newFragment.setListener { files, caption ->
|
||||
uploadFiles(files, caption)
|
||||
}
|
||||
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
||||
} catch (e: IllegalStateException) {
|
||||
context.resources?.getString(R.string.nc_upload_failed)?.let {
|
||||
@ -3050,11 +3052,11 @@ class ChatActivity :
|
||||
filenamesWithLineBreaks.append(filename).append("\n")
|
||||
}
|
||||
|
||||
val newFragment: DialogFragment = FileAttachmentPreviewFragment.newInstance(
|
||||
val newFragment = FileAttachmentPreviewFragment.newInstance(
|
||||
filenamesWithLineBreaks.toString(),
|
||||
filesToUpload,
|
||||
this::uploadFiles
|
||||
filesToUpload
|
||||
)
|
||||
newFragment.setListener { files, caption -> uploadFiles(files, caption) }
|
||||
newFragment.show(supportFragmentManager, FileAttachmentPreviewFragment.TAG)
|
||||
} else {
|
||||
UploadAndShareFilesWorker.requestStoragePermission(this)
|
||||
@ -4383,7 +4385,7 @@ class ChatActivity :
|
||||
val lon = data["longitude"]!!
|
||||
metaData =
|
||||
"{\"type\":\"geo-location\",\"id\":\"geo:$lat,$lon\",\"latitude\":\"$lat\"," +
|
||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||
"\"longitude\":\"$lon\",\"name\":\"$name\"}"
|
||||
}
|
||||
|
||||
when (type) {
|
||||
|
@ -36,14 +36,10 @@ import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class FileAttachmentPreviewFragment(
|
||||
filenames: String,
|
||||
filesToUpload: MutableList<String>,
|
||||
functionToCall: (files: MutableList<String>, caption: String) -> Unit
|
||||
) : DialogFragment() {
|
||||
private val files = filenames
|
||||
private val filesList = filesToUpload
|
||||
private val uploadFiles = functionToCall
|
||||
class FileAttachmentPreviewFragment : DialogFragment() {
|
||||
private lateinit var files: String
|
||||
private lateinit var filesList: ArrayList<String>
|
||||
private var uploadFiles: (files: MutableList<String>, caption: String) -> Unit = { _, _ -> }
|
||||
lateinit var binding: DialogFileAttachmentPreviewBinding
|
||||
|
||||
@Inject
|
||||
@ -51,7 +47,18 @@ class FileAttachmentPreviewFragment(
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
fun setListener(uploadFiles: (files: MutableList<String>, caption: String) -> Unit) {
|
||||
this.uploadFiles = uploadFiles
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
arguments?.let {
|
||||
files = it.getString(FILE_NAMES_ARG, "")
|
||||
filesList = it.getStringArrayList(FILES_TO_UPLOAD_ARG)!!
|
||||
}
|
||||
|
||||
binding = DialogFileAttachmentPreviewBinding.inflate(LayoutInflater.from(context))
|
||||
return MaterialAlertDialogBuilder(requireContext()).setView(binding.root).create()
|
||||
}
|
||||
@ -88,12 +95,23 @@ class FileAttachmentPreviewFragment(
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val FILE_NAMES_ARG = "FILE_NAMES_ARG"
|
||||
private const val FILES_TO_UPLOAD_ARG = "FILES_TO_UPLOAD_ARG"
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(
|
||||
filenames: String,
|
||||
filesToUpload: MutableList<String>,
|
||||
functionToCall: (files: MutableList<String>, caption: String) -> Unit
|
||||
) = FileAttachmentPreviewFragment(filenames, filesToUpload, functionToCall)
|
||||
): FileAttachmentPreviewFragment {
|
||||
val fileAttachmentFragment = FileAttachmentPreviewFragment()
|
||||
val args = Bundle()
|
||||
args.putString(FILE_NAMES_ARG, filenames)
|
||||
args.putStringArrayList(FILES_TO_UPLOAD_ARG, ArrayList(filesToUpload))
|
||||
fileAttachmentFragment.arguments = args
|
||||
return fileAttachmentFragment
|
||||
}
|
||||
|
||||
val TAG: String = FilterConversationFragment::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user