3

프로필 pic이있는 네비게이션 서랍이있는 4 개의 조각이있는 안드로이드 응용 프로그램이 있습니다. 그러나 프로파일 조각을 편집/업데이트 할 때 문제가 있습니다. 프로필 사진은이 부분에서 업데이트 중이고 공유 기본 설정 (또한 서버에 업로드)에 그림 URL을 저장하고 있습니다. 그러나 홈 조각으로 돌아 가면 탐색 창에있는 프로필 사진이 최신 그림으로 업데이트되지 않습니다. Glide lib를 사용하고 있습니다. 프로필 그림을로드하기 위해이 이미지는 공유 환경 설정에 저장된 URL을로드합니다. 하지만 내 애플 리케이션을 닫고 탐색 사진에서 최근 사진 찍은 업데이 트에 프로필 사진을 엽니 다. 사용자에게 앱을 닫고 프로필 조각 편집에서 프로필 사진을 변경할 때마다 열도록 요청할 수는 없습니다. 이 문제를 해결할 방법이 있습니까?그림이 Edit Profile Fragment에서 바뀌면 탐색 창에 프로필 그림이 업데이트됩니다.

//getting image URL from Shared Preferences. 
     imgUrl = Prefrences.getProfile_picture(HomeActivity.this); 
     loadImageUrl(imgUrl); 

//loading image in navigation drawer with glide in Main Activity 
private void loadImageUrl(String imgUrl) { 
    if (imgUrl != null && !imgUrl.isEmpty()) { 
     Glide.with(this).load(imgUrl).placeholder(R.drawable.avatar) 
       .crossFade() 
       .thumbnail(0.5f) 
       .bitmapTransform(new CircleTransform(this)) 
       .diskCacheStrategy(DiskCacheStrategy.ALL) 
       .into(img_profile); 
    } else { 
     getUserDetails(); <-- this method is called when imgUrl is Null, 
    } 

} 
+0

'EditProfileFragment'에 서랍이 있습니까? –

+0

아니요, 서랍이 없습니다. 그림을 표시/변경할 수있는 사진보기 만 있고 이름, 전화 번호 등의 EditText 필드가 없습니다. –

답변

0

아마도 이미지가 글라이드에 의해 캐시되고 있습니다.

확인 여기 상위 2 응답 Remove image from cache in Glide library

+0

위의 답변을 시도했지만 운이 없으니 응답 해 주셔서 감사드립니다. –

+0

어떤 콜백에서 이미지를 가져 오는 중입니까? onCreate? –

+0

예, 주 활동, onCreate() 메소드에서 이미지를 가져 오는 중입니다. –

0

당신은 일부 바인딩 당신이 당신의 탐색 활동을 만들 데이터 ....

데이터 분리를 새로 탐색보기를 호출하고이 같이 호출 할 수 있습니다 fromCreate()

private void updateNavHeaderView(){ 
View headerView = navigationView.inflateHeaderView(R.layout.nav_header); 
     ImageView ivUserProfilePhoto = (ImageView) headerView.findViewById(R.id.ivUserProfilePhoto); 
     TextView userName = (TextView) headerView.findViewById(R.id.userName); 

     if (user != null && user.getUser_image() != null && !user.getUser_image().equals("")) { 
      Picasso.with(MainActivity.this) 
        .load(Config.BASE_IMAGE_URL+"/"+user.getUser_image()) 
        .placeholder(R.drawable.user_profile) 
        .resize(avatarSize, avatarSize) 
        .centerCrop() 
        .transform(new CircleTransformation()) 
        .into(ivUserProfilePhoto); 
     } else { 
      ivUserProfilePhoto.setImageDrawable(getResources().getDrawable(R.drawable.user_profile)); 
     } 
     } 
+0

감사합니다. 아프고 시도해보고 알려 주시면 감사하겠습니다. :) –