From b25eec44f7e98e8c0bd3ff72c332dcc0fe728e2a Mon Sep 17 00:00:00 2001 From: liujing Date: Thu, 13 Aug 2020 18:05:32 +0800 Subject: [PATCH] =?UTF-8?q?error=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2x/fragment/V2XShareEventsFragment.java | 24 ++++++--- .../v2x/view/V2XNetworkLoadingView.java | 22 +++++++- .../layout/module_v2x_event_share_empty.xml | 4 +- .../module_v2x_event_share_recylerview.xml | 23 +++++---- .../res/layout/v2x_network_loading_item.xml | 51 +++++++++++-------- 5 files changed, 82 insertions(+), 42 deletions(-) diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java index 6b4f575100..a623c41835 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/fragment/V2XShareEventsFragment.java @@ -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) { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java index 40714ec11e..99712f12bd 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XNetworkLoadingView.java @@ -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); + } + + } + } diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_share_empty.xml b/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_share_empty.xml index 952d4503e3..9ab5722748 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_share_empty.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/module_v2x_event_share_empty.xml @@ -20,10 +20,10 @@ android:layout_centerHorizontal="true" android:gravity="bottom" android:alpha="0.7" - android:textColor="#FFFFFF" android:layout_marginTop="12.6px" android:textSize="18px" - android:text="你还没有分享过道路事件,快去试试吧" /> + android:text="你还没有分享过道路事件,快去试试吧" + android:textColor="#FFFFFF" />