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
c8b88113
authored
Sep 11, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WordInfoFragment is opened when a list item is clicked
parent
c53a7d01
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
46 additions
and
96 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/paktalin/vocabularynotebook/ConfiguredFirestore.kt
app/src/main/java/com/paktalin/vocabularynotebook/UserManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyApplication.java → app/src/main/java/com/paktalin/vocabularynotebook/app_setup/VocabularyApplication.java
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/WordInfoFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/WordItemInfoActivity.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_word_info.xml
app/src/main/AndroidManifest.xml
View file @
c8b88113
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<uses-permission
android:name=
"android.permission.READ_CONTACTS"
/>
<uses-permission
android:name=
"android.permission.READ_CONTACTS"
/>
<application
<application
android:name=
".VocabularyApplication"
android:name=
".
app_setup.
VocabularyApplication"
android:allowBackup=
"true"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".ui.WordItemInfoActivity"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ConfiguredFirestore.kt
deleted
100644 → 0
View file @
c53a7d01
package
com.paktalin.vocabularynotebook
import
com.google.firebase.firestore.FirebaseFirestore
import
com.google.firebase.firestore.FirebaseFirestoreSettings
object
ConfiguredFirestore
{
val
instance
:
FirebaseFirestore
get
()
{
val
firestore
=
FirebaseFirestore
.
getInstance
()
val
settings
=
FirebaseFirestoreSettings
.
Builder
()
.
setTimestampsInSnapshotsEnabled
(
true
)
.
build
()
firestore
.
firestoreSettings
=
settings
return
firestore
}
}
app/src/main/java/com/paktalin/vocabularynotebook/UserManager.kt
View file @
c8b88113
...
@@ -2,6 +2,7 @@ package com.paktalin.vocabularynotebook
...
@@ -2,6 +2,7 @@ package com.paktalin.vocabularynotebook
import
android.util.Log
import
android.util.Log
import
com.google.firebase.auth.FirebaseUser
import
com.google.firebase.auth.FirebaseUser
import
com.paktalin.vocabularynotebook.app_setup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.ui.LogInActivity
import
com.paktalin.vocabularynotebook.ui.LogInActivity
import
com.paktalin.vocabularynotebook.pojo.UserPojo
import
com.paktalin.vocabularynotebook.pojo.UserPojo
import
com.paktalin.vocabularynotebook.pojo.VocabularyPojo
import
com.paktalin.vocabularynotebook.pojo.VocabularyPojo
...
...
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
c8b88113
package
com.paktalin.vocabularynotebook
package
com.paktalin.vocabularynotebook
import
android.app.Activity
import
android.app.Activity
import
android.
content.Intent
import
android.
os.Bundle
import
android.support.v7.widget.PopupMenu
import
android.support.v7.widget.PopupMenu
import
android.support.v7.widget.RecyclerView
import
android.support.v7.widget.RecyclerView
import
android.util.Log
import
android.util.Log
import
android.view.*
import
android.view.*
import
android.widget.ImageButton
import
android.widget.LinearLayout
import
android.widget.LinearLayout
import
android.widget.TextView
import
android.widget.TextView
import
com.paktalin.vocabularynotebook.ui.MainActivity
import
com.paktalin.vocabularynotebook.ui.MainActivity
import
com.paktalin.vocabularynotebook.ui.WordInfoFragment
import
com.paktalin.vocabularynotebook.ui.WordInfoFragment
import
com.paktalin.vocabularynotebook.ui.WordItemInfoActivity
class
VocabularyAdapter
(
private
val
wordItems
:
MutableList
<
WordItem
>,
private
val
context
:
Activity
)
:
RecyclerView
.
Adapter
<
VocabularyAdapter
.
ViewHolder
>()
{
class
VocabularyAdapter
(
private
val
wordItems
:
MutableList
<
WordItem
>,
private
val
activity
:
Activity
)
:
RecyclerView
.
Adapter
<
VocabularyAdapter
.
ViewHolder
>()
{
private
lateinit
var
recyclerView
:
RecyclerView
private
lateinit
var
recyclerView
:
RecyclerView
...
@@ -39,17 +37,15 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
...
@@ -39,17 +37,15 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
override
fun
getItemCount
():
Int
{
return
wordItems
.
size
}
override
fun
getItemCount
():
Int
{
return
wordItems
.
size
}
private
fun
openWordItemInfo
(
wordItem
:
WordItem
)
{
private
fun
openWordItemInfo
(
wordItem
:
WordItem
)
{
/* val intentWordItemInfo = Intent(context, WordItemInfoActivity::class.java)
val
wordInfoFragment
=
WordInfoFragment
()
intentWordItemInfo.putExtra("wordItem", wordItem)
val
arguments
=
Bundle
()
context.startActivity(intentWordItemInfo)*/
arguments
.
putSerializable
(
"wordItem"
,
wordItem
)
wordInfoFragment
.
arguments
=
arguments
Log
.
d
(
TAG
,
"starting transaction"
)
(
activity
as
MainActivity
).
supportFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
content
,
wordInfoFragment
).
commit
()
//todo start word info fragment
/*(context as MainActivity).supportFragmentManager.beginTransaction().add(R.id.for_fragment, WordInfoFragment()).commit()*/
}
}
private
fun
showPopupMenu
(
v
:
View
,
position
:
Int
)
{
private
fun
showPopupMenu
(
v
:
View
,
position
:
Int
)
{
val
popup
=
PopupMenu
(
context
,
v
)
val
popup
=
PopupMenu
(
activity
,
v
)
val
inflater
=
popup
.
menuInflater
val
inflater
=
popup
.
menuInflater
inflater
.
inflate
(
R
.
menu
.
word_item_menu
,
popup
.
menu
)
inflater
.
inflate
(
R
.
menu
.
word_item_menu
,
popup
.
menu
)
popup
.
setOnMenuItemClickListener
{
popup
.
setOnMenuItemClickListener
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/WordItem.kt
View file @
c8b88113
package
com.paktalin.vocabularynotebook
package
com.paktalin.vocabularynotebook
import
android.util.Log
import
android.util.Log
import
com.paktalin.vocabularynotebook.app_setup.ConfiguredFirestore
import
java.io.Serializable
import
java.io.Serializable
...
...
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyApplication.java
→
app/src/main/java/com/paktalin/vocabularynotebook/
app_setup/
VocabularyApplication.java
View file @
c8b88113
package
com
.
paktalin
.
vocabularynotebook
;
package
com
.
paktalin
.
vocabularynotebook
.
app_setup
;
import
android.app.Application
;
import
android.app.Application
;
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/MainActivity.kt
View file @
c8b88113
...
@@ -13,7 +13,7 @@ import android.view.WindowManager
...
@@ -13,7 +13,7 @@ import android.view.WindowManager
import
android.app.Activity
import
android.app.Activity
import
android.view.View
import
android.view.View
import
android.view.inputmethod.InputMethodManager
import
android.view.inputmethod.InputMethodManager
import
com.paktalin.vocabularynotebook.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.
app_setup.
ConfiguredFirestore
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
View file @
c8b88113
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
android.widget.ImageButton
import
android.widget.ImageButton
import
android.widget.Toast
import
android.widget.Toast
import
com.paktalin.vocabularynotebook.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.
app_setup.
ConfiguredFirestore
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.WordItem
import
com.paktalin.vocabularynotebook.WordItem
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_new_word.*
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyFragment.kt
View file @
c8b88113
...
@@ -9,6 +9,7 @@ import android.view.ViewGroup
...
@@ -9,6 +9,7 @@ import android.view.ViewGroup
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.firestore.DocumentSnapshot
import
com.google.firebase.firestore.DocumentSnapshot
import
com.paktalin.vocabularynotebook.*
import
com.paktalin.vocabularynotebook.*
import
com.paktalin.vocabularynotebook.app_setup.ConfiguredFirestore
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
class
VocabularyFragment
:
Fragment
()
{
class
VocabularyFragment
:
Fragment
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/WordInfoFragment.kt
View file @
c8b88113
...
@@ -7,12 +7,26 @@ import android.view.LayoutInflater
...
@@ -7,12 +7,26 @@ import android.view.LayoutInflater
import
android.view.View
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.WordItem
import
kotlinx.android.synthetic.main.activity_word_info.*
class
WordInfoFragment
:
Fragment
()
{
class
WordInfoFragment
:
Fragment
()
{
private
lateinit
var
wordItem
:
WordItem
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
Log
.
d
(
"TTT"
,
"onCreateView"
)
wordItem
=
arguments
!!
[
"wordItem"
]
as
WordItem
return
inflater
.
inflate
(
R
.
layout
.
activity_word_info
,
container
,
false
)
return
inflater
.
inflate
(
R
.
layout
.
activity_word_info
,
container
,
false
)
}
}
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
setData
()
}
private
fun
setData
()
{
etWord
.
text
=
wordItem
.
pojo
!!
.
word
etTranslation
.
text
=
wordItem
.
pojo
!!
.
translation
}
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/WordItemInfoActivity.kt
deleted
100644 → 0
View file @
c53a7d01
package
com.paktalin.vocabularynotebook.ui
import
android.content.Intent
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
android.view.Menu
import
android.view.MenuItem
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.WordItem
import
kotlinx.android.synthetic.main.activity_word_info.*
class
WordItemInfoActivity
:
AppCompatActivity
()
{
private
lateinit
var
wordItem
:
WordItem
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_word_info
)
wordItem
=
intent
.
getSerializableExtra
(
"wordItem"
)
as
WordItem
setData
()
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
):
Boolean
{
val
inflater
=
menuInflater
inflater
.
inflate
(
R
.
menu
.
word_item_info_menu
,
menu
)
return
true
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
when
(
item
!!
.
itemId
)
{
R
.
id
.
item_delete
->
{
wordItem
.
delete
()
cancel
()
}
R
.
id
.
item_edit
->
{
//todo edit item
}
}
return
true
}
private
fun
setData
()
{
etWord
.
text
=
wordItem
.
pojo
!!
.
word
etTranslation
.
text
=
wordItem
.
pojo
!!
.
translation
}
private
fun
cancel
()
{
val
intentMainActivity
=
Intent
(
this
,
MainActivity
::
class
.
java
)
startActivity
(
intentMainActivity
)
}
companion
object
{
private
val
TAG
=
"VN/"
+
WordItemInfoActivity
::
class
.
java
.
simpleName
}
}
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
c8b88113
...
@@ -7,12 +7,19 @@
...
@@ -7,12 +7,19 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:openDrawer=
"start"
>
tools:openDrawer=
"start"
>
<include
layout=
"@layout/notebook_sheet"
/>
<FrameLayout
android:id=
"@+id/content"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
<include
layout=
"@layout/notebook_sheet"
/>
android:id=
"@+id/progress"
layout=
"@layout/progress"
<include
android:visibility=
"gone"
/>
android:id=
"@+id/progress"
layout=
"@layout/progress"
android:visibility=
"gone"
/>
</FrameLayout>
<android.support.design.widget.NavigationView
<android.support.design.widget.NavigationView
android:id=
"@+id/navigationView"
android:id=
"@+id/navigationView"
...
...
app/src/main/res/layout/activity_word_info.xml
View file @
c8b88113
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"250dp"
android:layout_width=
"250dp"
android:layout_height=
"180dp"
android:layout_height=
"180dp"
android:layout_gravity=
"center"
>
android:background=
"@android:color/white"
android:layout_gravity=
"center"
>
<TextView
<TextView
android:id=
"@+id/etWord"
android:id=
"@+id/etWord"
...
...
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