-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'remove_code_duplication'
- Loading branch information
Showing
3 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/de/blau/android/easyedit/AbortableActionModeCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.blau.android.easyedit; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
import de.blau.android.R; | ||
|
||
public abstract class AbortableActionModeCallback extends NonSimpleActionModeCallback { | ||
|
||
/** | ||
* Common code if you want to abort an action mode and rollback any changes | ||
* | ||
* @param manager | ||
*/ | ||
protected AbortableActionModeCallback(EasyEditManager manager) { | ||
super(manager); | ||
} | ||
|
||
@Override | ||
protected void onCloseClicked() { | ||
onBackPressed(); | ||
} | ||
|
||
@Override | ||
public boolean onBackPressed() { | ||
new AlertDialog.Builder(main).setTitle(R.string.abort_action_title).setPositiveButton(R.string.yes, (dialog, which) -> { | ||
logic.rollback(); | ||
super.onBackPressed(); | ||
}).setNeutralButton(R.string.cancel, null).show(); | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters