Skip to content

Commit

Permalink
修复已知bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liang02.wang committed Jan 7, 2020
1 parent 3fe045f commit c17ae00
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 108 additions & 1 deletion core/src/main/java/me/liam/support/SupportActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
return super.dispatchTouchEvent(ev);
}

/**
* 获取默认的Fragment背景颜色
* @return
*/
@Override
public int getDefaultBackground() {
return Color.WHITE;
}

/**
* 设置全局默认动画
* @param animation
*/
@Override
public void setDefaultAnimation(FragmentAnimation animation) {
defaultAnimation = animation;
Expand All @@ -70,11 +78,22 @@ public FragmentAnimation getDefaultAnimation() {
return defaultAnimation;
}

/**
* 在栈内查找Fragment对象,如果一个栈内存在多个同一个class的Fragment对象,则返回结果可能不准确
* @param cls
* @param <T>
* @return
*/
@Override
public <T extends SupportFragment> T findFragmentByClass(Class cls) {
return FragmentUtils.findFragmentByClass(getSupportFragmentManager(),cls);
}

/**
* 发送一条消息到当前所有的Fragment
* @param code
* @param data
*/
@Override
public void postDataToFragments(int code, Bundle data) {
List<SupportFragment> fragmentList = new ArrayList<>();
Expand All @@ -84,92 +103,180 @@ public void postDataToFragments(int code, Bundle data) {
}
}

/**
* 加载第一个Fragment
* @param containerId
* @param to
* @param anim
* @param playEnterAnim
* @param addToBackStack
*/
@Override
public void loadRootFragment(int containerId, SupportFragment to, FragmentAnimation anim, boolean playEnterAnim,boolean addToBackStack) {
supportTransaction.loadRootFragment(getSupportFragmentManager(),containerId,to,anim,playEnterAnim,addToBackStack);
}

/**
* 加载第一个Fragment
* @param containerId
* @param to
*/
@Override
public void loadRootFragment(int containerId, SupportFragment to) {
supportTransaction.loadRootFragment(getSupportFragmentManager(),containerId,to,getDefaultAnimation(),false,true);
}

/**
* 加载多个Fragment
* @param containerId
* @param showPosition
* @param fragments
*/
@Override
public void loadMultipleRootFragments(int containerId, int showPosition, SupportFragment... fragments) {
supportTransaction.loadMultipleRootFragments(getSupportFragmentManager(),containerId,showPosition,fragments);
}

/**
* 显示一个Fragment,并隐藏当前Child Fragment Manager 栈内的其它Fragment
* @param show
*/
@Override
public void showHideAllFragment(SupportFragment show) {
supportTransaction.showHideAllFragment(getSupportFragmentManager(), show);
}

/**
* 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
* @param to
*/
@Override
public void start(SupportFragment to) {
supportTransaction.start(FragmentUtils.getLastFragment(getSupportFragmentManager()),to,true);
}

/**
* 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
* @param to
* @param addToBackStack
*/
@Override
public void start(SupportFragment to, boolean addToBackStack) {
supportTransaction.start(FragmentUtils.getLastFragment(getSupportFragmentManager()),to,addToBackStack);
}

/**
* 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
* @param from
* @param to
*/
@Override
public void start(SupportFragment from, SupportFragment to) {
supportTransaction.start(from,to,true);
}

/**
* 启动一个新的Fragment,栈内必须有至少1个Fragment才可以使用此方法
* @param from
* @param to
* @param addToBackStack
*/
@Override
public void start(SupportFragment from, SupportFragment to, boolean addToBackStack) {
supportTransaction.start(from,to,addToBackStack);
}

/**
* 启动一个新的Fragment并关闭当前Fragment
* @param to
*/
@Override
public void startWithPop(SupportFragment to) {
supportTransaction.startWithPop(FragmentUtils.getLastFragment(getSupportFragmentManager()), to);
}

/**
* 启动一个新的Fragment并关闭当前Fragment
* @param from
* @param to
*/
@Override
public void startWithPop(SupportFragment from, SupportFragment to) {
supportTransaction.startWithPop(from, to);
}

/**
* 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
* @param to
* @param cls
*/
@Override
public void startWithPopTo(SupportFragment to, Class cls) {
supportTransaction.startWithPopTo(FragmentUtils.getLastFragment(getSupportFragmentManager()),to,cls,true);
}

/**
* 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
* @param to
* @param cls
* @param includeTarget
*/
@Override
public void startWithPopTo(SupportFragment to, Class cls, boolean includeTarget) {
supportTransaction.startWithPopTo(FragmentUtils.getLastFragment(getSupportFragmentManager()),to,cls,includeTarget);
}

/**
* 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
* @param from
* @param to
* @param cls
*/
@Override
public void startWithPopTo(SupportFragment from, SupportFragment to, Class cls) {
supportTransaction.startWithPopTo(from,to,cls,true);
}

/**
* 启动一个新的Fragment,并弹出栈内的Fragment到指定位置
* @param from
* @param to
* @param cls
* @param includeTarget
*/
@Override
public void startWithPopTo(SupportFragment from, SupportFragment to, Class cls, boolean includeTarget) {
supportTransaction.startWithPopTo(from,to,cls,includeTarget);
}

/**
* 弹出栈内最后一个Fragment
*/
@Override
public void pop() {
supportTransaction.pop(getSupportFragmentManager());
}

/**
* 弹出栈内的Fragment到指定位置
* @param cls
*/
@Override
public void popTo(Class cls) {
supportTransaction.popTo(getSupportFragmentManager(),cls,true);
}

/**
* 弹出栈内的Fragment到指定位置
* @param cls
* @param includeTarget
*/
@Override
public void popTo(Class cls, boolean includeTarget) {
supportTransaction.popTo(getSupportFragmentManager(),cls,includeTarget);
}

public SupportTransaction getSupportTransaction() {
SupportTransaction getSupportTransaction() {
return supportTransaction;
}
}
Loading

0 comments on commit c17ae00

Please sign in to comment.