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
9cb76de7
authored
Apr 22, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scroll to the edited position; freeze layout while editing
parent
40e11f55
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitEditedFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/views/LockableLayoutManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitEditedFragment.kt
View file @
9cb76de7
...
@@ -3,18 +3,25 @@ package com.paktalin.vocabularynotebook.ui.fragments
...
@@ -3,18 +3,25 @@ package com.paktalin.vocabularynotebook.ui.fragments
import
android.view.View
import
android.view.View
import
android.widget.EditText
import
android.widget.EditText
import
com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import
com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.removeFragment
import
com.paktalin.vocabularynotebook.utils.removeFragment
import
com.paktalin.vocabularynotebook.utils.showKeyboard
import
com.paktalin.vocabularynotebook.utils.showKeyboard
import
com.paktalin.vocabularynotebook.utils.visible
import
com.paktalin.vocabularynotebook.utils.visible
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.word_item.*
import
kotlinx.android.synthetic.main.word_item.*
class
SubmitEditedFragment
:
SubmitFragment
()
{
class
SubmitEditedFragment
:
SubmitFragment
()
{
private
lateinit
var
clickableView
:
View
private
lateinit
var
clickableView
:
View
private
lateinit
var
wordPojo
:
WordPojo
private
lateinit
var
wordPojo
:
WordPojo
private
var
recyclerViewPosition
:
Int
=
0
override
fun
init
()
{
override
fun
init
()
{
(
mainActivity
.
recyclerView
.
layoutManager
as
LockableLayoutManager
).
apply
{
scrollToPositionWithOffset
(
recyclerViewPosition
,
2
)
isScrollEnabled
=
false
}
mainActivity
.
vocabularyAdapter
.
showPopupMenu
=
false
mainActivity
.
vocabularyAdapter
.
showPopupMenu
=
false
visible
(
mainActivity
.
clickable_view
)
visible
(
mainActivity
.
clickable_view
)
gone
(
clickableView
)
gone
(
clickableView
)
...
@@ -42,14 +49,20 @@ class SubmitEditedFragment : SubmitFragment() {
...
@@ -42,14 +49,20 @@ class SubmitEditedFragment : SubmitFragment() {
gone
(
mainActivity
.
clickable_view
)
gone
(
mainActivity
.
clickable_view
)
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
mainActivity
.
vocabularyAdapter
.
showPopupMenu
=
true
mainActivity
.
vocabularyAdapter
.
showPopupMenu
=
true
(
mainActivity
.
recyclerView
.
layoutManager
as
LockableLayoutManager
).
isScrollEnabled
=
true
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
return
return
}
}
fun
setData
(
wordEt
:
EditText
,
translationEt
:
EditText
,
wordPojo
:
WordPojo
,
clickableView
:
View
)
{
fun
setData
(
wordEt
:
EditText
,
translationEt
:
EditText
,
wordPojo
:
WordPojo
,
clickableView
:
View
,
recyclerViewPosition
:
Int
)
{
this
.
wordEt
=
wordEt
this
.
wordEt
=
wordEt
this
.
translationEt
=
translationEt
this
.
translationEt
=
translationEt
this
.
wordPojo
=
wordPojo
this
.
wordPojo
=
wordPojo
this
.
clickableView
=
clickableView
this
.
clickableView
=
clickableView
this
.
recyclerViewPosition
=
recyclerViewPosition
}
}
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
9cb76de7
...
@@ -67,7 +67,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -67,7 +67,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
popup
.
setOnMenuItemClickListener
{
popup
.
setOnMenuItemClickListener
{
when
(
it
.
itemId
)
{
when
(
it
.
itemId
)
{
R
.
id
.
option_delete
->
deleteWord
(
vocabulary
.
displayedAt
(
position
),
position
)
R
.
id
.
option_delete
->
deleteWord
(
vocabulary
.
displayedAt
(
position
),
position
)
R
.
id
.
option_edit
->
editWord
(
v
,
vocabulary
.
displayedAt
(
position
)
)
R
.
id
.
option_edit
->
editWord
(
v
,
position
)
}
}
true
true
}
}
...
@@ -103,10 +103,14 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -103,10 +103,14 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}
}
@SuppressLint
(
"ResourceType"
)
@SuppressLint
(
"ResourceType"
)
private
fun
editWord
(
container
:
View
,
wordPo
jo
:
WordPojo
)
{
private
fun
editWord
(
container
:
View
,
wordPo
sition
:
Int
)
{
addSubmitFragment
(
mainActivity
.
supportFragmentManager
,
addSubmitFragment
(
mainActivity
.
supportFragmentManager
,
SubmitEditedFragment
().
apply
{
SubmitEditedFragment
().
apply
{
setData
(
container
.
word
,
container
.
translation
,
wordPojo
,
container
.
clickable_view
)
setData
(
container
.
word
,
container
.
translation
,
vocabulary
.
displayedAt
(
wordPosition
),
container
.
clickable_view
,
wordPosition
)
},
},
R
.
id
.
main_activity_container
)
R
.
id
.
main_activity_container
)
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/views/LockableLayoutManager.kt
View file @
9cb76de7
...
@@ -4,7 +4,7 @@ import android.content.Context
...
@@ -4,7 +4,7 @@ import android.content.Context
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
class
LockableLayoutManager
(
context
:
Context
)
:
LinearLayoutManager
(
context
)
{
class
LockableLayoutManager
(
context
:
Context
)
:
LinearLayoutManager
(
context
)
{
private
var
isScrollEnabled
=
true
var
isScrollEnabled
=
true
override
fun
canScrollVertically
():
Boolean
{
override
fun
canScrollVertically
():
Boolean
{
return
isScrollEnabled
&&
super
.
canScrollVertically
()
return
isScrollEnabled
&&
super
.
canScrollVertically
()
...
...
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