package me.yokeyword.fragmentation_swipeback;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;

import me.yokeyword.fragmentation.SupportFragment;
import me.yokeyword.fragmentation.SwipeBackLayout;

/**
 * SwipeBackFragment
 * Created by YoKeyword on 16/4/19.
 */
public class SwipeBackFragment extends SupportFragment {
    private SwipeBackLayout mSwipeBackLayout;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        onFragmentCreate();
    }

    private void onFragmentCreate() {
        mSwipeBackLayout = new SwipeBackLayout(_mActivity);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        mSwipeBackLayout.setLayoutParams(params);
        mSwipeBackLayout.setBackgroundColor(Color.TRANSPARENT);
    }

    protected View attachToSwipeBack(View view) {
        mSwipeBackLayout.attachToFragment(this,view);
        return mSwipeBackLayout;
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden && mSwipeBackLayout != null) {
            mSwipeBackLayout.hiddenFragment();
        }
    }

    @Override
    protected void initFragmentBackground(View view) {
        if (!(view instanceof SwipeBackLayout) && view != null && view.getBackground() == null) {
            int background = getWindowBackground();
            view.setBackgroundResource(background);
        } else {
            if (view instanceof SwipeBackLayout) {
                View childView = ((SwipeBackLayout) view).getChildAt(0);
                if (childView != null && childView.getBackground() == null) {
                    int background = getWindowBackground();
                    childView.setBackgroundResource(background);
                }
            }
        }
    }

    public SwipeBackLayout getSwipeBackLayout() {
        return mSwipeBackLayout;
    }

    public void setSwipeBackEnable(boolean enable) {
        mSwipeBackLayout.setEnableGesture(enable);
    }
}

@@ -1087,16 +1087,17 @@
 nt(this,
+ 
 view);%0A 
@@ -1436,10 +1436,8 @@
  if 
-(!
 (vie
@@ -1470,439 +1470,114 @@
 ut) 
-&& view != null && view.getBackground() == null) %7B%0A            int background = getWindowBackground();%0A            view.setBackgroundResource(background);%0A        %7D else %7B%0A            if (view instanceof SwipeBackLayout) %7B%0A                View childView = ((SwipeBackLayout) view).getChildAt(0);%0A                if (childView != null && childView.getBackground() == null) %7B%0A                    int background = getWindowBackground(
+%7B%0A            View childView = ((SwipeBackLayout) view).getChildAt(0);%0A            setBackground(childView
 );%0A 
@@ -1575,33 +1575,41 @@
 dView);%0A        
- 
+%7D else %7B%0A
            child
@@ -1607,18 +1607,9 @@
     
-childView.
+ 
 setB
@@ -1621,61 +1621,15 @@
 ound
-Resource(background);%0A                %7D%0A            %7D
+(view);
 %0A   

Add setDefaultFragmentBackground(int res) to Activity, which is used to change the background of the Fragments