Refactor edit fragment code

This commit is contained in:
J-Jamet
2020-09-15 20:16:40 +02:00
parent 23c8735568
commit 6e99b667af

View File

@@ -53,7 +53,6 @@ import org.joda.time.Instant
class EntryEditFragment: StylishFragment() { class EntryEditFragment: StylishFragment() {
private var fontInVisibility: Boolean = false
private lateinit var entryTitleLayoutView: TextInputLayout private lateinit var entryTitleLayoutView: TextInputLayout
private lateinit var entryTitleView: EditText private lateinit var entryTitleView: EditText
@@ -73,9 +72,11 @@ class EntryEditFragment: StylishFragment() {
private lateinit var attachmentsAdapter: EntryAttachmentsItemsAdapter private lateinit var attachmentsAdapter: EntryAttachmentsItemsAdapter
private var fontInVisibility: Boolean = false
private var iconColor: Int = 0 private var iconColor: Int = 0
private var expiresInstant: DateInstant = DateInstant(Instant.now().plus(Duration.standardDays(30)).toDate()) private var expiresInstant: DateInstant = DateInstant(Instant.now().plus(Duration.standardDays(30)).toDate())
var drawFactory: IconDrawableFactory? = null
var setOnDateClickListener: View.OnClickListener? = null var setOnDateClickListener: View.OnClickListener? = null
var setOnPasswordGeneratorClickListener: View.OnClickListener? = null var setOnPasswordGeneratorClickListener: View.OnClickListener? = null
var setOnIconViewClickListener: View.OnClickListener? = null var setOnIconViewClickListener: View.OnClickListener? = null
@@ -180,38 +181,34 @@ class EntryEditFragment: StylishFragment() {
} }
private fun populateViewsWithEntry() { private fun populateViewsWithEntry() {
try { // Set info in view
// Set info in view icon = mEntryInfo.icon
icon = mEntryInfo.icon title = mEntryInfo.title
title = mEntryInfo.title username = mEntryInfo.username
username = mEntryInfo.username url = mEntryInfo.url
url = mEntryInfo.url password = mEntryInfo.password
password = mEntryInfo.password expires = mEntryInfo.expires
expires = mEntryInfo.expires expiryTime = mEntryInfo.expiryTime
expiryTime = mEntryInfo.expiryTime notes = mEntryInfo.notes
notes = mEntryInfo.notes assignExtraFields(mEntryInfo.customFields) { fields ->
assignExtraFields(mEntryInfo.customFields) { fields -> setOnEditCustomField?.invoke(fields)
setOnEditCustomField?.invoke(fields) }
} assignAttachments(mEntryInfo.attachments, StreamDirection.UPLOAD) { attachment ->
assignAttachments(mEntryInfo.attachments, StreamDirection.UPLOAD) { attachment -> setOnRemoveAttachment?.invoke(attachment)
setOnRemoveAttachment?.invoke(attachment) }
}
} catch (e: Exception) {}
} }
private fun populateEntryWithViews() { private fun populateEntryWithViews() {
try { // Icon already populate
// Icon already populate mEntryInfo.title = title
mEntryInfo.title = title mEntryInfo.username = username
mEntryInfo.username = username mEntryInfo.url = url
mEntryInfo.url = url mEntryInfo.password = password
mEntryInfo.password = password mEntryInfo.expires = expires
mEntryInfo.expires = expires mEntryInfo.expiryTime = expiryTime
mEntryInfo.expiryTime = expiryTime mEntryInfo.notes = notes
mEntryInfo.notes = notes mEntryInfo.customFields = getExtraFields()
mEntryInfo.customFields = getExtraFields() mEntryInfo.attachments = getAttachments()
mEntryInfo.attachments = getAttachments()
} catch (e: Exception) {}
} }
var title: String var title: String
@@ -224,8 +221,6 @@ class EntryEditFragment: StylishFragment() {
entryTitleView.applyFontVisibility() entryTitleView.applyFontVisibility()
} }
var drawFactory: IconDrawableFactory? = null
var icon: IconImage var icon: IconImage
get() { get() {
return mEntryInfo.icon return mEntryInfo.icon