Profile photo update things.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package nl.myhyvesbookplus.tagram;
|
package nl.myhyvesbookplus.tagram;
|
||||||
|
|
||||||
|
import android.app.FragmentManager;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -33,25 +34,25 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
|||||||
case nl.myhyvesbookplus.tagram.R.id.navigation_timeline:
|
case nl.myhyvesbookplus.tagram.R.id.navigation_timeline:
|
||||||
Log.d(TAG, "onNavigationItemSelected: Timeline");
|
Log.d(TAG, "onNavigationItemSelected: Timeline");
|
||||||
TimelineFragment timeline = new TimelineFragment();
|
TimelineFragment timeline = new TimelineFragment();
|
||||||
transaction.replace(R.id.content, timeline);
|
transaction.replace(R.id.content, timeline)
|
||||||
transaction.addToBackStack(null);
|
.addToBackStack(null)
|
||||||
transaction.commit();
|
.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");
|
Log.d(TAG, "onNavigationItemSelected: Camera");
|
||||||
CameraFragment camera = new CameraFragment();
|
CameraFragment camera = new CameraFragment();
|
||||||
transaction.replace(R.id.content, camera);
|
transaction.replace(R.id.content, camera)
|
||||||
transaction.addToBackStack(null);
|
.addToBackStack(null)
|
||||||
transaction.commit();
|
.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");
|
Log.d(TAG, "onNavigationItemSelected: Profile");
|
||||||
ProfileFragment profile = new ProfileFragment();
|
ProfileFragment profile = new ProfileFragment();
|
||||||
transaction.replace(R.id.content, profile);
|
transaction.replace(R.id.content, profile)
|
||||||
transaction.addToBackStack(null);
|
.addToBackStack(null)
|
||||||
transaction.commit();
|
.commit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -110,6 +111,13 @@ public class MainActivity extends AppCompatActivity implements CameraFragment.On
|
|||||||
@Override
|
@Override
|
||||||
public void ProfilePictureUpdated(Boolean success) {
|
public void ProfilePictureUpdated(Boolean success) {
|
||||||
Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!");
|
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();
|
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);
|
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||||
findViews(view);
|
findViews(view);
|
||||||
|
|
||||||
|
if (user != null && user.getPhotoUrl() != null) {
|
||||||
|
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
||||||
|
}
|
||||||
|
|
||||||
if (httpsReference != null) {
|
if (httpsReference != null) {
|
||||||
Glide.with(this).using(new FirebaseImageLoader()).load(httpsReference).into(profilePicture);
|
Glide.with(this).using(new FirebaseImageLoader()).load(httpsReference).into(profilePicture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profilePicture.invalidate();
|
||||||
|
|
||||||
if (user != null && user.getDisplayName() != null) {
|
if (user != null && user.getDisplayName() != null) {
|
||||||
profileName.setText(user.getDisplayName());
|
profileName.setText(user.getDisplayName());
|
||||||
}
|
}
|
||||||
@@ -188,27 +191,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
||||||
UploadClass uploadClass = new UploadClass(getActivity());
|
UploadClass uploadClass = new UploadClass(getActivity());
|
||||||
uploadClass.uploadProfilePicture(imageBitmap);
|
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.
|
// TODO Make this function into its own class for modularity.
|
||||||
|
|||||||
Reference in New Issue
Block a user