Skip to content
Open
Changes from all commits
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 @@ -205,9 +205,7 @@ protected void onDestroy() {
EditorFragment.clearCache();
}

@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
private void handleBack(boolean checkDoublePress) {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
return;
Expand Down Expand Up @@ -245,14 +243,20 @@ public void onBackPressed() {
}

long currentTime = System.currentTimeMillis();
if (currentTime - lastBackPressTime < DOUBLE_PRESS_INTERVAL) {
if (!checkDoublePress || currentTime - lastBackPressTime < DOUBLE_PRESS_INTERVAL) {
exitActivity();
} else {
lastBackPressTime = currentTime;
SketchwareUtil.showMessage(this, "Press back again to exit");
}
}

@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
handleBack(true);
}


// ==========================================
// Initialization & UI Setup
Expand Down Expand Up @@ -602,7 +606,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
showCompilationOptionsDialog();
return true;
} else if (id == R.id.action_exit) {
onBackPressed();
handleBack(false);
return true;
}

Expand Down