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
472ba8eb
authored
Nov 11, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only one word can be edited in a time
parent
c4e730c5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
26 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.kt
app/src/main/java/com/paktalin/vocabularynotebook/Random.java
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/VocabularyFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/LockableLayoutManager.kt → app/src/main/java/com/paktalin/vocabularynotebook/ui/views/LockableLayoutManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/LockableScrollView.kt → app/src/main/java/com/paktalin/vocabularynotebook/ui/views/LockableScrollView.kt
app/src/main/res/layout/content_main.xml
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.kt
View file @
472ba8eb
...
...
@@ -6,7 +6,9 @@ import android.support.v4.app.Fragment
import
android.support.v4.app.FragmentManager
import
android.text.TextUtils
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
import
kotlinx.android.synthetic.main.content_main.*
val
progressFragment
:
Fragment
=
ProgressFragment
()
...
...
@@ -35,6 +37,14 @@ fun fieldsNotEmpty(text1: String, text2: String, toastMessage: String, context:
return
true
}
fun
disableScrolling
(
mainActivity
:
MainActivity
)
{
mainActivity
.
scrollView
!!
.
setScrollingEnabled
(
false
)
}
fun
enableScrolling
(
mainActivity
:
MainActivity
)
{
mainActivity
.
scrollView
!!
.
setScrollingEnabled
(
true
)
}
fun
shortToast
(
context
:
Context
,
text
:
String
)
{
Toast
.
makeText
(
context
,
text
,
Toast
.
LENGTH_SHORT
).
show
()
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/Random.java
deleted
100644 → 0
View file @
c4e730c5
package
com
.
paktalin
.
vocabularynotebook
;
public
class
Random
{
}
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
472ba8eb
...
...
@@ -62,7 +62,7 @@ class VocabularyAdapter(private val displayedVocabulary: Vocabulary, private val
if
(
it
.
itemId
==
R
.
id
.
option_edit
)
{
editWord
(
v
,
displayedVocabulary
.
getAt
(
position
))
}
true
}
popup
.
show
()
if
(
EditWordFragment
.
notInEditMode
)
popup
.
show
()
}
private
fun
deleteWord
(
position
:
Int
)
{
...
...
@@ -95,15 +95,17 @@ class VocabularyAdapter(private val displayedVocabulary: Vocabulary, private val
@SuppressLint
(
"ResourceType"
)
private
fun
editWord
(
container
:
View
,
wordItem
:
WordItem
)
{
//set container id
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
container
.
id
=
View
.
generateViewId
()
}
else
container
.
id
=
18071999
// start EditWordFragment
val
arguments
=
Bundle
()
arguments
.
putSerializable
(
"wordItem"
,
wordItem
)
addFragment
(
mainActivity
.
supportFragmentManager
,
EditWordFragment
(),
container
.
id
,
arguments
)
if
(
EditWordFragment
.
notInEditMode
)
{
//set container id
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
container
.
id
=
View
.
generateViewId
()
}
else
container
.
id
=
18071999
// start EditWordFragment
val
arguments
=
Bundle
()
arguments
.
putSerializable
(
"wordItem"
,
wordItem
)
addFragment
(
mainActivity
.
supportFragmentManager
,
EditWordFragment
(),
container
.
id
,
arguments
)
}
}
inner
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
472ba8eb
...
...
@@ -7,13 +7,11 @@ import android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
import
com.paktalin.vocabularynotebook.
R
import
com.paktalin.vocabularynotebook.
*
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.removeFragment
import
com.paktalin.vocabularynotebook.shortToast
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.content_main.*
...
...
@@ -23,6 +21,7 @@ class EditWordFragment : WordFragment() {
private
lateinit
var
wordItem
:
WordItem
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
notInEditMode
=
false
mainActivity
=
activity
as
MainActivity
hidePreviousViews
(
container
)
wordItem
=
arguments
!!
[
"wordItem"
]
as
WordItem
...
...
@@ -32,6 +31,7 @@ class EditWordFragment : WordFragment() {
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
setWordItemData
()
disableScrolling
(
mainActivity
)
setFocusOnWord
()
}
...
...
@@ -39,7 +39,6 @@ class EditWordFragment : WordFragment() {
word
.
setText
(
wordItem
.
pojo
.
word
)
translation
.
setText
(
wordItem
.
pojo
.
translation
)
editable_word
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
green_highlight
))
disableScrolling
()
}
private
fun
setFocusOnWord
()
{
...
...
@@ -79,11 +78,9 @@ class EditWordFragment : WordFragment() {
private
fun
stop
()
{
// set onClickListener from AddWordFragment
mainActivity
.
btnSubmit
.
setOnClickListener
{
(
mainActivity
.
fragmentAddWord
as
AddWordFragment
).
submitWord
()
}
enableScrolling
(
mainActivity
)
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
private
fun
disableScrolling
()
{
mainActivity
.
scrollView
!!
.
setScrollingEnabled
(
false
)
notInEditMode
=
true
}
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
...
...
@@ -92,5 +89,6 @@ class EditWordFragment : WordFragment() {
companion
object
{
private
val
TAG
=
"VN/"
+
EditWordFragment
::
class
.
java
.
simpleName
var
notInEditMode
=
true
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/VocabularyFragment.kt
View file @
472ba8eb
...
...
@@ -16,6 +16,7 @@ import com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCAB
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
class
VocabularyFragment
:
Fragment
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/LockableLayoutManager.kt
→
app/src/main/java/com/paktalin/vocabularynotebook/
ui/views/
LockableLayoutManager.kt
View file @
472ba8eb
package
com.paktalin.vocabularynotebook
package
com.paktalin.vocabularynotebook
.ui.views
import
android.content.Context
import
android.support.v7.widget.LinearLayoutManager
...
...
app/src/main/java/com/paktalin/vocabularynotebook/LockableScrollView.kt
→
app/src/main/java/com/paktalin/vocabularynotebook/
ui/views/
LockableScrollView.kt
View file @
472ba8eb
package
com.paktalin.vocabularynotebook
package
com.paktalin.vocabularynotebook
.ui.views
import
android.content.Context
import
android.util.AttributeSet
...
...
app/src/main/res/layout/content_main.xml
View file @
472ba8eb
...
...
@@ -31,7 +31,7 @@
android:layout_height=
"wrap_content"
/>
</FrameLayout>
<com.paktalin.vocabularynotebook.LockableScrollView
<com.paktalin.vocabularynotebook.
ui.views.
LockableScrollView
android:id=
"@+id/scrollView"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
...
...
@@ -58,7 +58,7 @@
android:paddingBottom=
"@dimen/small_padding"
>
</LinearLayout>
</com.paktalin.vocabularynotebook.LockableScrollView>
</com.paktalin.vocabularynotebook.
ui.views.
LockableScrollView>
<LinearLayout
android:id=
"@+id/btnSubmitLayout"
...
...
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