mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-16 02:48:08 -04:00
added safe call on non-null type
This commit is contained in:
parent
cfbd50eb45
commit
225cede56e
@ -82,13 +82,13 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
@JvmField @BindView(R2.id.add_note_edit_text)
|
@JvmField @BindView(R2.id.add_note_edit_text)
|
||||||
var addNoteEditText: EditText? = null // Displays the note text
|
var addNoteEditText: EditText? = null // Displays the note text
|
||||||
|
|
||||||
private var unbinder: Unbinder? = null
|
private lateinit var unbinder: Unbinder
|
||||||
private var zimFileName: String? = null
|
private var zimFileName: String? = null
|
||||||
private var zimFileTitle: String? = null
|
private var zimFileTitle: String? = null
|
||||||
private var articleTitle: String? = null
|
private var articleTitle: String? = null
|
||||||
|
|
||||||
// Corresponds to "ArticleUrl" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
// Corresponds to "ArticleUrl" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||||
private var articleNotefileName: String? = null
|
private lateinit var articleNoteFileName: String
|
||||||
private var noteFileExists = false
|
private var noteFileExists = false
|
||||||
private var noteEdited = false
|
private var noteEdited = false
|
||||||
|
|
||||||
@ -116,11 +116,11 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
zimFileName = zimReaderContainer!!.zimCanonicalPath
|
zimFileName = zimReaderContainer!!.zimCanonicalPath
|
||||||
if (zimFileName != null) { // No zim file currently opened
|
if (zimFileName != null) { // No zim file currently opened
|
||||||
zimFileTitle = zimReaderContainer!!.zimFileTitle
|
zimFileTitle = zimReaderContainer!!.zimFileTitle
|
||||||
articleTitle = (activity as WebViewProvider?)!!.getCurrentWebView()!!.title
|
articleTitle = (activity as WebViewProvider?)!!.getCurrentWebView()?.title
|
||||||
|
|
||||||
// Corresponds to "ZimFileName" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
// Corresponds to "ZimFileName" of "{External Storage}/Kiwix/Notes/ZimFileName/ArticleUrl.txt"
|
||||||
val zimNoteDirectoryName = zimNoteDirectoryName
|
val zimNoteDirectoryName = zimNoteDirectoryName
|
||||||
articleNotefileName = getArticleNotefileName()
|
articleNoteFileName = getArticleNotefileName()
|
||||||
zimNotesDirectory = "$NOTES_DIRECTORY$zimNoteDirectoryName/"
|
zimNotesDirectory = "$NOTES_DIRECTORY$zimNoteDirectoryName/"
|
||||||
} else {
|
} else {
|
||||||
onFailureToCreateAddNoteDialog()
|
onFailureToCreateAddNoteDialog()
|
||||||
@ -143,7 +143,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
unbinder = ButterKnife.bind(this, view)
|
unbinder = ButterKnife.bind(this, view)
|
||||||
toolbar!!.setTitle(R.string.note)
|
toolbar!!.setTitle(R.string.note)
|
||||||
toolbar!!.setNavigationIcon(R.drawable.ic_close_white_24dp)
|
toolbar!!.setNavigationIcon(R.drawable.ic_close_white_24dp)
|
||||||
toolbar!!.setNavigationOnClickListener { v: View? ->
|
toolbar!!.setNavigationOnClickListener {
|
||||||
exitAddNoteDialog()
|
exitAddNoteDialog()
|
||||||
closeKeyboard()
|
closeKeyboard()
|
||||||
}
|
}
|
||||||
@ -351,7 +351,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
if (folderExists) {
|
if (folderExists) {
|
||||||
val noteFile =
|
val noteFile =
|
||||||
File(notesFolder.absolutePath, "$articleNotefileName.txt")
|
File(notesFolder.absolutePath, "$articleNoteFileName.txt")
|
||||||
|
|
||||||
// Save note text-file code:
|
// Save note text-file code:
|
||||||
try {
|
try {
|
||||||
@ -377,7 +377,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
private fun deleteNote() {
|
private fun deleteNote() {
|
||||||
val notesFolder = File(zimNotesDirectory)
|
val notesFolder = File(zimNotesDirectory)
|
||||||
val noteFile =
|
val noteFile =
|
||||||
File(notesFolder.absolutePath, "$articleNotefileName.txt")
|
File(notesFolder.absolutePath, "$articleNoteFileName.txt")
|
||||||
val noteDeleted = noteFile.delete()
|
val noteDeleted = noteFile.delete()
|
||||||
if (noteDeleted) {
|
if (noteDeleted) {
|
||||||
addNoteEditText!!.text.clear()
|
addNoteEditText!!.text.clear()
|
||||||
@ -394,7 +394,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
*/
|
*/
|
||||||
private fun displayNote() {
|
private fun displayNote() {
|
||||||
|
|
||||||
val noteFile = File("$zimNotesDirectory$articleNotefileName.txt")
|
val noteFile = File("$zimNotesDirectory$articleNoteFileName.txt")
|
||||||
if (noteFile.exists()) {
|
if (noteFile.exists()) {
|
||||||
writeNote(noteFile)
|
writeNote(noteFile)
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
if (noteEdited) {
|
if (noteEdited) {
|
||||||
saveNote(addNoteEditText!!.text.toString()) // Save edited note before sharing the text file
|
saveNote(addNoteEditText!!.text.toString()) // Save edited note before sharing the text file
|
||||||
}
|
}
|
||||||
val noteFile = File("$zimNotesDirectory$articleNotefileName.txt")
|
val noteFile = File("$zimNotesDirectory$articleNoteFileName.txt")
|
||||||
var noteFileUri: Uri? = null
|
var noteFileUri: Uri? = null
|
||||||
if (noteFile.exists()) {
|
if (noteFile.exists()) {
|
||||||
noteFileUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
noteFileUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
@ -475,15 +475,13 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
val width = ViewGroup.LayoutParams.MATCH_PARENT
|
val width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
val height = ViewGroup.LayoutParams.MATCH_PARENT
|
val height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
dialog.window.setLayout(width, height)
|
dialog.window?.setLayout(width, height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
if (unbinder != null) {
|
unbinder.unbind()
|
||||||
unbinder!!.unbind()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user