-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wumeng1
authored and
wumeng1
committed
Jun 17, 2022
1 parent
7447814
commit 73be1fb
Showing
7 changed files
with
145 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 19 additions & 19 deletions
38
lib_base/src/main/java/com/mirkowu/lib_base/event/StateBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package com.mirkowu.lib_base.event; | ||
|
||
import java.io.Serializable; | ||
|
||
public class StateBean implements Serializable { | ||
private static final long serialVersionUID = 330324159087062791L; | ||
public int state; | ||
public int code; | ||
public String msg; | ||
|
||
public StateBean() { | ||
} | ||
|
||
public StateBean(int state, int code, String msg) { | ||
this.state = state; | ||
this.code = code; | ||
this.msg = msg; | ||
} | ||
} | ||
//package com.mirkowu.lib_base.event; | ||
// | ||
//import java.io.Serializable; | ||
// | ||
//public class StateBean implements Serializable { | ||
// private static final long serialVersionUID = 330324159087062791L; | ||
// public int state; | ||
// public int code; | ||
// public String msg; | ||
// | ||
// public StateBean() { | ||
// } | ||
// | ||
// public StateBean(int state, int code, String msg) { | ||
// this.state = state; | ||
// this.code = code; | ||
// this.msg = msg; | ||
// } | ||
//} |
226 changes: 113 additions & 113 deletions
226
lib_base/src/main/java/com/mirkowu/lib_base/event/UiChangeEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,127 @@ | ||
package com.mirkowu.lib_base.event; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.lifecycle.LifecycleOwner; | ||
import androidx.lifecycle.MutableLiveData; | ||
import androidx.lifecycle.Observer; | ||
|
||
import com.mirkowu.lib_base.view.IBaseView; | ||
|
||
public class UiChangeEvent { | ||
private SingleLiveEvent<Boolean> mIsShowLoadingDialogEvent; | ||
private SingleLiveEvent<Boolean> mIsEmptyViewEvent; | ||
private SingleLiveEvent<Boolean> mIsDismissViewEvent; | ||
private SingleLiveEvent<Boolean> mIsReloadViewEvent; | ||
private SingleLiveEvent<String> mJumpPathEvent; | ||
private SingleLiveEvent<Bundle> mJumpPathParamsEvent; | ||
private SingleLiveEvent<StateBean> mStateViewEvent; | ||
//显示 、隐藏 | ||
// private SingleLiveEvent<ApiException> mErrorEvent;//加载中、网络错误、服务器异常、(点击刷新)、空数据 | ||
|
||
public UiChangeEvent() { | ||
} | ||
|
||
public MutableLiveData<Boolean> getShowLoadingDialogEvent() { | ||
return this.mIsShowLoadingDialogEvent = this.getLiveData(this.mIsShowLoadingDialogEvent); | ||
} | ||
|
||
public MutableLiveData<StateBean> getStateViewEvent() { | ||
return this.mStateViewEvent = this.getLiveData(this.mStateViewEvent); | ||
} | ||
|
||
public MutableLiveData<Boolean> getEmptyViewEvent() { | ||
return this.mIsEmptyViewEvent = this.getLiveData(this.mIsEmptyViewEvent); | ||
} | ||
|
||
public MutableLiveData<Boolean> getDismissViewEvent() { | ||
return this.mIsDismissViewEvent = this.getLiveData(this.mIsDismissViewEvent); | ||
} | ||
|
||
public MutableLiveData<Boolean> getReloadViewEvent() { | ||
return this.mIsReloadViewEvent = this.getLiveData(this.mIsReloadViewEvent); | ||
} | ||
|
||
public MutableLiveData<String> getJumpPagePathEvent() { | ||
return this.mJumpPathEvent = this.getLiveData(this.mJumpPathEvent); | ||
} | ||
|
||
public MutableLiveData<Bundle> getJumpPageParamsEvent() { | ||
return this.mJumpPathParamsEvent = this.getLiveData(this.mJumpPathParamsEvent); | ||
} | ||
|
||
private <T> SingleLiveEvent<T> getLiveData(SingleLiveEvent<T> mutableLiveData) { | ||
if (mutableLiveData == null) { | ||
mutableLiveData = new SingleLiveEvent<>(); | ||
} | ||
|
||
return mutableLiveData; | ||
} | ||
|
||
public void unregisterEvent(@NonNull LifecycleOwner owner) { | ||
getShowLoadingDialogEvent().removeObservers(owner); | ||
getStateViewEvent().removeObservers(owner); | ||
} | ||
|
||
public void registerEvent(@NonNull LifecycleOwner owner, final IBaseView iBaseView) { | ||
getShowLoadingDialogEvent().observe(owner, new Observer<Boolean>() { | ||
public void onChanged(Boolean aBoolean) { | ||
if (aBoolean) { | ||
iBaseView.showLoadingDialog(); | ||
} else { | ||
iBaseView.hideLoadingDialog(); | ||
} | ||
} | ||
}); | ||
|
||
|
||
getStateViewEvent().observe(owner, new Observer<StateBean>() { | ||
public void onChanged(StateBean stateBean) { | ||
|
||
//stateBean.state== | ||
// iBaseView.showStateView(); | ||
|
||
|
||
} | ||
}); | ||
// getEmptyViewEvent().observe(owner, new Observer<Boolean>() { | ||
// public void onChanged(Boolean aBoolean) { | ||
// if (aBoolean) { | ||
// iBaseView.showEmptyView(); | ||
// } | ||
//package com.mirkowu.lib_base.event; | ||
// | ||
// } | ||
// }); | ||
//import android.os.Bundle; | ||
// | ||
//import androidx.annotation.NonNull; | ||
//import androidx.lifecycle.LifecycleOwner; | ||
//import androidx.lifecycle.MutableLiveData; | ||
//import androidx.lifecycle.Observer; | ||
// | ||
//import com.mirkowu.lib_base.view.IBaseView; | ||
// | ||
//public class UiChangeEvent { | ||
// private SingleLiveEvent<Boolean> mIsShowLoadingDialogEvent; | ||
// private SingleLiveEvent<Boolean> mIsEmptyViewEvent; | ||
// private SingleLiveEvent<Boolean> mIsDismissViewEvent; | ||
// private SingleLiveEvent<Boolean> mIsReloadViewEvent; | ||
// private SingleLiveEvent<String> mJumpPathEvent; | ||
// private SingleLiveEvent<Bundle> mJumpPathParamsEvent; | ||
// private SingleLiveEvent<StateBean> mStateViewEvent; | ||
// //显示 、隐藏 | ||
//// private SingleLiveEvent<ApiException> mErrorEvent;//加载中、网络错误、服务器异常、(点击刷新)、空数据 | ||
// | ||
// public UiChangeEvent() { | ||
// } | ||
// | ||
// public MutableLiveData<Boolean> getShowLoadingDialogEvent() { | ||
// return this.mIsShowLoadingDialogEvent = this.getLiveData(this.mIsShowLoadingDialogEvent); | ||
// } | ||
// | ||
// public MutableLiveData<StateBean> getStateViewEvent() { | ||
// return this.mStateViewEvent = this.getLiveData(this.mStateViewEvent); | ||
// } | ||
// | ||
// public MutableLiveData<Boolean> getEmptyViewEvent() { | ||
// return this.mIsEmptyViewEvent = this.getLiveData(this.mIsEmptyViewEvent); | ||
// } | ||
// | ||
// public MutableLiveData<Boolean> getDismissViewEvent() { | ||
// return this.mIsDismissViewEvent = this.getLiveData(this.mIsDismissViewEvent); | ||
// } | ||
// | ||
// getReloadViewEvent().observe(owner, new Observer<Boolean>() { | ||
// public MutableLiveData<Boolean> getReloadViewEvent() { | ||
// return this.mIsReloadViewEvent = this.getLiveData(this.mIsReloadViewEvent); | ||
// } | ||
// | ||
// public MutableLiveData<String> getJumpPagePathEvent() { | ||
// return this.mJumpPathEvent = this.getLiveData(this.mJumpPathEvent); | ||
// } | ||
// | ||
// public MutableLiveData<Bundle> getJumpPageParamsEvent() { | ||
// return this.mJumpPathParamsEvent = this.getLiveData(this.mJumpPathParamsEvent); | ||
// } | ||
// | ||
// private <T> SingleLiveEvent<T> getLiveData(SingleLiveEvent<T> mutableLiveData) { | ||
// if (mutableLiveData == null) { | ||
// mutableLiveData = new SingleLiveEvent<>(); | ||
// } | ||
// | ||
// return mutableLiveData; | ||
// } | ||
// | ||
// public void unregisterEvent(@NonNull LifecycleOwner owner) { | ||
// getShowLoadingDialogEvent().removeObservers(owner); | ||
// getStateViewEvent().removeObservers(owner); | ||
// } | ||
// | ||
// public void registerEvent(@NonNull LifecycleOwner owner, final IBaseView iBaseView) { | ||
// getShowLoadingDialogEvent().observe(owner, new Observer<Boolean>() { | ||
// public void onChanged(Boolean aBoolean) { | ||
// if (aBoolean) { | ||
// iBaseView.showReloadView(); | ||
// iBaseView.showLoadingDialog(); | ||
// } else { | ||
// iBaseView.hideLoadingDialog(); | ||
// } | ||
// | ||
// } | ||
// }); | ||
// | ||
// getJumpPagePathEvent().observe(owner, new Observer<String>() { | ||
// public void onChanged(String path) { | ||
// iBaseView.jumpPage(path); | ||
// } | ||
// }); | ||
// | ||
// getStateViewEvent().observe(owner, new Observer<StateBean>() { | ||
// public void onChanged(StateBean stateBean) { | ||
// | ||
// //stateBean.state== | ||
// // iBaseView.showStateView(); | ||
// | ||
// getJumpPageParamsEvent().observe(owner, new Observer<Bundle>() { | ||
// public void onChanged(Bundle paramsMap) { | ||
// if (paramsMap.containsKey("JUMP_PAGE_PATH_KEY")) { | ||
// String path = paramsMap.getString("JUMP_PAGE_PATH_KEY"); | ||
// if (!TextUtils.isEmpty(path)) { | ||
// paramsMap.remove("JUMP_PAGE_PATH_KEY"); | ||
// iBaseView.jumpPage(path, paramsMap); | ||
// } | ||
// } | ||
// | ||
// } | ||
// }); | ||
} | ||
} | ||
//// getEmptyViewEvent().observe(owner, new Observer<Boolean>() { | ||
//// public void onChanged(Boolean aBoolean) { | ||
//// if (aBoolean) { | ||
//// iBaseView.showEmptyView(); | ||
//// } | ||
//// | ||
//// } | ||
//// }); | ||
//// | ||
//// | ||
//// getReloadViewEvent().observe(owner, new Observer<Boolean>() { | ||
//// public void onChanged(Boolean aBoolean) { | ||
//// if (aBoolean) { | ||
//// iBaseView.showReloadView(); | ||
//// } | ||
//// | ||
//// } | ||
//// }); | ||
//// | ||
//// getJumpPagePathEvent().observe(owner, new Observer<String>() { | ||
//// public void onChanged(String path) { | ||
//// iBaseView.jumpPage(path); | ||
//// } | ||
//// }); | ||
//// | ||
//// | ||
//// getJumpPageParamsEvent().observe(owner, new Observer<Bundle>() { | ||
//// public void onChanged(Bundle paramsMap) { | ||
//// if (paramsMap.containsKey("JUMP_PAGE_PATH_KEY")) { | ||
//// String path = paramsMap.getString("JUMP_PAGE_PATH_KEY"); | ||
//// if (!TextUtils.isEmpty(path)) { | ||
//// paramsMap.remove("JUMP_PAGE_PATH_KEY"); | ||
//// iBaseView.jumpPage(path, paramsMap); | ||
//// } | ||
//// } | ||
//// | ||
//// } | ||
//// }); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters