An android library that helps you to finish activity with slide gesture, never stuck with a bunch of activities openning.
Please download the latest release apk via Download APK.
You can download the dependency from JitPack using Gradle for AndroidX.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation "com.github.phantomVK:SlideBack:latest.release"
}Add <item name="android:windowIsTranslucent">true</item> to your ActivityTheme in styles.xml, such as
<resources>
<!-- Base application theme. -->
<stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
....
<itemname="android:windowIsTranslucent">true</item>
</style>
</resources>Extends the class named SlideActivity using your Activity, set the edge which is going to track after setContentView(View).
publicclassMainActivityextendsSlideActivity {
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (!slideManager.isSlideDisable()) {
overridePendingTransition(R.anim.slide_in_right, 0);
}
}
// Optional, set tracking edge after content changed.// Default edge is ViewDragHelper.EDGE_LEFT.@OverridepublicvoidonContentChanged() {
super.onContentChanged();
slideManager.getSlideLayout().setTrackingEdge(ViewDragHelper.EDGE_RIGHT);
}
@Overridepublicvoidfinish() {
super.finish();
if (!slideManager.isSlideDisable()) {
overridePendingTransition(0, R.anim.slide_out_right);
}
}
// Optional, provide a custom SlideManager instance to SlideActivity.@NonNull@OverrideprotectedSlideManagerslideManagerProvider() {
returnnewSlideManager(this, newCustomAdapter(this));
}
}Totally disable the slide function, nothing inside SlideManager will be initialized, re-initialize is illegal either.
publicclassMainActivityextendsSlideActivityimplementsSlideManager.Conductor{
@OverridepublicbooleanisSlideBackDisabled() {
returnBuild.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT;
}
}To temporarily disable the slide action, or enable again whenever you want, see the method below.
slideManager comes from SlideActivity the super class you extended. What slideManager.getSlideLayout() returns is null if slide action has been totally disabled, see method mentioned above named isSlideBackDisabled() for more details.
publicclassMainActivityextendsSlideActivity {
@OverrideprotectedvoidonResume() {
super.onResume();
slideManager.getSlideLayout().setEnable(false);
}
}- Minimum Android SDK: SlideBack requires a minimum API level of 14.
- Compile Android SDK: SlideBack requires you to compile against API 28 or later.
- Both AndroidX and Android Support are supported by using different dependencies.
Copyright 2019 WenKang Tan(phantomVK)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
