Commit 2027d343 by Paktalin

package refactoring

parent 38842264
Showing with 36 additions and 25 deletions
package com.paktalin.vocabularynotebook.firestoreitems
package com.paktalin.vocabularynotebook.entities
import com.google.firebase.firestore.DocumentReference
......
package com.paktalin.vocabularynotebook.firestoreitems
package com.paktalin.vocabularynotebook.entities
class VocabularyPojo(var title:String?) {
init {
......
package com.paktalin.vocabularynotebook.firestoreitems
package com.paktalin.vocabularynotebook.entities
import java.io.Serializable
import java.util.*
......
package com.paktalin.vocabularynotebook.utils
package com.paktalin.vocabularynotebook.firestore
import android.content.Context
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.firestore.*
import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import com.paktalin.vocabularynotebook.firestoreitems.UserPojo
import com.paktalin.vocabularynotebook.firestoreitems.VocabularyPojo
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.UserPojo
import com.paktalin.vocabularynotebook.entities.VocabularyPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.ui.activities.LogInActivity
import com.paktalin.vocabularynotebook.utils.Log
import com.paktalin.vocabularynotebook.utils.saveVocabularyId
import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary.Label
import java.util.*
......
package com.paktalin.vocabularynotebook.utils
package com.paktalin.vocabularynotebook.firestore
import android.util.Patterns
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.ui.activities.LogInActivity
import com.paktalin.vocabularynotebook.utils.Log
import com.paktalin.vocabularynotebook.utils.removeProgressBar
import com.paktalin.vocabularynotebook.utils.shortToast
private const val TAG = "VN/UserManager"
private var mAuth: FirebaseAuth? = FirebaseAuth.getInstance()
......@@ -12,7 +15,7 @@ private var mAuth: FirebaseAuth? = FirebaseAuth.getInstance()
fun mDeleteUser(user: FirebaseUser) {
user.delete()
.addOnSuccessListener { Log.i(TAG, "UserPojo was successfully deleted") }
.addOnFailureListener { Log.i(TAG, "mDeleteUser:failure", it.cause)}
.addOnFailureListener { Log.i(TAG, "mDeleteUser:failure", it.cause) }
}
fun mLogIn(onComplete: () -> Unit, onSuccess: () -> Unit, onFailure: () -> Unit,
......
package com.paktalin.vocabularynotebook.ui.activities
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.paktalin.vocabularynotebook.*
import androidx.appcompat.app.AppCompatActivity
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.firestore.mLogIn
import com.paktalin.vocabularynotebook.firestore.mSignUp
import com.paktalin.vocabularynotebook.firestore.mUserLoggedIn
import com.paktalin.vocabularynotebook.utils.*
import kotlinx.android.synthetic.main.activity_log_in.*
......
......@@ -11,6 +11,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView
import androidx.recyclerview.selection.Selection
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.firestore.FirestoreManager
import com.paktalin.vocabularynotebook.firestore.mLogOut
import com.paktalin.vocabularynotebook.ui.fragments.SubmitAddedFragment
import com.paktalin.vocabularynotebook.ui.fragments.TagFragment
import com.paktalin.vocabularynotebook.ui.recycler_view.State
......@@ -153,7 +155,7 @@ class MainActivity : AppCompatActivity() {
super.onPause()
hideKeyboard()
try {
vocabularyAdapter?.getModifiedWords()?.let { FirestoreManager().saveWords(it) }
FirestoreManager().saveWords(vocabularyAdapter?.getModifiedWords()!!)
} catch (ignored: Exception) {
}
}
......
package com.paktalin.vocabularynotebook.ui.fragments
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.ui.recycler_view.State
import com.paktalin.vocabularynotebook.utils.removeFragment
import kotlinx.android.synthetic.main.word_item.*
......
......@@ -2,7 +2,7 @@ package com.paktalin.vocabularynotebook.ui.fragments
import android.view.View
import android.widget.EditText
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.ui.recycler_view.State
import com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import com.paktalin.vocabularynotebook.utils.gone
......
......@@ -4,7 +4,7 @@ import android.view.View
import android.widget.EditText
import androidx.recyclerview.selection.ItemDetailsLookup
import androidx.recyclerview.widget.RecyclerView
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.utils.visible
import kotlinx.android.synthetic.main.word_item.view.*
......
......@@ -6,13 +6,14 @@ import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu
import androidx.recyclerview.widget.RecyclerView
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.ui.activities.MainActivity
import com.paktalin.vocabularynotebook.ui.fragments.SubmitEditedFragment
import com.paktalin.vocabularynotebook.ui.recycler_view.selection_tracker.MySelectionTracker
import com.paktalin.vocabularynotebook.utils.addSubmitFragment
import com.paktalin.vocabularynotebook.utils.gone
import com.paktalin.vocabularynotebook.utils.visible
import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary
import com.paktalin.vocabularynotebook.vocabulary.Sort
import com.paktalin.vocabularynotebook.vocabulary.VocabSet
import kotlinx.android.synthetic.main.word_item.*
......@@ -89,7 +90,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
notifyDataSetChanged()
}
fun getModifiedWords(): MutableMap<WordPojo, Boolean> {
fun getModifiedWords(): MutableMap<ModifiedVocabulary.Label, MutableList<WordPojo>> {
return vocabulary.getModified()
}
......
......@@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.firestore.isEmail
import com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
import com.paktalin.vocabularynotebook.ui.fragments.SubmitFragment
import org.apache.commons.lang3.StringUtils
......
package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
open class BasicVocabulary(var wordList: MutableList<WordPojo>): Vocabulary {
......
package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
class DisplayedVocabulary(wordList: MutableList<WordPojo>): BasicVocabulary(wordList) {
......
package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.utils.FirestoreManager
import com.paktalin.vocabularynotebook.entities.WordPojo
import com.paktalin.vocabularynotebook.firestore.FirestoreManager
class ModifiedVocabulary : Vocabulary {
......
......@@ -4,7 +4,7 @@ import android.graphics.Color
import com.google.firebase.Timestamp
import com.google.firebase.firestore.QueryDocumentSnapshot
import com.google.firebase.firestore.QuerySnapshot
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
import java.util.*
class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
......@@ -82,7 +82,7 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
return displayedVocabulary.size()
}
fun getModified(): MutableMap<WordPojo, Boolean> {
fun getModified(): MutableMap<ModifiedVocabulary.Label, MutableList<WordPojo>> {
return modifiedVocabulary.get()
}
......
package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.entities.WordPojo
interface Vocabulary {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment