mirror of
https://github.com/Docile-Alligator/Infinity-For-Reddit.git
synced 2025-10-29 11:35:08 +00:00
Use getOnBackPressedDispatcher().addCallback in MainActivity.
This commit is contained in:
parent
a2d991e6d0
commit
5fe3041b9f
@ -23,6 +23,7 @@ import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -397,6 +398,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}*/
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
handleBackPress();
|
||||
}
|
||||
});
|
||||
|
||||
initializeNotificationAndBindView();
|
||||
}
|
||||
|
||||
@ -1263,8 +1271,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
private void handleBackPress() {
|
||||
if (binding.drawerLayout.isOpen()) {
|
||||
binding.drawerLayout.close();
|
||||
} else {
|
||||
@ -1278,7 +1285,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
} else if (mBackButtonAction == SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION_OPEN_NAVIGATION_DRAWER) {
|
||||
binding.drawerLayout.open();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user