Skip to content

Commit

Permalink
Fix: 디폴트 프로필 이미지 오류 수정
Browse files Browse the repository at this point in the history
body: 친구가 디폴트 프로필 이미지일 때, 친구 목록에 친구가 안뜨는 오류를 수정함

footer
  • Loading branch information
JieunYume committed May 25, 2023
1 parent 2c352ae commit ec3dcf3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 42 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/org/techtown/bookshelf/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public void changeFragment(String FriendId) {
ft.commit();
Toast.makeText(this, FriendId, Toast.LENGTH_SHORT).show();
}
//친구 데이터 뿌리기(1번레이아웃)

//홈 상단 친구목록 데이터 읽어오기(1번레이아웃)
public void dispFriendProfile() {
friendRecyclerView = (RecyclerView) findViewById(R.id.friendRecyclerView);
friendAdapter = new FriendAdapter(); //어답터 초기화
Expand All @@ -182,9 +183,7 @@ public void onDataChange(@NonNull DataSnapshot snapshot) {
StorageReference storageReference = storage.getReference();
StorageReference pathReference = storageReference.child("ProfileImage/" + friend_id);
if (pathReference == null) {
mfriendItems.add(new Friend(friend_id, default_image_uri));
Log.e("friend_id", friend_id);
friendAdapter.setFriendList(mfriendItems);
Log.e("오류", "저장소 폴더 오류");
} else {
StorageReference submitProfile = storageReference.child("ProfileImage/" + friend_id + "/1.png");
submitProfile.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
Expand All @@ -193,6 +192,13 @@ public void onSuccess(Uri uri) {
mfriendItems.add(new Friend(friend_id, uri));
friendAdapter.setFriendList(mfriendItems);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mfriendItems.add(new Friend(friend_id, default_image_uri));
Toast.makeText(getApplicationContext(), friend_id, Toast.LENGTH_LONG).show();
friendAdapter.setFriendList(mfriendItems);
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void loadMyImage(RoundImageView myImage) {
StorageReference pathReference = storageReference.child("ProfileImage/"+UserId);
if (pathReference == null) {
Toast.makeText(getActivity(), "저장소에 사진이 없습니다.", Toast.LENGTH_LONG).show();

} else{
StorageReference submitProfile=storageReference.child("ProfileImage/"+UserId+"/1.png");
submitProfile.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
Expand All @@ -128,8 +127,10 @@ public void onSuccess(Uri uri) {
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getActivity(), "이미지를 불러오는 데 실패했습니다.", Toast.LENGTH_LONG).show();

Glide.with(myImage)
.load(R.drawable.default_profile)
.placeholder(R.drawable.icon_search)
.into(myImage);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public void onSuccess(Uri uri) {
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "이미지를 불러오는 데 실패했습니다.", Toast.LENGTH_LONG).show();
userList.add(new Friend(user_id, ((MainActivity)MainActivity.mContext).default_image_uri));
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.techtown.bookshelf.login;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
Expand Down Expand Up @@ -68,21 +71,6 @@ public void onClick(View v) {
startActivity(intent);
}
});

storage = FirebaseStorage.getInstance();
StorageReference storageReference = storage.getReference();
StorageReference submitProfile=storageReference.child("ProfileImage/default_profile.png");
submitProfile.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
default_image_uri=uri;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "디폴트 이미지를 불러오는 데 실패했습니다.", Toast.LENGTH_LONG).show(); }
});

}

private void id_check() {
Expand Down Expand Up @@ -154,25 +142,9 @@ public void onClick(View view) {
firebaseDatabase.getReference("user").child(UserId).child("join_date").setValue(joinDate.toString());
firebaseDatabase.getReference("user").child(UserId).child("password").setValue(UserPwd);

StorageReference storageReference = storage.getReference();
StorageReference riversReference = storageReference.child("ProfileImage/"+UserId+"/1.png");
UploadTask uploadTask = riversReference.putFile(default_image_uri);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(RegisterActivity.this, "업로드 실패!", Toast.LENGTH_LONG).show();
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(RegisterActivity.this, "업로드 성공!", Toast.LENGTH_LONG).show();

Toast.makeText(getApplicationContext(), String.format("%s님 가입을 환영합니다.", UserId), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
startActivity(intent);

}
});
Toast.makeText(getApplicationContext(), String.format("%s님 가입을 환영합니다.", UserId), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
dialog = builder.setMessage("비밀번호가 동일하지 않습니다.").setNegativeButton("확인", null).create();
Expand Down

0 comments on commit ec3dcf3

Please sign in to comment.