optimize multi status layout

androidx
Zhanty 5 years ago
parent 1a34c1c7e3
commit a9c0fe36b5
  1. 7
      lib_base/src/main/java/com/android/base/app/fragment/BaseFragment.java
  2. 1
      lib_base/src/main/java/com/android/base/app/fragment/BaseListV2Fragment.kt
  3. 9
      lib_base/src/main/java/com/android/base/app/fragment/BaseStateDialogFragment.java
  4. 7
      lib_base/src/main/java/com/android/base/app/fragment/BaseStateFragment.java
  5. 1
      lib_base/src/main/java/com/android/base/app/fragment/RefreshLoadMoreStateLayoutImpl.kt
  6. 5
      lib_base/src/main/java/com/android/base/app/fragment/RefreshableStateLayoutImpl.java
  7. 4
      lib_base/src/main/java/com/android/base/app/ui/StateLayout.java
  8. 1
      lib_base/src/main/java/com/android/base/app/ui/StateLayoutConfig.java
  9. 14
      lib_base/src/main/java/com/android/base/kotlin/DialogEx.kt
  10. 6
      lib_base/src/main/java/com/android/base/widget/SimpleMultiStateView.java
  11. 3
      lib_base/src/main/java/com/android/base/widget/StateActionProcessor.java

@ -245,12 +245,19 @@ public class BaseFragment extends Fragment implements LoadingView, OnBackPressLi
}
private LoadingView getLoadingViewImpl() {
if (mLoadingViewImpl == null) {
mLoadingViewImpl = onCreateLoadingView();
}
if (mLoadingViewImpl == null) {
mLoadingViewImpl = BaseKit.get().getLoadingViewFactory().createLoadingDelegate(getContext());
}
return mLoadingViewImpl;
}
protected LoadingView onCreateLoadingView() {
return null;
}
@Override
public void showLoadingDialog() {
getLoadingViewImpl().showLoadingDialog(true);

@ -98,5 +98,6 @@ abstract class BaseListV2Fragment<T> : BaseFragment(), RefreshListLayout<T> {
override fun showNetErrorLayout() = stateLayout.showNetErrorLayout()
override fun showServerErrorLayout() = stateLayout.showServerErrorLayout()
override fun isLoadingMore() = stateLayout.refreshView.isLoadingMore
override fun currentStatus() = stateLayout.currentStatus()
}

@ -59,7 +59,7 @@ public abstract class BaseStateDialogFragment extends BaseDialogFragment impleme
return mStateLayout.getRefreshView();
}
protected void onRetry(int state) {
protected void onRetry(@StateLayoutConfig.RetryableState int state) {
if (getRefreshView() != null) {
if (!getRefreshView().isRefreshing()) {
autoRefresh();
@ -142,4 +142,9 @@ public abstract class BaseStateDialogFragment extends BaseDialogFragment impleme
getStateLayout().showServerErrorLayout();
}
}
@Override
public int currentStatus() {
return mStateLayout.currentStatus();
}
}

@ -65,7 +65,7 @@ public abstract class BaseStateFragment extends BaseFragment implements RefreshS
return mStateLayout.getRefreshView();
}
protected void onRetry(int state) {
protected void onRetry(@StateLayoutConfig.RetryableState int state) {
if (getRefreshView() != null) {
if (!getRefreshView().isRefreshing()) {
autoRefresh();
@ -149,4 +149,9 @@ public abstract class BaseStateFragment extends BaseFragment implements RefreshS
getStateLayout().showServerErrorLayout();
}
@Override
public int currentStatus() {
return mStateLayout.currentStatus();
}
}

@ -34,6 +34,7 @@ internal class RefreshLoadMoreStateLayoutImpl private constructor(layout: View)
override fun showBlank() = checkMultiStateView().showBlank()
override fun showNetErrorLayout() = checkMultiStateView().showNetErrorLayout()
override fun showServerErrorLayout() = checkMultiStateView().showServerErrorLayout()
override fun currentStatus() = checkMultiStateView().currentStatus()
override fun getStateLayoutConfig(): StateLayoutConfig = checkMultiStateView().stateLayoutConfig

@ -129,6 +129,11 @@ final class RefreshableStateLayoutImpl implements RefreshStateLayout, StateLayou
return this;
}
@Override
public int currentStatus() {
return mMultiStateView.currentStatus();
}
@Override
public void refreshCompleted() {
if (mRefreshView != null) {

@ -24,4 +24,8 @@ public interface StateLayout {
void showServerErrorLayout();
StateLayoutConfig getStateLayoutConfig();
@StateLayoutConfig.ViewState
int currentStatus();
}

@ -29,6 +29,7 @@ public interface StateLayoutConfig {
EMPTY,
ERROR,
NET_ERROR,
SERVER_ERROR,
})
@Retention(RetentionPolicy.SOURCE)
@interface RetryableState {

@ -2,12 +2,14 @@ package com.android.base.kotlin
import android.app.Dialog
/**
*@author Ztiany
* Email: ztiany3@gmail.com
* Date : 2019-03-04 10:46
*/
fun Dialog.noCancelable(): Dialog {
fun Dialog.notCancelable(): Dialog {
this.setCancelable(false)
return this
}
fun Dialog.onDismiss(action: () -> Unit): Dialog {
setOnDismissListener {
action()
}
return this
}

@ -142,4 +142,10 @@ public class SimpleMultiStateView extends MultiStateView implements StateLayout
return mStateProcessor.getStateLayoutConfigImpl();
}
@Override
@ViewState
public int currentStatus() {
return getViewState();
}
}

@ -6,6 +6,7 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@ -102,7 +103,7 @@ public class StateActionProcessor extends StateProcessor {
private final int mState;
private Drawable mDrawable;
private CharSequence mMessage;
private int mMessageGravity;
private int mMessageGravity = Gravity.CENTER;
private CharSequence mActionText;
private View mStateView;
private TextView mMessageTv;

Loading…
Cancel
Save