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
50a4eced
authored
Apr 21, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added MyItemKeyProvider and moved submit layout to a separate xml file
parent
daa4eff2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
50 deletions
.idea/misc.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/MyItemKeyProvider.kt
app/src/main/res/layout/content_main.xml
app/src/main/res/layout/submit.xml
app/src/main/res/layout/tag.xml
app/src/main/res/values/strings.xml
.idea/misc.xml
View file @
50a4eced
...
...
@@ -35,7 +35,7 @@
</value>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
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 @
50a4eced
...
...
@@ -11,10 +11,10 @@ import androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.widget.SearchView
import
androidx.recyclerview.selection.SelectionPredicates
import
androidx.recyclerview.selection.SelectionTracker
import
androidx.recyclerview.selection.StableIdKeyProvider
import
androidx.recyclerview.selection.StorageStrategy
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.ui.recycler_view.MyItemDetailsLookup
import
com.paktalin.vocabularynotebook.ui.recycler_view.MyItemKeyProvider
import
com.paktalin.vocabularynotebook.ui.recycler_view.VocabularyAdapter
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import
com.paktalin.vocabularynotebook.utils.*
...
...
@@ -33,6 +33,7 @@ class MainActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
FirestoreManager
.
vocabularyId
=
getSavedVocabularyIdFromPreferences
(
this
@MainActivity
)
recyclerView
.
adapter
=
VocabularyAdapter
(
VocabSet
(
mutableListOf
()),
this
@MainActivity
)
setUpSwipeRefresh
()
setUpNavigationView
()
hideKeyboard
()
...
...
@@ -85,6 +86,7 @@ class MainActivity : AppCompatActivity() {
}
private
fun
setUpVocabularyAdapter
()
{
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
...
...
@@ -123,7 +125,7 @@ class MainActivity : AppCompatActivity() {
tracker
=
SelectionTracker
.
Builder
<
Long
>(
"mySelection"
,
recyclerView
,
StableId
KeyProvider
(
recyclerView
),
MyItem
KeyProvider
(
recyclerView
),
MyItemDetailsLookup
(
recyclerView
),
StorageStrategy
.
createLongStorage
()
).
withSelectionPredicate
(
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
View file @
50a4eced
...
...
@@ -4,9 +4,11 @@ import android.os.Bundle
import
android.text.Editable
import
android.text.TextWatcher
import
com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import
com.paktalin.vocabularynotebook.utils.*
import
kotlinx.android.synthetic.main.content_main.*
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.invisible
import
com.paktalin.vocabularynotebook.utils.visible
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.submit.*
class
AddWordFragment
:
WordFragment
()
{
private
var
wordEmpty
:
Boolean
=
true
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
50a4eced
...
...
@@ -13,6 +13,7 @@ import com.paktalin.vocabularynotebook.utils.removeFragment
import
com.paktalin.vocabularynotebook.utils.visible
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.submit.*
import
kotlinx.android.synthetic.main.word_item.view.*
class
EditWordFragment
:
WordFragment
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
50a4eced
package
com.paktalin.vocabularynotebook.ui.fragments
import
android.os.Bundle
import
androidx.fragment.app.Fragment
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.fragment.app.Fragment
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
import
com.paktalin.vocabularynotebook.utils.gone
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.
content_main
.*
import
kotlinx.android.synthetic.main.
submit
.*
abstract
class
WordFragment
:
Fragment
()
{
protected
lateinit
var
mainActivity
:
MainActivity
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/MyItemKeyProvider.kt
0 → 100644
View file @
50a4eced
package
com.paktalin.vocabularynotebook.ui.recycler_view
import
androidx.recyclerview.selection.ItemKeyProvider
import
androidx.recyclerview.widget.RecyclerView
class
MyItemKeyProvider
(
private
val
recyclerView
:
RecyclerView
)
:
ItemKeyProvider
<
Long
>(
ItemKeyProvider
.
SCOPE_MAPPED
)
{
override
fun
getKey
(
position
:
Int
):
Long
?
{
return
recyclerView
.
adapter
?.
getItemId
(
position
)
}
override
fun
getPosition
(
key
:
Long
):
Int
{
val
viewHolder
=
recyclerView
.
findViewHolderForItemId
(
key
)
return
viewHolder
?.
layoutPosition
?:
RecyclerView
.
NO_POSITION
}
}
\ No newline at end of file
app/src/main/res/layout/content_main.xml
View file @
50a4eced
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
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:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -43,39 +41,6 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
<LinearLayout
android:id=
"@+id/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:orientation=
"horizontal"
android:visibility=
"gone"
android:layout_alignParentBottom=
"true"
>
<ImageButton
android:id=
"@+id/btnCancel"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_close_brown"
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=
"center_vertical"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_brown"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<include
layout=
"@layout/submit"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/submit.xml
0 → 100644
View file @
50a4eced
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:background=
"@color/colorPrimary"
android:orientation=
"horizontal"
android:visibility=
"gone"
>
<ImageButton
android:id=
"@+id/btnCancel"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_close_brown"
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=
"center_vertical"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_brown"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/tag.xml
View file @
50a4eced
...
...
@@ -6,18 +6,17 @@
android:background=
"@color/colorPrimary"
android:orientation=
"vertical"
>
<
Spinner
android:id=
"@+id/
spinner2
"
android:layout_width=
"
match_parent
"
<
AutoCompleteTextView
android:id=
"@+id/
brand
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
android:hint=
"@string/enter_tag"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
50a4eced
...
...
@@ -22,4 +22,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_select_words_to_tag"
>
Select words to tag
</string>
<string
name=
"enter_tag"
>
Enter 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