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
f0081656
authored
Apr 25, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made vocabularyAdapter nullable
parent
742d65b0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
17 deletions
.idea/caches/build_file_checksums.ser
.idea/misc.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitAddedFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitEditedFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/TagFragment.kt
.idea/caches/build_file_checksums.ser
View file @
f0081656
No preview for this file type
.idea/misc.xml
View file @
f0081656
...
...
@@ -35,7 +35,7 @@
</value>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
f0081656
...
...
@@ -27,7 +27,7 @@ import kotlinx.android.synthetic.main.word_item.*
class
MainActivity
:
AppCompatActivity
()
{
var
searchView
:
SearchView
?
=
null
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
var
vocabularyAdapter
:
VocabularyAdapter
?
=
null
private
var
tagFragment
=
TagFragment
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
@@ -52,7 +52,7 @@ class MainActivity : AppCompatActivity() {
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
vocabularyAdapter
.
sort
=
when
(
item
!!
.
itemId
)
{
vocabularyAdapter
?
.
sort
=
when
(
item
!!
.
itemId
)
{
R
.
id
.
sortByWord
->
Sort
.
BY_WORD
R
.
id
.
sortByTranslation
->
Sort
.
BY_TRANSLATION
else
->
Sort
.
BY_TIME
...
...
@@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity() {
}
private
fun
refreshVocabulary
()
{
vocabularyAdapter
.
refresh
()
vocabularyAdapter
?
.
refresh
()
swipeRefresh
.
isRefreshing
=
false
}
...
...
@@ -128,28 +128,30 @@ class MainActivity : AppCompatActivity() {
}
private
fun
setUpSelectionTracker
()
{
vocabularyAdapter
.
selectionTracker
=
MySelectionTracker
().
apply
{
vocabularyAdapter
?
.
selectionTracker
=
MySelectionTracker
().
apply
{
init
(
recyclerView
)
addObserver
{
selection
->
whenSelectionChanges
(
selection
)
}
}
}
private
fun
whenSelectionChanges
(
selection
:
Selection
<
Long
>)
{
if
(!
selection
.
isEmpty
&&
vocabularyAdapter
.
state
.
notAddOrEdit
())
{
vocabularyAdapter
.
state
=
State
.
TAG
vocabularyAdapter
?.
let
{
if
(!
selection
.
isEmpty
&&
it
.
state
.
notAddOrEdit
())
{
vocabularyAdapter
?.
state
=
State
.
TAG
tagFragment
.
setSelection
(
selection
.
toList
())
addFragment
(
supportFragmentManager
,
tagFragment
,
R
.
id
.
main_activity_container
)
}
else
{
vocabularyAdapter
.
state
=
State
.
NONE
vocabularyAdapter
?
.
state
=
State
.
NONE
removeFragment
(
supportFragmentManager
,
tagFragment
)
}
}
}
override
fun
onPause
()
{
super
.
onPause
()
hideKeyboard
()
try
{
FirestoreManager
().
saveWords
(
vocabularyAdapter
.
getModifiedWords
())
vocabularyAdapter
?.
getModifiedWords
()
?.
let
{
FirestoreManager
().
saveWords
(
it
)
}
}
catch
(
ignored
:
Exception
)
{
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitAddedFragment.kt
View file @
f0081656
...
...
@@ -8,13 +8,13 @@ import kotlinx.android.synthetic.main.word_item.*
class
SubmitAddedFragment
:
SubmitFragment
()
{
override
fun
init
()
{
mainActivity
.
vocabularyAdapter
.
state
=
State
.
ADD
mainActivity
.
vocabularyAdapter
?
.
state
=
State
.
ADD
wordEt
=
mainActivity
.
word
translationEt
=
mainActivity
.
translation
}
override
fun
submit
()
{
mainActivity
.
vocabularyAdapter
.
addWord
(
WordPojo
(
wordEt
.
text
.
toString
(),
translationEt
.
text
.
toString
()))
mainActivity
.
vocabularyAdapter
?
.
addWord
(
WordPojo
(
wordEt
.
text
.
toString
(),
translationEt
.
text
.
toString
()))
wordEt
.
requestFocus
()
finish
()
return
...
...
@@ -28,7 +28,7 @@ class SubmitAddedFragment : SubmitFragment() {
override
fun
finish
()
{
wordEt
.
text
.
clear
()
translationEt
.
text
.
clear
()
mainActivity
.
vocabularyAdapter
.
state
=
State
.
NONE
mainActivity
.
vocabularyAdapter
?
.
state
=
State
.
NONE
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
return
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitEditedFragment.kt
View file @
f0081656
...
...
@@ -22,7 +22,7 @@ class SubmitEditedFragment : SubmitFragment() {
scrollToPositionWithOffset
(
recyclerViewPosition
,
2
)
isScrollEnabled
=
false
}
mainActivity
.
vocabularyAdapter
.
state
=
State
.
EDIT
mainActivity
.
vocabularyAdapter
?
.
state
=
State
.
EDIT
gone
(
clickableView
)
wordEt
.
requestFocus
()
wordEt
.
setSelection
(
wordEt
.
text
.
length
)
...
...
@@ -32,7 +32,7 @@ class SubmitEditedFragment : SubmitFragment() {
override
fun
submit
()
{
wordPojo
.
word
=
wordEt
.
text
.
toString
()
wordPojo
.
translation
=
translationEt
.
text
.
toString
()
mainActivity
.
vocabularyAdapter
.
updateWord
(
wordPojo
)
mainActivity
.
vocabularyAdapter
?
.
updateWord
(
wordPojo
)
finish
()
}
...
...
@@ -47,7 +47,7 @@ class SubmitEditedFragment : SubmitFragment() {
translationEt
.
clearFocus
()
visible
(
clickableView
)
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
mainActivity
.
vocabularyAdapter
.
state
=
State
.
NONE
mainActivity
.
vocabularyAdapter
?
.
state
=
State
.
NONE
(
mainActivity
.
recyclerView
.
layoutManager
as
LockableLayoutManager
).
isScrollEnabled
=
true
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
return
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/TagFragment.kt
View file @
f0081656
...
...
@@ -36,12 +36,12 @@ class TagFragment : Fragment() {
if
(
it
.
isBlank
())
shortToast
(
mainActivity
,
mainActivity
.
getString
(
R
.
string
.
toast_tag_cannot_be_empty
))
else
mainActivity
.
vocabularyAdapter
.
addTagToSelected
(
it
)
mainActivity
.
vocabularyAdapter
?
.
addTagToSelected
(
it
)
}
}
private
fun
cancel
()
{
mainActivity
.
vocabularyAdapter
.
selectionTracker
.
clearSelection
()
mainActivity
.
vocabularyAdapter
?.
selectionTracker
?
.
clearSelection
()
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
...
...
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