package me.yokeyword.swipebackfragment.sample;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.Toast;

import me.yokeyword.swipebackfragment.SwipeBackActivity;
import me.yokeyword.swipebackfragment.sample.fragment.FirstSwipeBackFragment;

public class MainActivity extends SwipeBackActivity implements BaseSwipeBackFragment.OnAddFragmentListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            FirstSwipeBackFragment firstFragment = FirstSwipeBackFragment.newInstance();
            loadFragment(firstFragment);
        } else {
            Toast.makeText(MainActivity.this, "啊哦,app被强杀喽~", Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void onBackPressed() {
        if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
            finish();
        } else {
            super.onBackPressed();
        }
    }

    private void addFragment(Fragment fromFragment, Fragment toFragment) {
        getSupportFragmentManager().beginTransaction()
                .setCustomAnimations(R.anim.h_fragment_enter, R.anim.h_fragment_exit, R.anim.h_fragment_pop_enter, R.anim.h_fragment_pop_exit)
                .add(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
                .hide(fromFragment)
                .addToBackStack(toFragment.getClass().getSimpleName())
                .commit();
    }

    private void loadFragment(Fragment toFragment) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fl_container, toFragment, toFragment.getClass().getSimpleName())
                .addToBackStack(toFragment.getClass().getSimpleName())
                .commit();
    }

    @Override
    public void onAddFragment(Fragment fromFragment, Fragment toFragment) {
        addFragment(fromFragment, toFragment);
    }
}

@@ -833,32 +833,301 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * %E9%99%90%E5%88%B6SwipeBack%E7%9A%84%E6%9D%A1%E4%BB%B6,%E9%BB%98%E8%AE%A4%E6%A0%88%E5%86%85Fragment%E6%95%B0 %3C= 1%E6%97%B6 , %E4%BC%98%E5%85%88%E6%BB%91%E5%8A%A8%E9%80%80%E5%87%BAActivity , %E8%80%8C%E4%B8%8D%E6%98%AFFragment%0A     *%0A     * @return true: Activity%E5%8F%AF%E4%BB%A5%E6%BB%91%E5%8A%A8%E9%80%80%E5%87%BA, %E5%B9%B6%E4%B8%94%E6%80%BB%E6%98%AF%E4%BC%98%E5%85%88;  false: Activity%E4%B8%8D%E5%85%81%E8%AE%B8%E6%BB%91%E5%8A%A8%E9%80%80%E5%87%BA%0A     */%0A    @Override%0A    public boolean swipeBackPriority() %7B%0A        return super.swipeBackPriority();%0A    %7D%0A%0A
     @Override%0A  

Update demo