|
16 | 16 | import android.support.v7.app.AppCompatActivity; |
17 | 17 | import android.view.LayoutInflater; |
18 | 18 | import android.view.View; |
| 19 | +import android.view.ViewGroup; |
19 | 20 |
|
| 21 | +import com.blankj.lib.base.slideBack.SlideBackLayout; |
20 | 22 | import com.blankj.utilcode.util.AntiShakeUtils; |
21 | 23 | import com.blankj.utilcode.util.AppUtils; |
22 | 24 | import com.blankj.utilcode.util.ToastUtils; |
23 | 25 | import com.blankj.utilcode.util.Utils; |
24 | | -import com.r0adkll.slidr.Slidr; |
25 | 26 |
|
26 | 27 | /** |
27 | 28 | * <pre> |
@@ -53,10 +54,8 @@ protected void onCreate(Bundle savedInstanceState) { |
53 | 54 | findViewById(android.R.id.content).setBackgroundColor(getResources().getColor(R.color.mediumGray)); |
54 | 55 | initView(savedInstanceState, mContentView); |
55 | 56 | doBusiness(); |
| 57 | + initSwipeBack(); |
56 | 58 |
|
57 | | - if (isSwipeBack()) { |
58 | | - Slidr.attach(this); |
59 | | - } |
60 | 59 | AppUtils.registerAppStatusChangedListener(this, new Utils.OnAppStatusChangedListener() { |
61 | 60 | @Override |
62 | 61 | public void onForeground() { |
@@ -89,5 +88,29 @@ protected void onDestroy() { |
89 | 88 | super.onDestroy(); |
90 | 89 | AppUtils.unregisterAppStatusChangedListener(this); |
91 | 90 | } |
| 91 | + |
| 92 | + private void initSwipeBack() { |
| 93 | + if (isSwipeBack()) { |
| 94 | + SlideBackLayout slideBackLayout = new SlideBackLayout(this); |
| 95 | + |
| 96 | + ViewGroup decorView = (ViewGroup) getWindow().getDecorView(); |
| 97 | + View oldScreen = decorView.getChildAt(0); |
| 98 | + decorView.removeViewAt(0); |
| 99 | + |
| 100 | + slideBackLayout.addView(oldScreen); |
| 101 | + decorView.addView(slideBackLayout, 0); |
| 102 | + slideBackLayout.setSwipeBackListener(new SlideBackLayout.OnSwipeBackListener() { |
| 103 | + @Override |
| 104 | + public void completeSwipeBack() { |
| 105 | +// finish(); |
| 106 | + ToastUtils.showLong("haha"); |
| 107 | + } |
| 108 | + }); |
| 109 | + |
| 110 | + |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + |
92 | 115 | } |
93 | 116 |
|
0 commit comments