Fragments change working!
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -49,7 +49,7 @@ captures/
|
||||
.externalNativeBuild
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
# google-services.json
|
||||
|
||||
# Freeline
|
||||
freeline.py
|
||||
|
||||
@@ -3,7 +3,7 @@ package nl.myhyvesbookplus.tagram;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -1,35 +1,55 @@
|
||||
package nl.myhyvesbookplus.tagram;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.app.Fragment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements CameraFragment.OnFragmentInteractionListener {
|
||||
public class MainActivity extends AppCompatActivity implements CameraFragment.OnFragmentInteractionListener, ProfileFragment.OnFragmentInteractionListener, TimelineFragment.OnFragmentInteractionListener {
|
||||
final static private String TAG = "MainScreen";
|
||||
|
||||
FirebaseAuth mAuth;
|
||||
CameraFragment cameraFragment;
|
||||
|
||||
|
||||
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
|
||||
= new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case nl.myhyvesbookplus.tagram.R.id.navigation_timeline:
|
||||
Log.d(TAG, "onNavigationItemSelected: Timeline");
|
||||
TimelineFragment timeline = new TimelineFragment();
|
||||
transaction.replace(R.id.content, timeline);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
return true;
|
||||
|
||||
case nl.myhyvesbookplus.tagram.R.id.navigation_camera:
|
||||
Log.d(TAG, "onNavigationItemSelected: Camera");
|
||||
CameraFragment camera = new CameraFragment();
|
||||
transaction.replace(R.id.content, camera);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
return true;
|
||||
|
||||
case nl.myhyvesbookplus.tagram.R.id.navigation_profile:
|
||||
Log.d(TAG, "onNavigationItemSelected: Profile");
|
||||
ProfileFragment profile = new ProfileFragment();
|
||||
transaction.replace(R.id.content, profile);
|
||||
transaction.addToBackStack(null);
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -45,19 +65,21 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
||||
BottomNavigationView navigation = (BottomNavigationView) findViewById(nl.myhyvesbookplus.tagram.R.id.navigation);
|
||||
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
if (mAuth.getCurrentUser() == null) {
|
||||
goToLogin();
|
||||
}
|
||||
|
||||
TimelineFragment fragment = new TimelineFragment();
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.content, fragment);
|
||||
transaction.commit();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// super.onBackPressed();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package nl.myhyvesbookplus.tagram;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -3,7 +3,7 @@ package nl.myhyvesbookplus.tagram;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
BIN
app/MyHyvesBookPlusStagram/app/src/main/res/drawable/logo.png
Normal file
BIN
app/MyHyvesBookPlusStagram/app/src/main/res/drawable/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
@@ -12,6 +12,13 @@
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context=".LoginActivity">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:cropToPadding="false"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/logo" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -12,14 +12,8 @@
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment_container"
|
||||
android:name="nl.myhyvesbookplus.tagram.CameraFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/fragment_camera" />
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp">
|
||||
</FrameLayout>
|
||||
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="layout.CameraFragment">
|
||||
tools:context="nl.myhyvesbookplus.tagram.CameraFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -12,7 +12,7 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
android:text="@string/hello_camera" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
<string name="hello_camera">Hello Camera</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user