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
1622b5ca
authored
Sep 07, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved vocabulary logic to a fragment
parent
5bbf1a85
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
27 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/paktalin/vocabularynotebook/activities/LogInActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/activities/UserActivity.kt → app/src/main/java/com/paktalin/vocabularynotebook/activities/VocabularyFragment.kt
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_vocabulary.xml → app/src/main/res/layout/fragment_vocabulary.xml
app/src/main/AndroidManifest.xml
View file @
1622b5ca
...
...
@@ -15,7 +15,7 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".activities.
User
Activity"
/>
<activity
android:name=
".activities.
Main
Activity"
/>
<activity
android:name=
".activities.LogInActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/activities/LogInActivity.kt
View file @
1622b5ca
...
...
@@ -78,8 +78,8 @@ class LogInActivity : AppCompatActivity() {
}
fun
startUserActivity
()
{
Log
.
d
(
TAG
,
"
Sign
ed in successfully"
)
val
userActivityIntent
=
Intent
(
this
@LogInActivity
,
User
Activity
::
class
.
java
)
Log
.
d
(
TAG
,
"
Logg
ed in successfully"
)
val
userActivityIntent
=
Intent
(
this
@LogInActivity
,
Main
Activity
::
class
.
java
)
startActivity
(
userActivityIntent
)
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/activities/MainActivity.kt
0 → 100644
View file @
1622b5ca
package
com.paktalin.vocabularynotebook.activities
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
com.paktalin.vocabularynotebook.R
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
navigationView
.
setNavigationItemSelectedListener
{
menuItem
->
menuItem
.
isChecked
=
true
drawerLayout
!!
.
closeDrawers
()
true
}
}
companion
object
{
private
val
TAG
=
"VN/"
+
MainActivity
::
class
.
simpleName
}
}
app/src/main/java/com/paktalin/vocabularynotebook/activities/
UserActivity
.kt
→
app/src/main/java/com/paktalin/vocabularynotebook/activities/
VocabularyFragment
.kt
View file @
1622b5ca
...
...
@@ -2,42 +2,33 @@ package com.paktalin.vocabularynotebook.activities
import
android.annotation.SuppressLint
import
android.os.Bundle
import
android.support.design.widget.NavigationView
import
android.support.v7.app.AppCompatActivity
import
android.support.v4.app.Fragment
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.DocumentSnapshot
import
com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.R
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_vocabulary.*
import
kotlinx.android.synthetic.main.fragment_vocabulary.*
class
UserActivity
:
AppCompatActivity
()
{
class
VocabularyFragment
:
Fragment
()
{
private
lateinit
var
userDocument
:
DocumentReference
private
val
db
=
FirebaseFirestore
.
getInstance
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
navigationView
.
setNavigationItemSelectedListener
{
menuItem
->
menuItem
.
isChecked
=
true
drawerLayout
!!
.
closeDrawers
()
true
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_vocabulary
,
container
,
false
)
}
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
extractUserDocument
()
printUserData
()
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
FirebaseAuth
.
getInstance
().
signOut
()
}
private
fun
extractUserDocument
()
{
val
userId
=
FirebaseAuth
.
getInstance
().
currentUser
!!
.
uid
Log
.
d
(
TAG
,
"retrieved userId: $userId"
)
...
...
@@ -65,7 +56,12 @@ class UserActivity : AppCompatActivity() {
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
FirebaseAuth
.
getInstance
().
signOut
()
}
companion
object
{
private
val
TAG
=
"VN/"
+
UserActivity
::
class
.
simpleName
private
val
TAG
=
"VN/"
+
VocabularyFragment
::
class
.
simpleName
}
}
app/src/main/res/layout/activity_main.xml
View file @
1622b5ca
...
...
@@ -8,10 +8,11 @@
android:layout_height=
"match_parent"
tools:openDrawer=
"start"
>
<include
layout=
"@layout/activity_vocabulary"
<fragment
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
android:name=
"com.paktalin.vocabularynotebook.activities.VocabularyFragment"
android:id=
"@+id/fragment_vocabulary"
/>
<android.support.design.widget.NavigationView
android:id=
"@+id/navigationView"
...
...
app/src/main/res/layout/
activity
_vocabulary.xml
→
app/src/main/res/layout/
fragment
_vocabulary.xml
View file @
1622b5ca
...
...
@@ -6,7 +6,7 @@
android:layout_height=
"match_parent"
android:background=
"@android:color/transparent"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
tools:context=
"com.paktalin.vocabularynotebook.activities.
UserActivity
"
>
tools:context=
"com.paktalin.vocabularynotebook.activities.
VocabularyFragment
"
>
<TextView
android:id=
"@+id/tvCongrats"
...
...
@@ -41,4 +41,15 @@
android:layout_marginTop=
"8dp"
app:layout_constraintTop_toBottomOf=
"@+id/tvUserData"
/>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/fabAddWord"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:src=
"@android:drawable/ic_input_add"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</android.support.constraint.ConstraintLayout>
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