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
e1a5bbb4
authored
Nov 10, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring in layouts
parent
b1ca71d2
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
80 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/LogInActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.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/res/layout/activity_main.xml
app/src/main/res/layout/fragment_new_word.xml
app/src/main/res/layout/notebook_sheet.xml
app/src/main/java/com/paktalin/vocabularynotebook/ActivityUtil.kt
View file @
e1a5bbb4
...
@@ -5,6 +5,7 @@ import android.os.Bundle
...
@@ -5,6 +5,7 @@ import android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v4.app.Fragment
import
android.support.v4.app.FragmentManager
import
android.support.v4.app.FragmentManager
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.View
import
android.widget.Toast
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
import
com.paktalin.vocabularynotebook.ui.fragments.ProgressFragment
...
@@ -38,3 +39,11 @@ fun fieldsNotEmpty(text1: String, text2: String, toastMessage: String, context:
...
@@ -38,3 +39,11 @@ fun fieldsNotEmpty(text1: String, text2: String, toastMessage: String, context:
fun
shortToast
(
context
:
Context
,
text
:
String
)
{
fun
shortToast
(
context
:
Context
,
text
:
String
)
{
Toast
.
makeText
(
context
,
text
,
Toast
.
LENGTH_SHORT
).
show
()
Toast
.
makeText
(
context
,
text
,
Toast
.
LENGTH_SHORT
).
show
()
}
}
fun
show
(
view
:
View
)
{
view
.
visibility
=
View
.
VISIBLE
}
fun
hide
(
view
:
View
)
{
view
.
visibility
=
View
.
INVISIBLE
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/LogInActivity.kt
View file @
e1a5bbb4
...
@@ -18,9 +18,9 @@ class LogInActivity : AppCompatActivity() {
...
@@ -18,9 +18,9 @@ class LogInActivity : AppCompatActivity() {
setContentView
(
R
.
layout
.
activity_log_in
)
setContentView
(
R
.
layout
.
activity_log_in
)
mAuth
=
FirebaseAuth
.
getInstance
()
mAuth
=
FirebaseAuth
.
getInstance
()
btnLogIn
!!
.
setOnClickListener
({
logIn
()
})
btnLogIn
!!
.
setOnClickListener
{
logIn
()
}
btnSignUp
!!
.
setOnClickListener
({
signUp
()
})
btnSignUp
!!
.
setOnClickListener
{
signUp
()
}
btnRandomUser
!!
.
setOnClickListener
({
createRandomUser
()
})
btnRandomUser
!!
.
setOnClickListener
{
createRandomUser
()
}
}
}
override
fun
onStart
()
{
override
fun
onStart
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
e1a5bbb4
...
@@ -101,7 +101,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -101,7 +101,7 @@ class MainActivity : AppCompatActivity() {
}
}
fun
addProgressBar
()
{
fun
addProgressBar
()
{
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_
main
)
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_
new_word
)
}
}
fun
removeProgressBar
()
{
fun
removeProgressBar
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
e1a5bbb4
...
@@ -12,11 +12,11 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordItem
...
@@ -12,11 +12,11 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.hide
import
com.paktalin.vocabularynotebook.removeFragment
import
com.paktalin.vocabularynotebook.removeFragment
import
com.paktalin.vocabularynotebook.shortToast
import
com.paktalin.vocabularynotebook.shortToast
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
import
kotlinx.android.synthetic.main.word_item.view.*
import
kotlinx.android.synthetic.main.word_item.view.*
class
EditWordFragment
:
WordFragment
()
{
class
EditWordFragment
:
WordFragment
()
{
...
@@ -61,7 +61,7 @@ class EditWordFragment : WordFragment() {
...
@@ -61,7 +61,7 @@ class EditWordFragment : WordFragment() {
.
collection
(
WORDS
).
document
(
wordItem
.
id
).
set
(
wordPojo
)
.
collection
(
WORDS
).
document
(
wordItem
.
id
).
set
(
wordPojo
)
.
addOnSuccessListener
{
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully updated the word"
)
Log
.
i
(
TAG
,
"Successfully updated the word"
)
hide
SubmitButton
(
)
hide
(
btnSubmit
)
mainActivity
.
removeProgressBar
()
mainActivity
.
removeProgressBar
()
wordItem
.
pojo
=
wordPojo
wordItem
.
pojo
=
wordPojo
updateRecycleView
(
wordItem
)
updateRecycleView
(
wordItem
)
...
@@ -76,7 +76,7 @@ class EditWordFragment : WordFragment() {
...
@@ -76,7 +76,7 @@ class EditWordFragment : WordFragment() {
private
fun
stop
()
{
private
fun
stop
()
{
// set onClickListener from AddWordFragment
// set onClickListener from AddWordFragment
mainActivity
.
btnSubmit
.
setOnClickListener
{
(
mainActivity
.
fragmentAdd
Word
as
AddWordFragment
).
submitWord
()
}
//mainActivity.btnSubmit.setOnClickListener { (mainActivity.fragmentNew
Word as AddWordFragment).submitWord() }
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
e1a5bbb4
...
@@ -9,9 +9,10 @@ import android.view.View
...
@@ -9,9 +9,10 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.hide
import
com.paktalin.vocabularynotebook.show
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.notebook_sheet.*
abstract
class
WordFragment
:
Fragment
()
{
abstract
class
WordFragment
:
Fragment
()
{
protected
lateinit
var
mainActivity
:
MainActivity
protected
lateinit
var
mainActivity
:
MainActivity
...
@@ -29,7 +30,8 @@ abstract class WordFragment : Fragment() {
...
@@ -29,7 +30,8 @@ abstract class WordFragment : Fragment() {
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
super
.
onActivityCreated
(
savedInstanceState
)
mainActivity
=
activity
as
MainActivity
mainActivity
=
activity
as
MainActivity
mainActivity
.
btnSubmit
.
setOnClickListener
{
submitWord
()
}
btnSubmit
.
setOnClickListener
{
submitWord
()
}
word
.
addTextChangedListener
(
textWatcher
{
word
.
addTextChangedListener
(
textWatcher
{
wordEmpty
=
word
.
text
.
isEmpty
()
})
wordEmpty
=
word
.
text
.
isEmpty
()
})
...
@@ -40,8 +42,8 @@ abstract class WordFragment : Fragment() {
...
@@ -40,8 +42,8 @@ abstract class WordFragment : Fragment() {
}
}
open
fun
updateButtons
()
{
open
fun
updateButtons
()
{
if
(!
wordEmpty
&&
!
translationEmpty
)
show
SubmitButton
(
)
if
(!
wordEmpty
&&
!
translationEmpty
)
show
(
btnSubmit
)
if
(
wordEmpty
||
translationEmpty
)
hide
SubmitButton
(
)
if
(
wordEmpty
||
translationEmpty
)
hide
(
btnSubmit
)
}
}
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
TextWatcher
{
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
TextWatcher
{
...
@@ -52,13 +54,7 @@ abstract class WordFragment : Fragment() {
...
@@ -52,13 +54,7 @@ abstract class WordFragment : Fragment() {
}
}
}
}
private
fun
showSubmitButton
()
{
private
fun
submitWord
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
VISIBLE
}
protected
fun
hideSubmitButton
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
GONE
}
fun
submitWord
()
{
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
val
word
=
word
.
text
.
toString
()
val
word
=
word
.
text
.
toString
()
...
...
app/src/main/res/layout/activity_main.xml
View file @
e1a5bbb4
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
android:background=
"#66330E"
>
android:background=
"#66330E"
>
<FrameLayout
<FrameLayout
android:id=
"@+id/container_
main
"
android:id=
"@+id/container_
new_word
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
...
...
app/src/main/res/layout/fragment_new_word.xml
View file @
e1a5bbb4
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
android:layout_height=
"match_parent"
>
<android.support.constraint.ConstraintLayout
android:id=
"@+id/container_new_word"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"@dimen/small_margin"
android:layout_marginLeft=
"@dimen/small_margin"
android:layout_marginRight=
"@dimen/small_margin"
android:layout_marginStart=
"@dimen/small_margin"
android:layout_marginTop=
"@dimen/small_margin"
android:paddingStart=
"@dimen/small_padding"
android:paddingLeft=
"@dimen/small_padding"
android:paddingEnd=
"@dimen/small_padding"
android:paddingRight=
"@dimen/small_padding"
android:paddingTop=
"@dimen/small_padding"
android:background=
"@drawable/sheet_top"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
<ImageView
android:id=
"@+id/line"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:src=
"@drawable/line"
android:src=
"@drawable/line"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageButton
android:id=
"@+id/btnClear"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_marginBottom=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:visibility=
"gone"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_close_icon"
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/word_layout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
...
@@ -58,22 +91,26 @@
...
@@ -58,22 +91,26 @@
android:textColor=
"#000F55"
android:textColor=
"#000F55"
tools:ignore=
"LabelFor"
/>
tools:ignore=
"LabelFor"
/>
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<FrameLayout
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:background=
"@color/colorPrimary"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<ImageButton
<ImageButton
android:id=
"@+id/btnClear
"
android:id=
"@+id/btnSubmit
"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:layout_gravity=
"end"
android:layout_marginEnd=
"8dp"
android:layout_margin=
"@dimen/small_margin"
android:layout_marginRight=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@android:color/transparent"
android:background=
"@android:color/transparent"
android:visibility=
"gone"
app:srcCompat=
"@drawable/ic_done_icon"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_close_icon"
tools:ignore=
"ContentDescription"
/>
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/notebook_sheet.xml
View file @
e1a5bbb4
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools
"
android:id=
"@+id/container_notebook_sheet
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<FrameLayout
android:id=
"@+id/container_main"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"@dimen/small_margin"
android:layout_marginLeft=
"@dimen/small_margin"
android:layout_marginRight=
"@dimen/small_margin"
android:layout_marginStart=
"@dimen/small_margin"
android:layout_marginTop=
"@dimen/small_margin"
android:paddingStart=
"@dimen/small_padding"
android:paddingLeft=
"@dimen/small_padding"
android:paddingEnd=
"@dimen/small_padding"
android:paddingRight=
"@dimen/small_padding"
android:paddingTop=
"@dimen/small_padding"
android:background=
"@drawable/sheet_top"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<fragment
<fragment
android:id=
"@+id/fragmentAdd
Word"
android:id=
"@+id/fragmentNew
Word"
android:name=
"com.paktalin.vocabularynotebook.ui.fragments.AddWordFragment"
android:name=
"com.paktalin.vocabularynotebook.ui.fragments.AddWordFragment"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"match_parent"
/>
</FrameLayout>
<ScrollView
<ScrollView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -42,7 +22,7 @@
...
@@ -42,7 +22,7 @@
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/container_
main
"
app:layout_constraintTop_toBottomOf=
"@+id/container_
new_word
"
app:layout_constraintVertical_bias=
"0.0"
>
app:layout_constraintVertical_bias=
"0.0"
>
<LinearLayout
<LinearLayout
...
@@ -60,23 +40,4 @@
...
@@ -60,23 +40,4 @@
</ScrollView>
</ScrollView>
<FrameLayout
android:id=
"@+id/btnSubmitLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<ImageButton
android:id=
"@+id/btnSubmit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_margin=
"@dimen/small_margin"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_done_icon"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
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