Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
OmGodse committed May 13, 2020
1 parent 704cc02 commit 8027b2f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ abstract class NotallyFragment : Fragment(), NoteListener {
if (note.isEmpty()){
model.handleNoteDeleted(filePath, getPayload())
val rootView = (mContext as MainActivity).binding.CoordinatorLayout
Snackbar.make(rootView, R.string.discarded_empty_note, Snackbar.LENGTH_SHORT).show()
if (note.isNote) {
Snackbar.make(rootView, R.string.discarded_empty_note, Snackbar.LENGTH_SHORT).show()
}
else Snackbar.make(rootView, R.string.discarded_empty_list, Snackbar.LENGTH_SHORT).show()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class BaseModel : ViewModel() {
setStateFromFile()
}

abstract fun saveNote() : Boolean
abstract fun saveNote()

abstract fun setStateFromFile()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MakeListModel : BaseModel() {

val items = ArrayList<ListItem>()

override fun saveNote() : Boolean {
override fun saveNote() {
val listItems = items.filter { item -> item.body.isNotBlank() }
if (file != null) {
val fileWriter = FileWriter(file)
Expand All @@ -24,9 +24,7 @@ class MakeListModel : BaseModel() {

fileWriter.write(xmlWriter.getText())
fileWriter.close()
return true
}
else return false
}

override fun setStateFromFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class NoteModel(private val app: Application) : AndroidViewModel(app) {
val note = list.find { note -> note.filePath == filePath }

if (notesHelper.moveFileToDeleted(file)){
println("Removed file from list")
list.remove(note)
liveData.value = list
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TakeNoteModel : BaseModel() {

var body = Editable.Factory.getInstance().newEditable(String())

override fun saveNote() : Boolean {
override fun saveNote() {
if (file != null) {
val fileWriter = FileWriter(file)
val xmlWriter = XMLWriter(XMLTags.Note)
Expand All @@ -33,9 +33,7 @@ class TakeNoteModel : BaseModel() {

fileWriter.write(xmlWriter.getText())
fileWriter.close()
return true
}
else return false
}

override fun setStateFromFile() {
Expand Down

0 comments on commit 8027b2f

Please sign in to comment.