Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the layout when onStart(), ensuring that View will not be added repeatedly when PIP mode is turned on #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -474,6 +474,15 @@ public void attachToActivity(Activity activity) {
decor.addView(this);
}

public void detachFromActivity(Activity activity) {
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
decorView.removeView(this);
View decorChild = getChildAt(0);
removeView(decorChild);
decorView.addView(decorChild,0);
setContentView(decorChild);
}

@Override
public void computeScroll() {
mScrimOpacity = 1 - mScrollPercent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package me.imid.swipebacklayout.lib.app;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

Expand All @@ -22,10 +21,19 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mHelper.onPostCreate();
}

@Override
@Override protected void onStart() {
super.onStart();
mHelper.onPostCreate();
}

@Override protected void onStop() {
super.onStop();
mHelper.onStop();
}

@Override
public View findViewById(int id) {
View v = super.findViewById(id);
if (v == null && mHelper != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public void onPostCreate() {
mSwipeBackLayout.attachToActivity(mActivity);
}

public void onStop() {
mSwipeBackLayout.detachFromActivity(mActivity);
}

public View findViewById(int id) {
if (mSwipeBackLayout != null) {
return mSwipeBackLayout.findViewById(id);
Expand Down