Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Update CustomerProfileActivity.java #82

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,19 @@ public Uri getImageUri(Context inContext, Bitmap inImage) {
return Uri.parse(path);
}

@Override
@Override
public void checkCameraPermission() {
if (CheckSelfPermissionAndRequest.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
shareImage();
} else {
requestPermission();
if (CheckSelfPermissionAndRequest.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
shareImage();
} else {
requestPermission();
}
}
}

Expand All @@ -144,14 +150,12 @@ public void requestPermission() {
R.string.dialog_message_write_permission_for_share_never_ask_again),
ConstantKeys.PERMISSIONS_WRITE_EXTERNAL_STORAGE_STATUS);
}

@Override
public void loadCustomerPortrait() {
ImageLoaderUtils imageLoaderUtils = new ImageLoaderUtils(this);
imageLoaderUtils.loadImage(imageLoaderUtils.buildCustomerPortraitImageUrl(
customerIdentifier), ivCustomerProfile, R.drawable.mifos_logo_new);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
Expand All @@ -164,6 +168,16 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
Toaster.show(findViewById(android.R.id.content),
getString(R.string.permission_denied_write));
}
case ConstantKeys.PERMISSIONS_REQUEST_CAMERA: {switch (requestCode) {
case ConstantKeys.PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are using two switches? It is too complicated, even by that, as I see in both cases we are doing the same thing. Instead, add only case ConstantKeys.PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE: before case ConstantKeys.PERMISSIONS_REQUEST_CAMERA: at line number 163 without adding break after the first case. It will do the same work as your boilerplate codes are doing at line numbers[171-180].

if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
shareImage();
} else {
Toaster.show(findViewById(android.R.id.content),
getString(R.string.permission_denied_write));
}
}}
}
}
}
Expand All @@ -173,12 +187,10 @@ public void refreshUI() {
loadCustomerPortrait();
sweetUIErrorHandler.hideSweetErrorLayoutUI(ivCustomerProfile, errorView);
}

@Override
public void showNoInternetConnection() {
sweetUIErrorHandler.showSweetNoInternetUI(ivCustomerProfile, errorView);
}

@Override
public void showError(String message) {
sweetUIErrorHandler.showSweetCustomErrorUI(message,
Expand Down