Merge branch 'dev_local' into dev_1.1
This commit is contained in:
@@ -3,6 +3,7 @@ package com.zhidao.mogo.module.event.panel.adapter
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.zhidao.mogo.module.event.panel.fragment.MyShareFragment
|
||||
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment
|
||||
import com.zhidao.mogo.module.event.panel.fragment.SurroundingEventFragment
|
||||
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
|
||||
|
||||
@@ -12,7 +13,7 @@ import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class EventPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||
private val fragments:Array<Fragment> = arrayOf(TripRecordFragment(), SurroundingEventFragment(), MyShareFragment())
|
||||
private val fragments:Array<Fragment> = arrayOf(TripRecordFragment(), SurroundingEventFragment(), ShareEventsFragment())
|
||||
|
||||
/**
|
||||
* 目前一共就三个fragment
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.zhidao.mogo.module.event.panel.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.zhidao.mogo.module.event.panel.R;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private Context context;
|
||||
private ArrayList<ShareEventItem> dataArrayList;
|
||||
private Object Tag = "ShareEventAdapter";
|
||||
private final LayoutInflater shareLayoutInflater;
|
||||
|
||||
public static enum ITEM_TYPE {
|
||||
ITEM_TYPE_NUM_DES,
|
||||
ITEM_TYPE_SHARE_LIST
|
||||
}
|
||||
|
||||
public ShareEventAdapter(Context context, ArrayList<ShareEventItem> dataArrayList) {
|
||||
this.context = context;
|
||||
this.dataArrayList = dataArrayList;
|
||||
shareLayoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
//根据viewType创建自定义布局
|
||||
if (viewType == ITEM_TYPE.ITEM_TYPE_NUM_DES.ordinal()) {
|
||||
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_event_description, parent,
|
||||
false);
|
||||
shareDescriptionViewHolder holder = new shareDescriptionViewHolder(v);
|
||||
return holder;
|
||||
} else {
|
||||
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_my_share_item, parent,
|
||||
false);
|
||||
shareItemViewHolder holder = new shareItemViewHolder(v);
|
||||
return holder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (position < 1) {
|
||||
ShareEventDescription data = new ShareEventDescription();
|
||||
data.shareNum = "12";
|
||||
data.approveNum = "10";
|
||||
((shareDescriptionViewHolder) holder).shareNumTextView.setText(data.shareNum);
|
||||
((shareDescriptionViewHolder) holder).approveNumTextView.setText(data.approveNum);
|
||||
|
||||
} else {
|
||||
ShareEventItem data = dataArrayList.get(position-1);
|
||||
((shareItemViewHolder) holder).caseStyleTextView.setText(data.caseStyle);
|
||||
((shareItemViewHolder) holder).caseAddressTextView.setText(data.caseAddress);
|
||||
((shareItemViewHolder) holder).caseTimeTextView.setText(data.caseTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataArrayList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
int type = position == 0 ? ITEM_TYPE.ITEM_TYPE_NUM_DES.ordinal() : ITEM_TYPE.ITEM_TYPE_SHARE_LIST.ordinal();
|
||||
return type;
|
||||
}
|
||||
|
||||
/*
|
||||
* 分享列表
|
||||
* */
|
||||
class shareItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView caseStyleTextView;
|
||||
private TextView caseAddressTextView;
|
||||
private TextView caseTimeTextView;
|
||||
// private TextView caseUsefulTextView;
|
||||
|
||||
public shareItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
caseStyleTextView = itemView.findViewById(R.id.road_case_style);
|
||||
caseAddressTextView = itemView.findViewById(R.id.road_case_address);
|
||||
caseTimeTextView = itemView.findViewById(R.id.road_case_share_time);
|
||||
// caseUsefulTextView = itemView.findViewById(R.id.road_case_useful_num);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 分享次数,热心指数...
|
||||
* */
|
||||
class shareDescriptionViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView shareNumTextView;
|
||||
private TextView approveNumTextView;
|
||||
|
||||
public shareDescriptionViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
shareNumTextView = itemView.findViewById(R.id.share_num);
|
||||
approveNumTextView = itemView.findViewById(R.id.share_approve);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.zhidao.mogo.module.event.panel.bean;
|
||||
|
||||
public class ShareEventDescription {
|
||||
public String shareNum;
|
||||
public String approveNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zhidao.mogo.module.event.panel.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ShareEventItem implements Serializable {
|
||||
public String caseStyle;
|
||||
public String caseAddress;
|
||||
public String caseTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class MyShareFragment : MvpFragment<MyShareFragment, MySharePresenter>() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_my_share
|
||||
override fun getLayoutId(): Int = R.layout.module_event_panel_my_share_item
|
||||
|
||||
/**
|
||||
* 初始化控件,必须在初始化完成之后才可以实例化presenter,避免
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.zhidao.mogo.module.event.panel.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.zhidao.mogo.module.event.panel.R;
|
||||
import com.zhidao.mogo.module.event.panel.adapter.ShareEventAdapter;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
|
||||
import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareEventsPresenter> {
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private View view;
|
||||
private ShareEventAdapter adapter;
|
||||
private ArrayList<ShareEventItem> dataArrayList = new ArrayList<ShareEventItem>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_event_panel_share_event_recylerview;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.module_event_panel_share_event_recylerview, container, false);
|
||||
initRecyclerView();
|
||||
initData();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView = view.findViewById(R.id.road_case_share_list);
|
||||
adapter = new ShareEventAdapter(getActivity(),dataArrayList);
|
||||
recyclerView.setAdapter(adapter);
|
||||
LinearLayoutManager linearLayoutManager =
|
||||
new LinearLayoutManager( getActivity(), LinearLayoutManager.VERTICAL, false );
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
ShareEventItem data = new ShareEventItem();
|
||||
data.caseStyle = "道路拥堵";
|
||||
data.caseAddress = "环球贸易中心";
|
||||
data.caseTime = "2020-07-21 12:00:00";
|
||||
dataArrayList.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ShareEventsPresenter createPresenter() {
|
||||
return new ShareEventsPresenter(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zhidao.mogo.module.event.panel.presenter;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment;
|
||||
|
||||
public class ShareEventsPresenter extends Presenter <ShareEventsFragment>{
|
||||
public ShareEventsPresenter(IView view) {
|
||||
super((ShareEventsFragment) view);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/clPanelContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="My Share"
|
||||
android:textColor="#fff"
|
||||
android:textSize="40sp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/road_case_liset_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/road_case_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:text="道路类型"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/road_case_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/road_case_style"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="15dp"
|
||||
android:text="东城区北三环"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/road_case_share_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/road_case_address"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="20dp"
|
||||
android:text="时间:"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/road_case_useless"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="@drawable/amap_bus" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/road_case_useless_num"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@id/road_case_useless"
|
||||
android:layout_alignLeft="@id/road_case_useless"
|
||||
android:layout_alignRight="@id/road_case_useless"
|
||||
android:gravity="center"
|
||||
android:text="10"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/road_case_uselful"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@id/road_case_useless"
|
||||
android:layout_alignBottom="@id/road_case_useless"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_toLeftOf="@id/road_case_useless"
|
||||
android:background="@drawable/amap_ride" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/road_case_useful_num"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@id/road_case_useless"
|
||||
android:layout_alignLeft="@id/road_case_uselful"
|
||||
android:layout_alignRight="@id/road_case_uselful"
|
||||
android:gravity="center"
|
||||
android:text="5"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_num"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/shre_num_des"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="分享次数"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="80dp"
|
||||
android:background="#FFFFFF" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_approve"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_approve_des"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:gravity="center"
|
||||
android:text="车友认同次数"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="80dp"
|
||||
android:background="#FFFFFF" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_index"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/amap_ride" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_index_des"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:gravity="center"
|
||||
android:text="热心指数"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/road_case_share_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:overScrollMode="never"
|
||||
android:background="#000000"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_event_guide_des"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="#0000ff"
|
||||
android:gravity="center"
|
||||
android:text="小窍门:分享路况、点赞其他车友,有助于提高热心指数"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp">
|
||||
|
||||
</TextView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_event_null_des"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:layout_below="@+id/share_event_guide_des"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:gravity="center"
|
||||
android:text="你还没有分享过道路事件,快去试试吧" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/shre_event_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/share_event_null_des"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="#FFFFFF"
|
||||
android:text="去分享"
|
||||
android:textSize="25sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user