mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Extract alert dialog creation to a function
This commit is contained in:
parent
de9bb89ff2
commit
67d1df27fb
1 changed files with 14 additions and 28 deletions
|
|
@ -233,26 +233,14 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
||||||
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
||||||
value = titleEdit.getRight() - titleEdit.getCompoundDrawables()[2].getBounds().width();
|
value = titleEdit.getRight() - titleEdit.getCompoundDrawables()[2].getBounds().width();
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
||||||
new AlertDialog.Builder(getContext())
|
showInfoAlert(R.string.media_detail_title, R.string.title_info);
|
||||||
.setTitle(R.string.media_detail_title)
|
|
||||||
.setMessage(R.string.title_info)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = titleEdit.getLeft() + titleEdit.getCompoundDrawables()[0].getBounds().width();
|
value = titleEdit.getLeft() + titleEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
new AlertDialog.Builder(getContext())
|
showInfoAlert(R.string.media_detail_title, R.string.title_info);
|
||||||
.setTitle(R.string.media_detail_title)
|
|
||||||
.setMessage(R.string.title_info)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,26 +253,14 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
||||||
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
if (ViewCompat.getLayoutDirection(getView()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
||||||
value = descEdit.getRight() - descEdit.getCompoundDrawables()[2].getBounds().width();
|
value = descEdit.getRight() - descEdit.getCompoundDrawables()[2].getBounds().width();
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() >= value) {
|
||||||
new AlertDialog.Builder(getContext())
|
showInfoAlert(R.string.media_detail_description,R.string.description_info);
|
||||||
.setTitle(R.string.media_detail_description)
|
|
||||||
.setMessage(R.string.description_info)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
value = descEdit.getLeft() + descEdit.getCompoundDrawables()[0].getBounds().width();
|
value = descEdit.getLeft() + descEdit.getCompoundDrawables()[0].getBounds().width();
|
||||||
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
if (motionEvent.getAction() == ACTION_UP && motionEvent.getRawX() <= value) {
|
||||||
new AlertDialog.Builder(getContext())
|
showInfoAlert(R.string.media_detail_description,R.string.description_info);
|
||||||
.setTitle(R.string.media_detail_description)
|
|
||||||
.setMessage(R.string.description_info)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -351,4 +327,14 @@ public class SingleUploadFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showInfoAlert (int titleStringID, int messageStringID){
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle(titleStringID)
|
||||||
|
.setMessage(messageStringID)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setNeutralButton(android.R.string.ok, (dialog, id) -> dialog.cancel())
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue