opt
This commit is contained in:
@@ -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<SurroundingEventViewHolder>{
|
||||
private List<SurroundingResponse.ResultBean.PoiInfosBean> mPoiInfosList;
|
||||
private Context mContext;
|
||||
private TextView mAddressTv;
|
||||
|
||||
//TODO 数据
|
||||
public SurroundingEventAdapter(Context context) {
|
||||
|
||||
public SurroundingEventAdapter(Context context, List<SurroundingResponse.ResultBean.PoiInfosBean> poiInfosList) {
|
||||
mContext = context;
|
||||
mPoiInfosList = poiInfosList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,21 +39,24 @@ public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEve
|
||||
@NonNull
|
||||
@Override
|
||||
public SurroundingEventViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
return null;
|
||||
View inflate = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.module_fragment_surrounding_event_item, parent, false);
|
||||
return new SurroundingEventViewHolder(inflate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SurroundingEventViewHolder holder, int position) {
|
||||
final SurroundingResponse.ResultBean.PoiInfosBean poiInfosBean = mPoiInfosList.get(position);
|
||||
if (poiInfosBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// mAddressTv = holder.itemView.findViewById(R.id.tv_information);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 0;
|
||||
return mPoiInfosList == null ? 0 : mPoiInfosList.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.mogo.module.v2x.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
@@ -15,27 +18,47 @@ import com.mogo.module.v2x.entity.panel.SurroundingResponse;
|
||||
import com.mogo.module.v2x.presenter.SurroundingEventPresenter;
|
||||
import com.mogo.module.v2x.view.SurroundingEventView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.View.OVER_SCROLL_NEVER;
|
||||
|
||||
/**
|
||||
* 周边事件
|
||||
*/
|
||||
public class SurroundingEventFragment extends MvpFragment<SurroundingEventView, SurroundingEventPresenter> 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<SurroundingResponse.ResultBean.PoiInfosBean> 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<SurroundingEventView,
|
||||
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
// recyclerView = view.findViewById(R.id.c);
|
||||
// mAdapter = new SurroundingEventAdapter(getActivity()); //TODO
|
||||
// recyclerView.setAdapter(mAdapter);
|
||||
// LinearLayoutManager linearLayoutManager =
|
||||
// new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
// recyclerView.setLayoutManager(linearLayoutManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取和刷新数据
|
||||
*/
|
||||
private void initData() {
|
||||
surroundingEventPresenter.getSurroundingEventData();
|
||||
}
|
||||
@@ -73,14 +90,31 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
|
||||
@Override
|
||||
public void showSurroudingData(SurroundingResponse data) {
|
||||
if (data.getResult() != null) {
|
||||
SurroundingResponse.ResultBean resultBean = data.getResult();
|
||||
SurroundingResponse.ResultBean resultBean = data.getResult();
|
||||
if (resultBean != null && resultBean.getPoiInfos() != null && resultBean.getPoiInfos().size() > 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<SurroundingEventView,
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user