Code style

This commit is contained in:
Hocuri
2020-04-22 15:05:38 +02:00
parent d7d5faaf64
commit c8351d1dd2
2 changed files with 6 additions and 11 deletions
@@ -259,12 +259,12 @@ public class CreateProfileActivity extends BaseActionBarActivity {
private void initializeProfileAvatar() {
String address = DcHelper.get(this, DcHelper.CONFIG_ADDRESS);
if (AvatarHelper.getSelfAvatarFile(this, address).exists() && AvatarHelper.getSelfAvatarFile(this, address).length() > 0) {
if (AvatarHelper.getSelfAvatarFile(this).exists() && AvatarHelper.getSelfAvatarFile(this).length() > 0) {
new AsyncTask<Void, Void, byte[]>() {
@Override
protected byte[] doInBackground(Void... params) {
try {
return Util.readFully(AvatarHelper.getInputStreamFor(CreateProfileActivity.this, address));
return Util.readFully(AvatarHelper.getInputStreamFor(CreateProfileActivity.this));
} catch (IOException e) {
Log.w(TAG, e);
return null;
@@ -61,23 +61,18 @@ public class AvatarHelper {
}
}
public static InputStream getInputStreamFor(@NonNull Context context, @NonNull String address)
public static InputStream getInputStreamFor(@NonNull Context context)
throws IOException {
return new FileInputStream(getSelfAvatarFile(context, address));
return new FileInputStream(getSelfAvatarFile(context));
}
public static File getSelfAvatarFile(@NonNull Context context, @NonNull Address address) {
String name = new File(address.serialize()).getName();
return getSelfAvatarFile(context, name);
}
public static File getSelfAvatarFile(@NonNull Context context, @NonNull String address) {
public static File getSelfAvatarFile(@NonNull Context context) {
String dirString = DcHelper.getContext(context).getConfig(DcHelper.CONFIG_SELF_AVATAR);
return new File(dirString);
}
public static void setSelfAvatar(@NonNull Context context, @NonNull String address, @Nullable byte[] data) throws IOException {
File avatar = getSelfAvatarFile(context, address);
File avatar = getSelfAvatarFile(context);
if (data == null) {
avatar.delete();
DcHelper.set(context, DcHelper.CONFIG_SELF_AVATAR, null);