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
c4e730c5
authored
Nov 11, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Word is fixed in edit mode
parent
082f67fb
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
11 deletions
app/src/main/java/com/paktalin/vocabularynotebook/LockableLayoutManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/LockableScrollView.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/res/layout/content_main.xml
app/src/main/res/layout/fragment_editable_word.xml
app/src/main/res/layout/word_item.xml
app/src/main/res/values/colors.xml
app/src/main/java/com/paktalin/vocabularynotebook/LockableLayoutManager.kt
0 → 100644
View file @
c4e730c5
package
com.paktalin.vocabularynotebook
import
android.content.Context
import
android.support.v7.widget.LinearLayoutManager
class
LockableLayoutManager
(
context
:
Context
)
:
LinearLayoutManager
(
context
)
{
private
var
isScrollEnabled
=
true
fun
setScrollingEnabled
(
flag
:
Boolean
)
{
this
.
isScrollEnabled
=
flag
}
override
fun
canScrollVertically
():
Boolean
{
return
isScrollEnabled
&&
super
.
canScrollVertically
()
}
}
app/src/main/java/com/paktalin/vocabularynotebook/LockableScrollView.kt
0 → 100644
View file @
c4e730c5
package
com.paktalin.vocabularynotebook
import
android.content.Context
import
android.util.AttributeSet
import
android.view.MotionEvent
import
android.widget.ScrollView
internal
class
LockableScrollView
:
ScrollView
{
private
var
isScrollable
=
true
constructor
(
context
:
Context
)
:
super
(
context
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
)
:
super
(
context
,
attrs
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
,
defStyleAttr
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
)
fun
setScrollingEnabled
(
enabled
:
Boolean
)
{
isScrollable
=
enabled
}
override
fun
onTouchEvent
(
ev
:
MotionEvent
):
Boolean
{
return
when
(
ev
.
action
)
{
MotionEvent
.
ACTION_DOWN
->
// if we can scroll pass the event to the superclass
isScrollable
&&
super
.
onTouchEvent
(
ev
)
else
->
super
.
onTouchEvent
(
ev
)
}
}
override
fun
onInterceptTouchEvent
(
ev
:
MotionEvent
):
Boolean
{
// Don't do anything with intercepted touch events if
// we are not scrollable
return
isScrollable
&&
super
.
onInterceptTouchEvent
(
ev
)
}
}
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
c4e730c5
...
...
@@ -38,6 +38,8 @@ class EditWordFragment : WordFragment() {
private
fun
setWordItemData
()
{
word
.
setText
(
wordItem
.
pojo
.
word
)
translation
.
setText
(
wordItem
.
pojo
.
translation
)
editable_word
.
setBackgroundColor
(
resources
.
getColor
(
R
.
color
.
green_highlight
))
disableScrolling
()
}
private
fun
setFocusOnWord
()
{
...
...
@@ -80,6 +82,10 @@ class EditWordFragment : WordFragment() {
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
private
fun
disableScrolling
()
{
mainActivity
.
scrollView
!!
.
setScrollingEnabled
(
false
)
}
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
mainActivity
.
vocabularyFragment
.
updateWord
(
wordItem
)
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/VocabularyFragment.kt
View file @
c4e730c5
...
...
@@ -2,7 +2,6 @@ package com.paktalin.vocabularynotebook.ui.fragments
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.widget.LinearLayoutManager
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
...
...
@@ -41,7 +40,8 @@ class VocabularyFragment : Fragment() {
private
fun
setEmptyAdapter
()
{
val
emptyList
:
MutableList
<
WordItem
>
=
mutableListOf
()
recyclerView
.
adapter
=
VocabularyAdapter
(
Vocabulary
(
emptyList
),
mainActivity
)
val
mLayoutManager
=
LinearLayoutManager
(
mainActivity
)
val
mLayoutManager
=
LockableLayoutManager
(
mainActivity
)
mLayoutManager
.
setScrollingEnabled
(
false
)
recyclerView
.
layoutManager
=
mLayoutManager
}
...
...
app/src/main/res/layout/content_main.xml
View file @
c4e730c5
...
...
@@ -31,7 +31,8 @@
android:layout_height=
"wrap_content"
/>
</FrameLayout>
<ScrollView
<com.paktalin.vocabularynotebook.LockableScrollView
android:id=
"@+id/scrollView"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginEnd=
"@dimen/small_margin"
...
...
@@ -39,11 +40,10 @@
android:layout_marginRight=
"@dimen/small_margin"
android:layout_marginStart=
"@dimen/small_margin"
android:scrollbars=
"vertical"
app:layout_constraintBottom_to
BottomOf=
"paren
t"
app:layout_constraintBottom_to
TopOf=
"@+id/btnSubmitLayou
t"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/container_main"
app:layout_constraintVertical_bias=
"0.0"
>
app:layout_constraintTop_toBottomOf=
"@+id/container_main"
>
<LinearLayout
android:id=
"@+id/container_vocabulary"
...
...
@@ -58,25 +58,40 @@
android:paddingBottom=
"@dimen/small_padding"
>
</LinearLayout>
</ScrollView>
</
com.paktalin.vocabularynotebook.Lockable
ScrollView>
<
Frame
Layout
<
Linear
Layout
android:id=
"@+id/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:visibility=
"gone"
android:orientation=
"horizontal"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<ImageButton
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:srcCompat=
"@drawable/ic_close_icon"
android:background=
"@android:color/transparent"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/small_margin"
tools:ignore=
"ContentDescription"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
<ImageButton
android:id=
"@+id/btnSubmit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"
end
"
android:layout_gravity=
"
center_vertical
"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_icon"
tools:ignore=
"ContentDescription"
/>
</
Frame
Layout>
</
Linear
Layout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_editable_word.xml
View file @
c4e730c5
...
...
@@ -21,6 +21,7 @@
tools:ignore=
"ContentDescription"
/>
<LinearLayout
android:id=
"@+id/editable_word"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
...
...
app/src/main/res/layout/word_item.xml
View file @
c4e730c5
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/word_item_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
...
...
app/src/main/res/values/colors.xml
View file @
c4e730c5
...
...
@@ -4,4 +4,5 @@
<color
name=
"colorPrimaryDark"
>
#303F9F
</color>
<color
name=
"colorAccent"
>
#FF4081
</color>
<color
name=
"sheet_color"
>
#FAFAFA
</color>
<color
name=
"green_highlight"
>
#69B578
</color>
</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