Marijn appje #11
@@ -1,5 +1,6 @@
|
||||
package nl.myhyvesbookplus.tagram;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -33,25 +34,25 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
||||
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();
|
||||
transaction.replace(R.id.content, timeline)
|
||||
.addToBackStack(null)
|
||||
.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();
|
||||
transaction.replace(R.id.content, camera)
|
||||
.addToBackStack(null)
|
||||
.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();
|
||||
transaction.replace(R.id.content, profile)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -110,6 +111,13 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
||||
@Override
|
||||
public void ProfilePictureUpdated(Boolean success) {
|
||||
Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!");
|
||||
FragmentManager man = getFragmentManager();
|
||||
ProfileFragment frag = (ProfileFragment) man.findFragmentById(R.id.content);
|
||||
FragmentTransaction transaction = man.beginTransaction();
|
||||
transaction.detach(frag)
|
||||
.attach(frag)
|
||||
.commit();
|
||||
Log.d(TAG, "ProfilePictureUpdated: Done reloading fragment");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,9 +91,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
}
|
||||
|
||||
user = FirebaseAuth.getInstance().getCurrentUser();
|
||||
if (user != null && user.getPhotoUrl() != null) {
|
||||
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +118,16 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
findViews(view);
|
||||
|
||||
if (user != null && user.getPhotoUrl() != null) {
|
||||
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
||||
}
|
||||
|
||||
if (httpsReference != null) {
|
||||
Glide.with(this).using(new FirebaseImageLoader()).load(httpsReference).into(profilePicture);
|
||||
}
|
||||
|
||||
profilePicture.invalidate();
|
||||
|
||||
if (user != null && user.getDisplayName() != null) {
|
||||
profileName.setText(user.getDisplayName());
|
||||
}
|
||||
@@ -188,27 +191,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
||||
UploadClass uploadClass = new UploadClass(getActivity());
|
||||
uploadClass.uploadProfilePicture(imageBitmap);
|
||||
// uploadClass.uploadPicture(new BitmapPost(imageBitmap, "Ik ben een heel mooi comment"));
|
||||
// downloadUrl = uploadClass.getDownloadUrl();
|
||||
// updateUserProfilePic(user);
|
||||
}
|
||||
}
|
||||
|
||||
// protected void updateUserProfilePic(final FirebaseUser user) {
|
||||
// UserProfileChangeRequest request = new UserProfileChangeRequest.Builder()
|
||||
// .setPhotoUri(downloadUrl)
|
||||
// .build();
|
||||
//
|
||||
// user.updateProfile(request)
|
||||
// .addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
// @Override
|
||||
// public void onComplete(@NonNull Task<Void> task) {
|
||||
// if (task.isSuccessful()) {
|
||||
// Log.d(TAG, "User profile updated!");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// TODO Make this function into its own class for modularity.
|
||||
|
||||
Reference in New Issue
Block a user