Commit 70172ad6 by Paktalin

Refactoring

parent 4968f1b6
package com.paktalin.vocabularynotebook.firestoreitems;
import com.google.firebase.firestore.DocumentReference;
import java.util.List;
public class UserPojo {
private final static String TAG = "VN/" + UserPojo.class.getSimpleName();
private String email, name;
private List<DocumentReference> vocabularies;
public UserPojo(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<DocumentReference> getVocabularies() {
return vocabularies;
}
public void setVocabularies(List<DocumentReference> vocabularies) {
this.vocabularies = vocabularies;
}
}
package com.paktalin.vocabularynotebook.firestoreitems
import com.google.firebase.firestore.DocumentReference
class UserPojo(var email: String?) {
var name: String? = null
var vocabularies: List<DocumentReference>? = null
}
......@@ -3,7 +3,12 @@ package com.paktalin.vocabularynotebook.firestoreitems
import java.io.Serializable
import java.util.Date
class WordPojo(var word: String, var translation: String, var time:Date? = null, var id: String? = null) : Serializable {
class WordPojo(var word: String,
var translation: String,
var time:Date? = null,
var id: String? = null,
var tag: String? = null)
: Serializable {
init {
if (time == null)
......
package com.paktalin.vocabularynotebook.ui
import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.support.v7.widget.PopupMenu
......@@ -13,6 +14,7 @@ import com.paktalin.vocabularynotebook.ui.fragments.EditWordFragment
import com.paktalin.vocabularynotebook.ui.activities.MainActivity
import com.paktalin.vocabularynotebook.utils.Log
import com.paktalin.vocabularynotebook.utils.addFragment
import com.paktalin.vocabularynotebook.utils.shortToast
import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary
import com.paktalin.vocabularynotebook.vocabulary.Sort
import com.paktalin.vocabularynotebook.vocabulary.VocabSet
......@@ -20,6 +22,7 @@ import com.paktalin.vocabularynotebook.vocabulary.VocabSet
class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivity: MainActivity) : RecyclerView.Adapter<ViewHolder>() {
private lateinit var recyclerView: RecyclerView
private lateinit var viewHolder: ViewHolder
var sort: Sort = Sort.BY_TIME
set(value) {
......@@ -45,9 +48,11 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
val wordItem = vocabulary.displayedAt(position)
viewHolder.init(wordItem, position) { view, p -> showPopupMenu(view, p)}
this.viewHolder = viewHolder
//todo set click listener to menu
}
private fun showPopupMenu(v: View, position: Int) {
val popup = PopupMenu(mainActivity, v)
popup.menuInflater.inflate(R.menu.word_item_menu, popup.menu)
......@@ -118,6 +123,13 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
return vocabulary.getModified()
}
fun addTag() {
shortToast(mainActivity, mainActivity.getString(R.string.toast_select_words_to_tag))
// TODO make words selectable
// TODO add complete button
// TODO collect selected words in a list
}
companion object {
private val TAG = "VN/" + VocabularyAdapter::class.java.simpleName
}
......
......@@ -49,6 +49,8 @@ class MainActivity : AppCompatActivity() {
vocabularyAdapter.sort = Sort.BY_WORD
if (item.itemId == R.id.sortByTranslation)
vocabularyAdapter.sort = Sort.BY_TRANSLATION
if (item.itemId == R.id.addTag)
vocabularyAdapter.addTag()
return super.onOptionsItemSelected(item)
}
......
......@@ -13,6 +13,7 @@
<string name="log_out">Log out</string>
<string name="sign_up">Sign Up</string>
<string name="log_in">Log In</string>
<string name="add_tag">Add tag</string>
<!--Toast messages-->
<string name="toast_empty_vocabulary">Your vocabulary is empty. Add your fist word!</string>
......@@ -23,5 +24,5 @@
<string name="toast_enter_username_password">Please, enter username and password</string>
<string name="toast_invalid_username">Please, create a username using letters a–z, numbers 0–9 and characters -_.</string>
<string name="toast_incorrect_username_password">Username or password is incorrect</string>
<string name="add_tag">Add tag</string>
<string name="toast_select_words_to_tag">Select words to tag</string>
</resources>
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