From 47bd94a1157e9d42f2c4bbc79b857f47642ee90f Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Tue, 4 Aug 2020 18:47:59 +0800 Subject: [PATCH] opt --- .../v2x/adapter/SurroundingEventAdapter.java | 32 ++++-- .../fragment/SurroundingEventFragment.java | 67 ++++++++++--- ...odule_event_panel_fragment_surrounding.xml | 99 +++++++++++++++++++ ...event_panel_fragment_surrounding_event.xml | 17 ---- ...module_fragment_surrounding_event_item.xml | 32 ++++++ .../src/main/res/values/color.xml | 1 + 6 files changed, 207 insertions(+), 41 deletions(-) create mode 100644 modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding.xml delete mode 100644 modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding_event.xml create mode 100644 modules/mogo-module-v2x/src/main/res/layout/module_fragment_surrounding_event_item.xml diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java index fded6a7d32..3da4f2f19f 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/adapter/SurroundingEventAdapter.java @@ -1,21 +1,34 @@ package com.mogo.module.v2x.adapter; import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.amap.api.maps.model.Text; +import com.mogo.module.v2x.R; +import com.mogo.module.v2x.entity.panel.SurroundingResponse; + +import java.util.List; + /** * @author lixiaopeng * @description 周边 * @since 2020/7/29 */ public class SurroundingEventAdapter extends RecyclerView.Adapter{ + private List mPoiInfosList; + private Context mContext; + private TextView mAddressTv; - //TODO 数据 - public SurroundingEventAdapter(Context context) { + public SurroundingEventAdapter(Context context, List poiInfosList) { + mContext = context; + mPoiInfosList = poiInfosList; } @Override @@ -26,21 +39,24 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter implements SurroundingEventView { - - private static final String TAG = "SurroundingEventFragment"; - private RecyclerView recyclerView; - private View view; + private static final String TAG = "SurroundingFragment"; + private RecyclerView mRecyclerView; + private RelativeLayout mEmptyLayout; + private TextView mShareTv; + private TextView mFreshTv; private SurroundingEventAdapter mAdapter; private SurroundingEventPresenter surroundingEventPresenter; + private List poiInfosList = new ArrayList<>(); @Override protected int getLayoutId() { - return R.layout.module_event_panel_fragment_surrounding_event; + return R.layout.module_event_panel_fragment_surrounding; } @Override protected void initViews() { Log.d("liyz", "initViews --------> "); - initRecyclerView(); + mRecyclerView = findViewById(R.id.surrounding_recycleview); + mEmptyLayout = findViewById(R.id.layout_empty_data_show); + mShareTv = findViewById(R.id.tv_main_share); + mFreshTv = findViewById(R.id.tv_main_refresh); + + + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setOverScrollMode(OVER_SCROLL_NEVER); + GridLayoutManager layoutManage = new GridLayoutManager(getContext(), 1); + mRecyclerView.setLayoutManager(layoutManage); + + mAdapter = new SurroundingEventAdapter(getActivity(), poiInfosList); //TODO + mRecyclerView.setAdapter(mAdapter); + initData(); } @@ -54,15 +77,9 @@ public class SurroundingEventFragment extends MvpFragment 0) { + mRecyclerView.setVisibility(View.VISIBLE); + mEmptyLayout.setVisibility(View.GONE); + poiInfosList.clear(); + poiInfosList.addAll(resultBean.getPoiInfos()); + mAdapter.notifyDataSetChanged(); + } else { + mRecyclerView.setVisibility(View.GONE); + mEmptyLayout.setVisibility(View.VISIBLE); + } + } else { + mRecyclerView.setVisibility(View.GONE); + mEmptyLayout.setVisibility(View.VISIBLE); } } @Override public void onDestroy() { super.onDestroy(); + if (poiInfosList != null) { + poiInfosList.clear(); + poiInfosList = null; + } } @Override @@ -88,4 +122,5 @@ public class SurroundingEventFragment extends MvpFragment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding_event.xml b/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding_event.xml deleted file mode 100644 index 22fcfcc273..0000000000 --- a/modules/mogo-module-v2x/src/main/res/layout/module_event_panel_fragment_surrounding_event.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/layout/module_fragment_surrounding_event_item.xml b/modules/mogo-module-v2x/src/main/res/layout/module_fragment_surrounding_event_item.xml new file mode 100644 index 0000000000..557a0f0c82 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/res/layout/module_fragment_surrounding_event_item.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/modules/mogo-module-v2x/src/main/res/values/color.xml b/modules/mogo-module-v2x/src/main/res/values/color.xml index f8a3476000..c416a6e0d5 100644 --- a/modules/mogo-module-v2x/src/main/res/values/color.xml +++ b/modules/mogo-module-v2x/src/main/res/values/color.xml @@ -2,4 +2,5 @@ #256BFF #3F4057 + \ No newline at end of file