Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
vocabulary_notebook
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70172ad6
authored
Apr 20, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
4968f1b6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
42 deletions
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/UserPojo.java
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/UserPojo.kt
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordPojo.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/res/values/strings.xml
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/UserPojo.java
deleted
100644 → 0
View file @
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
;
}
}
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/UserPojo.kt
0 → 100644
View file @
70172ad6
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
}
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordPojo.kt
View file @
70172ad6
...
...
@@ -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
)
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyAdapter.kt
View file @
70172ad6
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
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
70172ad6
...
...
@@ -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
)
}
...
...
app/src/main/res/values/strings.xml
View file @
70172ad6
...
...
@@ -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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment