This commit is contained in:
wangcongtao
2020-01-08 15:13:56 +08:00
parent 420098c704
commit ad03c651f2
18 changed files with 239 additions and 108 deletions

View File

@@ -0,0 +1,63 @@
package com.mogo.service.fragmentmanager;
import androidx.fragment.app.Fragment;
/**
* @author congtaowang
* @since 2020-01-08
* <p>
* 加入栈中的fragment
*/
public class FragmentDescriptor {
private Fragment mFragment;
private String mTag;
/**
* 是否需要主页面的UI联动
*/
private boolean mNotifyMainModule = true;
public FragmentDescriptor() {
}
public Fragment getFragment() {
return mFragment;
}
public String getTag() {
return mTag;
}
public boolean isNotifyMainModule() {
return mNotifyMainModule;
}
public static class Builder {
private FragmentDescriptor descriptor;
public Builder() {
descriptor = new FragmentDescriptor();
}
public Builder fragment( Fragment fragment ) {
descriptor.mFragment = fragment;
return this;
}
public Builder tag( String tag ) {
descriptor.mTag = tag;
return this;
}
public Builder notifyMainModule( boolean notify ) {
descriptor.mNotifyMainModule = notify;
return this;
}
public FragmentDescriptor build() {
return descriptor;
}
}
}

View File

@@ -15,10 +15,9 @@ public interface IMogoFragmentManager extends IProvider {
/**
* 显示fragment并加入回退栈
*
* @param fragment 需要显示的fragment
* @param tag fragment的tag
* @param descriptor fragment描述
*/
void push( Fragment fragment, String tag );
void push( FragmentDescriptor descriptor );
/**
* 将当前 fragment 出栈