Merge branch 'marijn-appje' into 'master'

Fragments change working!

See merge request !5
This commit was merged in pull request #5.
This commit is contained in:
Marijn Jansen
2017-06-19 16:03:22 +02:00
10 changed files with 45 additions and 21 deletions

2
.gitignore vendored
View File

@@ -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

View File

@@ -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;

View File

@@ -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();
} }

View File

@@ -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;

View File

@@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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>