Commit 2d0634ca by Paktalin

Start addWordActivity when button is pressed

parent 1622b5ca
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".activities.AddWordActivity"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.paktalin.vocabularynotebook.activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.paktalin.vocabularynotebook.R;
public class AddWordActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_word);
}
}
package com.paktalin.vocabularynotebook.activities package com.paktalin.vocabularynotebook.activities
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.util.Log import android.util.Log
...@@ -25,10 +26,16 @@ class VocabularyFragment : Fragment() { ...@@ -25,10 +26,16 @@ class VocabularyFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
fabAddWord.setOnClickListener( { addWord() } )
extractUserDocument() extractUserDocument()
printUserData() printUserData()
} }
override fun onDestroy() {
super.onDestroy()
FirebaseAuth.getInstance().signOut()
}
private fun extractUserDocument() { private fun extractUserDocument() {
val userId = FirebaseAuth.getInstance().currentUser!!.uid val userId = FirebaseAuth.getInstance().currentUser!!.uid
Log.d(TAG, "retrieved userId: $userId") Log.d(TAG, "retrieved userId: $userId")
...@@ -56,9 +63,9 @@ class VocabularyFragment : Fragment() { ...@@ -56,9 +63,9 @@ class VocabularyFragment : Fragment() {
} }
} }
override fun onDestroy() { private fun addWord() {
super.onDestroy() val addWordIntent = Intent(activity, AddWordActivity::class.java)
FirebaseAuth.getInstance().signOut() startActivity(addWordIntent)
} }
companion object { companion object {
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/etWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Word"
app:layout_constraintBottom_toTopOf="@+id/etTranslation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<EditText
android:id="@+id/etTranslation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Translation"
app:layout_constraintBottom_toTopOf="@+id/btnSubmit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etWord" />
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Submit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etTranslation" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment