Merge remote-tracking branch 'origin/marijn-appje' into niels-profile
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
package nl.myhyvesbookplus.tagram;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.hardware.Camera;
|
||||
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;
|
||||
@@ -17,9 +14,10 @@ import android.view.View;
|
||||
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
|
||||
import nl.myhyvesbookplus.tagram.controller.UploadClass;
|
||||
import nl.myhyvesbookplus.tagram.model.BitmapPost;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements CameraFragment.OnFragmentInteractionListener, ProfileFragment.OnFragmentInteractionListener, TimelineFragment.OnFragmentInteractionListener {
|
||||
public class MainActivity extends AppCompatActivity implements CameraFragment.OnFragmentInteractionListener, ProfileFragment.OnFragmentInteractionListener, TimelineFragment.OnFragmentInteractionListener, UploadClass.ProfilePictureUpdatedListener {
|
||||
final static private String TAG = "MainScreen";
|
||||
|
||||
FirebaseAuth mAuth;
|
||||
@@ -74,14 +72,11 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
||||
goToLogin();
|
||||
}
|
||||
|
||||
Log.d(TAG, "onCreate: " + mAuth.getCurrentUser().getPhotoUrl() );
|
||||
|
||||
TimelineFragment fragment = new TimelineFragment();
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.content, fragment);
|
||||
transaction.commit();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,9 +101,15 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
||||
}
|
||||
|
||||
public void testCreatePost(View view) {
|
||||
UploadClass uploadClass = new UploadClass();
|
||||
UploadClass uploadClass = new UploadClass(this);
|
||||
Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8);
|
||||
BitmapPost bitmapPost = new BitmapPost(bitmap, "Dit is een Test!");
|
||||
uploadClass.uploadPicture(bitmapPost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ProfilePictureUpdated(Boolean success) {
|
||||
Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.storage.FirebaseStorage;
|
||||
import com.google.firebase.storage.StorageReference;
|
||||
|
||||
import nl.myhyvesbookplus.tagram.controller.UploadClass;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
/**
|
||||
@@ -38,6 +40,7 @@ import static android.app.Activity.RESULT_OK;
|
||||
*/
|
||||
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
static final int REQUEST_IMAGE_CAPTURE = 1;
|
||||
final static private String TAG = "ProfileFragment";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
@@ -183,7 +186,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
|
||||
Bundle extras = data.getExtras();
|
||||
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
||||
UploadClass uploadClass = new UploadClass();
|
||||
UploadClass uploadClass = new UploadClass(getActivity());
|
||||
uploadClass.uploadProfilePicture(imageBitmap);
|
||||
profilePicture.invalidate();
|
||||
}
|
||||
@@ -246,4 +249,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package nl.myhyvesbookplus.tagram.controller;
|
||||
|
||||
import com.google.firebase.database.DatabaseReference;
|
||||
import com.google.firebase.database.FirebaseDatabase;
|
||||
import com.google.firebase.storage.FirebaseStorage;
|
||||
import com.google.firebase.storage.StorageReference;
|
||||
|
||||
import nl.myhyvesbookplus.tagram.model.UriPost;
|
||||
|
||||
/**
|
||||
* Created by marijnjansen on 23/06/2017.
|
||||
*/
|
||||
|
||||
public class DownloadClass {
|
||||
private static final String TAG = "DownloadClass";
|
||||
private StorageReference mStorageRef;
|
||||
private DatabaseReference mDataRef;
|
||||
|
||||
public DownloadClass() {
|
||||
mStorageRef = FirebaseStorage.getInstance().getReference();
|
||||
mDataRef = FirebaseDatabase.getInstance().getReference();
|
||||
}
|
||||
|
||||
public UriPost[] getPosts() {
|
||||
UriPost[] posts = new UriPost[10];
|
||||
return posts;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package nl.myhyvesbookplus.tagram.controller;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
@@ -34,9 +35,12 @@ public class UploadClass {
|
||||
private StorageReference mStorageRef;
|
||||
private DatabaseReference mDataRef;
|
||||
|
||||
public UploadClass() {
|
||||
private ProfilePictureUpdatedListener mListener;
|
||||
|
||||
public UploadClass(Context context) {
|
||||
mStorageRef = FirebaseStorage.getInstance().getReference();
|
||||
mDataRef = FirebaseDatabase.getInstance().getReference();
|
||||
mListener = (ProfilePictureUpdatedListener) context;
|
||||
}
|
||||
|
||||
/// Helpers ///
|
||||
@@ -117,7 +121,12 @@ public class UploadClass {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
Log.d(TAG, "onComplete: Updated profile picture");
|
||||
mListener.ProfilePictureUpdated(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface ProfilePictureUpdatedListener {
|
||||
void ProfilePictureUpdated(Boolean success);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import android.net.Uri;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* BitmapPost is a Class for a Post with a Bitmap as an image.
|
||||
*/
|
||||
public class BitmapPost extends Post {
|
||||
private Bitmap photo;
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ import com.google.firebase.auth.FirebaseAuth;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by marijnjansen on 22/06/2017.
|
||||
* Post is a Class for a Post with a Bitmap as an image.
|
||||
*/
|
||||
|
||||
abstract class Post {
|
||||
|
||||
private Date date;
|
||||
|
||||
@@ -4,6 +4,9 @@ import android.net.Uri;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* UriPost is a Class for a Post with a Uri as an image.
|
||||
*/
|
||||
public class UriPost extends Post {
|
||||
private String photo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user