error界面
This commit is contained in:
@@ -32,7 +32,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
private static final String TAG = "ShareEventsFragment";
|
||||
private RecyclerView recyclerView;
|
||||
private V2XShareEventAdapter adapter;
|
||||
private ArrayList dataArrayList = new ArrayList();
|
||||
private ArrayList dataArrayList;
|
||||
private int pageNum = 1;
|
||||
private V2XShareNetworkModel v2XShareNetworkModel;
|
||||
|
||||
@@ -66,10 +66,10 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
loadingView = mRootView.findViewById(R.id.network_loading_imageview);
|
||||
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
loadingView.start();
|
||||
getShareEventResponse();
|
||||
}
|
||||
|
||||
@@ -77,9 +77,20 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
* 获取热心指数,分享列表等分享内容
|
||||
* */
|
||||
private void getShareEventResponse() {
|
||||
if (CheckUtils.isNetworkConnected(getContext()) == false) {
|
||||
Log.d(TAG, "网络异常");
|
||||
}
|
||||
animatioonAcction(View.VISIBLE);
|
||||
dataArrayList = new ArrayList();
|
||||
|
||||
// if (CheckUtils.isNetworkConnected(getContext()) == false) {
|
||||
// loadingView.networkError("获取失败");
|
||||
// loadingView.refresButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// getShareEventResponse();
|
||||
// }
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
v2XShareNetworkModel.getShareEventResponse(pageNum, 10, new V2XRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
@@ -110,6 +121,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
* 我的分享列表数据处理
|
||||
* */
|
||||
private void loadSuccessWithShareEventList(Object result) {
|
||||
animatioonAcction(View.GONE);
|
||||
V2XShareEventItem resultData = (V2XShareEventItem) result;
|
||||
V2XShareEventLoadMoreItem item = new V2XShareEventLoadMoreItem();
|
||||
if (resultData != null && resultData.getResult() != null) {
|
||||
@@ -146,7 +158,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
dataArrayList.add(item);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
animatioonAcction(View.INVISIBLE);
|
||||
|
||||
}
|
||||
|
||||
private void animatioonAcction(int visible) {
|
||||
|
||||
@@ -4,10 +4,13 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.utils.animation.AnimationResources;
|
||||
import com.mogo.module.v2x.utils.animation.V2XAnimationManager;
|
||||
@@ -17,7 +20,7 @@ public class V2XNetworkLoadingView extends RelativeLayout {
|
||||
private ImageView loadView;
|
||||
private TextView textView;
|
||||
private V2XAnimationManager v2XAnimationManager;
|
||||
|
||||
public Button refresButton;
|
||||
|
||||
public V2XNetworkLoadingView(Context context) {
|
||||
|
||||
@@ -39,6 +42,7 @@ public class V2XNetworkLoadingView extends RelativeLayout {
|
||||
v2XAnimationManager = new V2XAnimationManager();
|
||||
loadView = findViewById(R.id.loading_imageview);
|
||||
textView = findViewById(R.id.loading_text);
|
||||
refresButton = findViewById(R.id.refresh_button);
|
||||
}
|
||||
|
||||
public void setLoadingText(String text) {
|
||||
@@ -56,6 +60,9 @@ public class V2XNetworkLoadingView extends RelativeLayout {
|
||||
v2XAnimationManager.start();
|
||||
this.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (refresButton != null) {
|
||||
refresButton.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -65,5 +72,18 @@ public class V2XNetworkLoadingView extends RelativeLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void networkError(String errormsg) {
|
||||
if (v2XAnimationManager != null) {
|
||||
v2XAnimationManager.stop();
|
||||
}
|
||||
if (textView != null) {
|
||||
textView.setText(errormsg);
|
||||
}
|
||||
if (refresButton != null) {
|
||||
refresButton.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user