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