File tree Expand file tree Collapse file tree
library/src/main/java/me/imid/swipebacklayout/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -474,6 +474,15 @@ public void attachToActivity(Activity activity) {
474474 decor .addView (this );
475475 }
476476
477+ public void detachFromActivity (Activity activity ) {
478+ ViewGroup decorView = (ViewGroup ) activity .getWindow ().getDecorView ();
479+ decorView .removeView (this );
480+ View decorChild = getChildAt (0 );
481+ removeView (decorChild );
482+ decorView .addView (decorChild ,0 );
483+ setContentView (decorChild );
484+ }
485+
477486 @ Override
478487 public void computeScroll () {
479488 mScrimOpacity = 1 - mScrollPercent ;
Original file line number Diff line number Diff line change 22package me .imid .swipebacklayout .lib .app ;
33
44import android .os .Bundle ;
5- import android .support .v4 .app .FragmentActivity ;
65import android .support .v7 .app .AppCompatActivity ;
76import android .view .View ;
87
@@ -22,10 +21,19 @@ protected void onCreate(Bundle savedInstanceState) {
2221 @ Override
2322 protected void onPostCreate (Bundle savedInstanceState ) {
2423 super .onPostCreate (savedInstanceState );
25- mHelper .onPostCreate ();
2624 }
2725
28- @ Override
26+ @ Override protected void onStart () {
27+ super .onStart ();
28+ mHelper .onPostCreate ();
29+ }
30+
31+ @ Override protected void onStop () {
32+ super .onStop ();
33+ mHelper .onStop ();
34+ }
35+
36+ @ Override
2937 public View findViewById (int id ) {
3038 View v = super .findViewById (id );
3139 if (v == null && mHelper != null )
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ public void onPostCreate() {
3333 mSwipeBackLayout .attachToActivity (mActivity );
3434 }
3535
36+ public void onStop () {
37+ mSwipeBackLayout .detachFromActivity (mActivity );
38+ }
39+
3640 public View findViewById (int id ) {
3741 if (mSwipeBackLayout != null ) {
3842 return mSwipeBackLayout .findViewById (id );
You can’t perform that action at this time.
0 commit comments