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..2c59af2622 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 @@ -33,6 +33,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba private RecyclerView recyclerView; private V2XShareEventAdapter adapter; private ArrayList dataArrayList = new ArrayList(); + ; private int pageNum = 1; private V2XShareNetworkModel v2XShareNetworkModel; @@ -66,10 +67,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 +78,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba * 获取热心指数,分享列表等分享内容 * */ private void getShareEventResponse() { - if (CheckUtils.isNetworkConnected(getContext()) == false) { - Log.d(TAG, "网络异常"); - } + v2XShareNetworkModel.getShareEventResponse(pageNum, 10, new V2XRefreshCallback() { @Override public void onSuccess(Object result) { @@ -98,10 +97,15 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba @Override public void onFail(String msg) { - + loadingView.stopWithError(msg); + loadingView.refresButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getShareEventResponse(); + } + }); } - }); } @@ -110,6 +114,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 +151,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/utils/animation/V2XAnimationManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java index ad0c6401ca..c77bea6db8 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/animation/V2XAnimationManager.java @@ -50,6 +50,13 @@ public class V2XAnimationManager implements Animation { } } + public void soptWithError(){ + if (delegate != null && isStarted) { + isStarted = false; + delegate.stop(); + } + } + public void release() { delegate = null; } 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..b8c1e9beea 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,8 @@ public class V2XNetworkLoadingView extends RelativeLayout { private ImageView loadView; private TextView textView; private V2XAnimationManager v2XAnimationManager; - + public Button refresButton; + private String loadingText = "正在获取信息…"; public V2XNetworkLoadingView(Context context) { @@ -39,6 +43,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 +61,12 @@ public class V2XNetworkLoadingView extends RelativeLayout { v2XAnimationManager.start(); this.setVisibility(View.VISIBLE); } + if (refresButton != null) { + refresButton.setVisibility(GONE); + } + if (textView != null) { + textView.setText(loadingText); + } } public void stop() { @@ -65,5 +76,18 @@ public class V2XNetworkLoadingView extends RelativeLayout { } } + public void stopWithError(String errormsg) { + if (v2XAnimationManager != null) { + v2XAnimationManager.soptWithError(); + } + 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" />