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
86480fca
authored
Sep 09, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keyboard is hidden after adding a new word
parent
70e56d3c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
app/src/main/res/layout/activity_main.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
View file @
86480fca
...
@@ -11,6 +11,10 @@ import com.google.firebase.firestore.FirebaseFirestore
...
@@ -11,6 +11,10 @@ import com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
import
android.view.WindowManager
import
android.view.WindowManager
import
android.app.Activity
import
android.view.View
import
android.view.inputmethod.InputMethodManager
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
@@ -60,6 +64,15 @@ class MainActivity : AppCompatActivity() {
...
@@ -60,6 +64,15 @@ class MainActivity : AppCompatActivity() {
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_HIDDEN
)
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_HIDDEN
)
}
}
fun
hideKeyboard
(
activity
:
Activity
)
{
val
imm
=
activity
.
getSystemService
(
Activity
.
INPUT_METHOD_SERVICE
)
as
InputMethodManager
var
view
=
activity
.
currentFocus
if
(
view
==
null
)
{
view
=
View
(
activity
)
}
imm
.
hideSoftInputFromWindow
(
view
.
windowToken
,
0
)
}
companion
object
{
companion
object
{
private
val
TAG
=
"VN/"
+
MainActivity
::
class
.
simpleName
private
val
TAG
=
"VN/"
+
MainActivity
::
class
.
simpleName
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
View file @
86480fca
...
@@ -8,6 +8,7 @@ import android.util.Log
...
@@ -8,6 +8,7 @@ import android.util.Log
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.ImageButton
import
android.widget.ImageButton
import
android.widget.Toast
import
android.widget.Toast
import
com.google.firebase.firestore.FirebaseFirestore
import
com.google.firebase.firestore.FirebaseFirestore
...
@@ -62,17 +63,18 @@ class NewWordFragment : Fragment() {
...
@@ -62,17 +63,18 @@ class NewWordFragment : Fragment() {
}
}
private
fun
showAddWordButton
()
{
private
fun
showAddWordButton
()
{
activity
!!
.
findViewById
<
ImageButton
>(
R
.
id
.
btnAddWord
).
visibility
=
View
.
VISIBLE
}
activity
!!
.
findViewById
<
FrameLayout
>(
R
.
id
.
btnAddWordLayout
).
visibility
=
View
.
VISIBLE
}
private
fun
hideAddWordButton
()
{
private
fun
hideAddWordButton
()
{
activity
!!
.
findViewById
<
ImageButton
>(
R
.
id
.
btnAddWord
).
visibility
=
View
.
GONE
}
activity
!!
.
findViewById
<
FrameLayout
>(
R
.
id
.
btnAddWordLayout
).
visibility
=
View
.
GONE
}
private
fun
hideClearButton
()
{
btnClear
.
visibility
=
View
.
GONE
}
private
fun
hideClearButton
()
{
btnClear
.
visibility
=
View
.
GONE
}
private
fun
showClearButton
()
{
btnClear
.
visibility
=
View
.
VISIBLE
}
private
fun
showClearButton
()
{
btnClear
.
visibility
=
View
.
VISIBLE
}
private
fun
addWord
()
{
private
fun
addWord
()
{
//todo get word data from edit texts and save it
(
activity
as
MainActivity
).
hideKeyboard
(
activity
as
MainActivity
)
val
word
=
etWord
.
text
.
toString
()
val
word
=
etWord
.
text
.
toString
()
val
translation
=
etTranslation
.
text
.
toString
()
val
translation
=
etTranslation
.
text
.
toString
()
val
vocabularyId
=
(
activity
as
MainActivity
).
vocabularyId
val
vocabularyId
=
(
activity
as
MainActivity
).
vocabularyId
...
...
app/src/main/res/layout/activity_main.xml
View file @
86480fca
...
@@ -41,6 +41,14 @@
...
@@ -41,6 +41,14 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/fragment_new_word"
/>
app:layout_constraintTop_toBottomOf=
"@+id/fragment_new_word"
/>
<FrameLayout
android:id=
"@+id/btnAddWordLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
android:background=
"@color/colorPrimary"
android:visibility=
"invisible"
>
<ImageButton
<ImageButton
android:id=
"@+id/btnAddWord"
android:id=
"@+id/btnAddWord"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
@@ -49,11 +57,11 @@
...
@@ -49,11 +57,11 @@
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginRight=
"8dp"
android:background=
"@android:color/transparent"
android:background=
"@android:color/transparent"
app:layout_constraintBottom_toBottomOf=
"parent"
android:layout_gravity=
"end"
app:layout_constraintEnd_toEndOf=
"parent"
android:visibility=
"invisible"
app:srcCompat=
"@drawable/ic_done_icon"
/>
app:srcCompat=
"@drawable/ic_done_icon"
/>
</FrameLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.NavigationView
<android.support.design.widget.NavigationView
...
...
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