Commit 02892bf2d0602d896e9cd2cfe7d55e8c4e81c3cf
1 parent
6e3859ed
消息页面修改
Showing
12 changed files
with
346 additions
and
3 deletions
app/src/main/AndroidManifest.xml
| ... | ... | @@ -464,6 +464,9 @@ |
| 464 | 464 | <meta-data |
| 465 | 465 | android:name="io.fabric.ApiKey" |
| 466 | 466 | android:value="ad4c6ea643d6b323b5f81ba1391b9ced2a4fd9e5" /> |
| 467 | + <activity android:name=".ui.activity.HistoryMvvmActivity" | |
| 468 | + android:launchMode="singleTop" | |
| 469 | + android:screenOrientation="portrait" /> | |
| 467 | 470 | |
| 468 | 471 | </application> |
| 469 | 472 | ... | ... |
app/src/main/java/com/cnlive/goldenline/ui/activity/HistoryMvvmActivity.java
0 → 100644
| 1 | +package com.cnlive.goldenline.ui.activity; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.os.Bundle; | |
| 6 | + | |
| 7 | +import com.cnlive.goldenline.R; | |
| 8 | +import com.cnlive.goldenline.databinding.ActivityMyHistoryMvvmBinding; | |
| 9 | +import com.cnlive.goldenline.ui.base.BaseActivity; | |
| 10 | +import com.cnlive.goldenline.viewmodel.HistoryModleView; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 创建:wukuiqing | |
| 14 | + * <p> | |
| 15 | + * 时间:2017/5/15 | |
| 16 | + * <p> | |
| 17 | + * 描述: | |
| 18 | + */ | |
| 19 | + | |
| 20 | +public class HistoryMvvmActivity extends Activity { | |
| 21 | + | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + protected void onCreate(Bundle savedInstanceState) { | |
| 25 | + super.onCreate(savedInstanceState); | |
| 26 | + | |
| 27 | + ActivityMyHistoryMvvmBinding activityMyHistoryMvvmBinding = DataBindingUtil.setContentView(this, R.layout.activity_my_history_mvvm); | |
| 28 | + | |
| 29 | + | |
| 30 | + activityMyHistoryMvvmBinding.setHistoryModleView(new HistoryModleView(this, activityMyHistoryMvvmBinding)); | |
| 31 | + } | |
| 32 | +} | ... | ... |
app/src/main/java/com/cnlive/goldenline/ui/activity/MyMessageActivity.java
app/src/main/java/com/cnlive/goldenline/ui/adapter/HistoryMvvmAdapter.java
0 → 100644
| 1 | +package com.cnlive.goldenline.ui.adapter; | |
| 2 | + | |
| 3 | +import android.databinding.DataBindingUtil; | |
| 4 | +import android.support.v7.widget.RecyclerView; | |
| 5 | +import android.view.LayoutInflater; | |
| 6 | +import android.view.View; | |
| 7 | +import android.view.ViewGroup; | |
| 8 | + | |
| 9 | +import com.cnlive.goldenline.R; | |
| 10 | +import com.cnlive.goldenline.dao.History; | |
| 11 | +import com.cnlive.goldenline.databinding.LayoutHistoryrecordItemMvvmBinding; | |
| 12 | +import com.cnlive.goldenline.viewmodel.HistoryItemModleView; | |
| 13 | + | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +import static android.databinding.DataBindingUtil.inflate; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 创建:wukuiqing | |
| 20 | + * <p> | |
| 21 | + * 时间:2017/5/15 | |
| 22 | + * <p> | |
| 23 | + * 描述: | |
| 24 | + */ | |
| 25 | + | |
| 26 | +public class HistoryMvvmAdapter extends RecyclerView.Adapter<HistoryMvvmAdapter.BindingHolder> { | |
| 27 | + | |
| 28 | + List<History> data; | |
| 29 | + | |
| 30 | + | |
| 31 | + public HistoryMvvmAdapter(List<History> data) { | |
| 32 | + this.data=data; | |
| 33 | + | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 38 | + | |
| 39 | + LayoutHistoryrecordItemMvvmBinding layoutHistoryrecordItemMvvmBinding= DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.layout_historyrecord_item_mvvm,parent,false); | |
| 40 | + | |
| 41 | + return new BindingHolder(layoutHistoryrecordItemMvvmBinding); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public void onBindViewHolder(BindingHolder holder, int position) { | |
| 46 | + HistoryItemModleView historyItemModleView= new HistoryItemModleView(data.get(position)); | |
| 47 | + | |
| 48 | + | |
| 49 | + holder.layoutHistoryrecordItemMvvmBinding.setHistoryItemModleView(historyItemModleView); | |
| 50 | + | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public int getItemCount() { | |
| 55 | + return data.size(); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public class BindingHolder extends RecyclerView.ViewHolder{ | |
| 59 | + LayoutHistoryrecordItemMvvmBinding layoutHistoryrecordItemMvvmBinding; | |
| 60 | + public BindingHolder(LayoutHistoryrecordItemMvvmBinding layoutHistoryrecordItemMvvmBinding) { | |
| 61 | + super(layoutHistoryrecordItemMvvmBinding.getRoot()); | |
| 62 | + this.layoutHistoryrecordItemMvvmBinding=layoutHistoryrecordItemMvvmBinding; | |
| 63 | + } | |
| 64 | + } | |
| 65 | +} | ... | ... |
app/src/main/java/com/cnlive/goldenline/ui/adapter/MyMessageAdapter.java
| 1 | 1 | package com.cnlive.goldenline.ui.adapter; |
| 2 | 2 | |
| 3 | +import android.content.Context; | |
| 3 | 4 | import android.databinding.DataBindingUtil; |
| 4 | 5 | import android.support.v7.widget.RecyclerView; |
| 5 | 6 | import android.view.LayoutInflater; |
| ... | ... | @@ -26,8 +27,10 @@ import static android.databinding.DataBindingUtil.inflate; |
| 26 | 27 | public class MyMessageAdapter extends RecyclerView.Adapter<MyMessageAdapter.BindingHolder> { |
| 27 | 28 | List<MessageBean> dataList; |
| 28 | 29 | |
| 30 | + | |
| 29 | 31 | public MyMessageAdapter(List<MessageBean> dataList) { |
| 30 | 32 | this.dataList=dataList; |
| 33 | + | |
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | @Override | ... | ... |
app/src/main/java/com/cnlive/goldenline/ui/fragment/MineFragment.java
| ... | ... | @@ -15,6 +15,7 @@ import com.cnlive.goldenline.model.User; |
| 15 | 15 | import com.cnlive.goldenline.model.mine.SyncUserRequestBean; |
| 16 | 16 | import com.cnlive.goldenline.ui.activity.CollectActivity; |
| 17 | 17 | import com.cnlive.goldenline.ui.activity.HistoryActivity; |
| 18 | +import com.cnlive.goldenline.ui.activity.HistoryMvvmActivity; | |
| 18 | 19 | import com.cnlive.goldenline.ui.activity.ImprovePersonInfoActivity; |
| 19 | 20 | import com.cnlive.goldenline.ui.activity.MyCouponActivity; |
| 20 | 21 | import com.cnlive.goldenline.ui.activity.MyMessageActivity; |
| ... | ... | @@ -227,8 +228,13 @@ public class MineFragment extends BaseFragment { |
| 227 | 228 | |
| 228 | 229 | break; |
| 229 | 230 | case R.id.tv_button_minehistory://历史记录 |
| 230 | - HistoryActivity.startActivity(getActivity()); | |
| 231 | +// HistoryActivity.startActivity(getActivity()); | |
| 232 | + | |
| 233 | + Intent intent4= new Intent(getActivity(), HistoryMvvmActivity.class); | |
| 234 | + | |
| 235 | + startActivity(intent4); | |
| 231 | 236 | break; |
| 237 | + | |
| 232 | 238 | case R.id.tv_button_minecollect://我的收藏 |
| 233 | 239 | skipAct(CollectActivity.class); |
| 234 | 240 | break; | ... | ... |
app/src/main/java/com/cnlive/goldenline/viewmodel/HistoryItemModleView.java
0 → 100644
| 1 | +package com.cnlive.goldenline.viewmodel; | |
| 2 | + | |
| 3 | +import com.cnlive.goldenline.dao.History; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 创建:wukuiqing | |
| 7 | + * <p> | |
| 8 | + * 时间:2017/5/15 | |
| 9 | + * <p> | |
| 10 | + * 描述: | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class HistoryItemModleView { | |
| 14 | + | |
| 15 | + History data; | |
| 16 | + public HistoryItemModleView(History data) { | |
| 17 | + this.data= data; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public String getContent(){ | |
| 21 | + | |
| 22 | + return data.getVdShowTitle(); | |
| 23 | + } | |
| 24 | +} | ... | ... |
app/src/main/java/com/cnlive/goldenline/viewmodel/HistoryModleView.java
0 → 100644
| 1 | +package com.cnlive.goldenline.viewmodel; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.support.v7.widget.DefaultItemAnimator; | |
| 5 | +import android.support.v7.widget.LinearLayoutManager; | |
| 6 | +import android.util.Log; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.cnlive.goldenline.dao.History; | |
| 10 | +import com.cnlive.goldenline.databinding.ActivityMyHistoryMvvmBinding; | |
| 11 | +import com.cnlive.goldenline.ui.activity.HistoryMvvmActivity; | |
| 12 | +import com.cnlive.goldenline.ui.adapter.HistoryMvvmAdapter; | |
| 13 | +import com.cnlive.goldenline.util.HistoryUtils; | |
| 14 | +import com.cnlive.libs.util.data.okhttpUtil.utils.L; | |
| 15 | + | |
| 16 | +import java.util.ArrayList; | |
| 17 | +import java.util.Collections; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * 创建:wukuiqing | |
| 22 | + * <p> | |
| 23 | + * 时间:2017/5/15 | |
| 24 | + * <p> | |
| 25 | + * 描述: 历史记录的 页面 (收藏和历史记录一直可以抽取) | |
| 26 | + */ | |
| 27 | + | |
| 28 | +public class HistoryModleView { | |
| 29 | + List<History> histories ; | |
| 30 | + | |
| 31 | + Activity historyMvvmActivity; | |
| 32 | + ActivityMyHistoryMvvmBinding activityMyHistoryMvvmBinding; | |
| 33 | + | |
| 34 | + public HistoryModleView(Activity historyMvvmActivity, ActivityMyHistoryMvvmBinding activityMyHistoryMvvmBinding) { | |
| 35 | + this.activityMyHistoryMvvmBinding = activityMyHistoryMvvmBinding; | |
| 36 | + this.historyMvvmActivity = historyMvvmActivity; | |
| 37 | + initData(); | |
| 38 | + | |
| 39 | + initView(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + private void initData() { | |
| 43 | + | |
| 44 | + histories = HistoryUtils.getHistories(historyMvvmActivity); | |
| 45 | +// Log.e("历史数据","历史数据:"+histories.size()); | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + private void initView() { | |
| 52 | + activityMyHistoryMvvmBinding.recyclerList.setItemAnimator(new DefaultItemAnimator()); | |
| 53 | + activityMyHistoryMvvmBinding.recyclerList.setLayoutManager(new LinearLayoutManager(historyMvvmActivity,LinearLayoutManager.VERTICAL,false)); | |
| 54 | + HistoryMvvmAdapter adapter= new HistoryMvvmAdapter(histories); | |
| 55 | + | |
| 56 | + activityMyHistoryMvvmBinding.recyclerList.setAdapter(adapter); | |
| 57 | + | |
| 58 | + } | |
| 59 | + | |
| 60 | + | |
| 61 | +} | ... | ... |
app/src/main/java/com/cnlive/goldenline/viewmodel/MyMessageModleView.java
| 1 | 1 | package com.cnlive.goldenline.viewmodel; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | +import android.content.Context; | |
| 5 | +import android.content.Intent; | |
| 4 | 6 | import android.databinding.BaseObservable; |
| 5 | 7 | import android.databinding.BindingAdapter; |
| 8 | +import android.view.View; | |
| 6 | 9 | import android.widget.ImageView; |
| 7 | 10 | |
| 8 | 11 | import com.bumptech.glide.Glide; |
| 9 | 12 | import com.cnlive.goldenline.R; |
| 10 | 13 | import com.cnlive.goldenline.databinding.ActivityMyMessageBinding; |
| 11 | 14 | import com.cnlive.goldenline.model.request.MessageBean; |
| 15 | +import com.cnlive.goldenline.ui.activity.act.model.ActWebActivity; | |
| 12 | 16 | import com.cnlive.goldenline.ui.adapter.MyMsgAdapter; |
| 13 | 17 | import com.cnlive.goldenline.ui.widget.CropCircleTransformation; |
| 14 | 18 | |
| ... | ... | @@ -23,6 +27,7 @@ import com.cnlive.goldenline.ui.widget.CropCircleTransformation; |
| 23 | 27 | public class MyMessageModleView extends BaseObservable{ |
| 24 | 28 | MessageBean data; |
| 25 | 29 | |
| 30 | + | |
| 26 | 31 | public MyMessageModleView(MessageBean data) { |
| 27 | 32 | this.data = data; |
| 28 | 33 | |
| ... | ... | @@ -54,6 +59,17 @@ public class MyMessageModleView extends BaseObservable{ |
| 54 | 59 | } |
| 55 | 60 | |
| 56 | 61 | |
| 62 | + public void itemOnClick(View v) { | |
| 63 | + | |
| 64 | + Intent intent = new Intent(v.getContext(), ActWebActivity.class); | |
| 65 | + intent.putExtra("url", data.getMessageUrl()); | |
| 66 | + v.getContext().startActivity(intent); | |
| 67 | + | |
| 68 | + } | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 57 | 73 | @BindingAdapter({"app:imageUrl"}) |
| 58 | 74 | public static void loadInternetImage(ImageView imageView, String url) { |
| 59 | 75 | Glide.with(imageView.getContext()) | ... | ... |
app/src/main/res/layout/activity_my_history_mvvm.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | + | |
| 3 | +<layout> | |
| 4 | + | |
| 5 | + <data> | |
| 6 | + | |
| 7 | + <variable | |
| 8 | + name="historyModleView" | |
| 9 | + type="com.cnlive.goldenline.viewmodel.HistoryModleView" /> | |
| 10 | + | |
| 11 | + </data> | |
| 12 | + | |
| 13 | + <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 14 | + android:layout_width="match_parent" | |
| 15 | + android:layout_height="match_parent" | |
| 16 | + android:orientation="vertical"> | |
| 17 | + | |
| 18 | + | |
| 19 | + <include | |
| 20 | + android:id="@+id/toolbarLayout" | |
| 21 | + layout="@layout/toolbar_edit_history" /> | |
| 22 | + | |
| 23 | + | |
| 24 | + <RelativeLayout | |
| 25 | + android:layout_width="match_parent" | |
| 26 | + android:layout_height="match_parent" | |
| 27 | + android:layout_above="@+id/deleteLayout" | |
| 28 | + android:layout_below="@+id/toolbarLayout"> | |
| 29 | + | |
| 30 | + <com.cnlive.goldenline.ui.widget.pull2refresh.PullToRefreshLayout | |
| 31 | + android:id="@+id/pull_to_refresh" | |
| 32 | + android:layout_width="match_parent" | |
| 33 | + android:layout_height="match_parent"> | |
| 34 | + | |
| 35 | + <com.cnlive.goldenline.ui.widget.pull2refresh.PullableRecyclerView | |
| 36 | + android:id="@+id/recyclerList" | |
| 37 | + android:layout_width="match_parent" | |
| 38 | + android:layout_height="match_parent" /> | |
| 39 | + </com.cnlive.goldenline.ui.widget.pull2refresh.PullToRefreshLayout> | |
| 40 | + | |
| 41 | + <!--<TextView--> | |
| 42 | + <!--android:id="@+id/errorText"--> | |
| 43 | + <!--android:layout_width="match_parent"--> | |
| 44 | + <!--android:layout_height="match_parent"--> | |
| 45 | + <!--android:gravity="center"--> | |
| 46 | + <!--android:text="还没有数据哦"--> | |
| 47 | + <!--android:textSize="20sp" />--> | |
| 48 | + | |
| 49 | + </RelativeLayout> | |
| 50 | + | |
| 51 | + <RelativeLayout | |
| 52 | + android:id="@+id/deleteLayout" | |
| 53 | + android:layout_width="match_parent" | |
| 54 | + android:layout_height="wrap_content" | |
| 55 | + android:layout_alignParentBottom="true"> | |
| 56 | + | |
| 57 | + <TextView | |
| 58 | + android:id="@+id/bottomDelete" | |
| 59 | + android:layout_width="match_parent" | |
| 60 | + android:layout_height="42dp" | |
| 61 | + android:layout_marginBottom="46dp" | |
| 62 | + android:layout_marginLeft="12dp" | |
| 63 | + android:layout_marginRight="12dp" | |
| 64 | + android:background="@drawable/history_delete_bg" | |
| 65 | + android:gravity="center" | |
| 66 | + android:text="删除" | |
| 67 | + android:textColor="@android:color/white" | |
| 68 | + android:textSize="17sp" | |
| 69 | + android:visibility="gone" /> | |
| 70 | + </RelativeLayout> | |
| 71 | + | |
| 72 | + | |
| 73 | + </RelativeLayout> | |
| 74 | +</layout> | |
| 0 | 75 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_historyrecord_item_mvvm.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | + | |
| 3 | +<layout> | |
| 4 | + <data> | |
| 5 | + <variable | |
| 6 | + name="historyItemModleView" | |
| 7 | + type="com.cnlive.goldenline.viewmodel.HistoryItemModleView"/> | |
| 8 | + | |
| 9 | + </data> | |
| 10 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 11 | + android:layout_width="match_parent" | |
| 12 | + android:layout_height="wrap_content"> | |
| 13 | + | |
| 14 | + <RelativeLayout | |
| 15 | + android:layout_width="match_parent" | |
| 16 | + android:layout_height="71dp" | |
| 17 | + android:background="@color/white"> | |
| 18 | + <CheckBox | |
| 19 | + android:id="@+id/check" | |
| 20 | + android:layout_width="wrap_content" | |
| 21 | + android:layout_centerVertical="true" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:layout_marginLeft="10dp" | |
| 24 | + android:visibility="gone" | |
| 25 | + android:button="@drawable/checkbox_selector" | |
| 26 | + android:background="@color/white" /> | |
| 27 | + | |
| 28 | + <ImageView | |
| 29 | + android:id="@+id/ima_history_head" | |
| 30 | + android:layout_width="96dp" | |
| 31 | + android:layout_height="55dp" | |
| 32 | + android:layout_centerVertical="true" | |
| 33 | + android:layout_marginLeft="10dp" | |
| 34 | + android:layout_toRightOf="@id/check" | |
| 35 | + android:background="@drawable/default_background" /> | |
| 36 | + | |
| 37 | + <TextView | |
| 38 | + | |
| 39 | + android:id="@+id/tv_history_title" | |
| 40 | + android:layout_width="wrap_content" | |
| 41 | + android:layout_height="wrap_content" | |
| 42 | + android:layout_centerVertical="true" | |
| 43 | + android:layout_marginLeft="11dp" | |
| 44 | + android:layout_marginRight="10dp" | |
| 45 | + android:layout_toRightOf="@id/ima_history_head" | |
| 46 | + android:ellipsize="end" | |
| 47 | + android:maxLines="2" | |
| 48 | + android:text="@{historyItemModleView.content}" | |
| 49 | + android:textColor="@color/color_333" | |
| 50 | + android:textSize="13sp" /> | |
| 51 | + <View | |
| 52 | + android:layout_width="match_parent" | |
| 53 | + android:layout_alignParentBottom="true" | |
| 54 | + android:layout_toRightOf="@id/ima_history_head" | |
| 55 | + android:layout_height="1dp"/> | |
| 56 | + </RelativeLayout> | |
| 57 | +</LinearLayout> | |
| 58 | +</layout> | |
| 0 | 59 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_msg_item_2.xml
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | </data> |
| 13 | 13 | <LinearLayout |
| 14 | + | |
| 14 | 15 | android:layout_width="match_parent" |
| 15 | 16 | android:id="@+id/ll_item" |
| 16 | 17 | android:layout_height="wrap_content" |
| ... | ... | @@ -18,6 +19,7 @@ |
| 18 | 19 | android:orientation="vertical"> |
| 19 | 20 | |
| 20 | 21 | <RelativeLayout |
| 22 | + android:onClick="@{msgModleView.itemOnClick}" | |
| 21 | 23 | android:layout_width="match_parent" |
| 22 | 24 | android:layout_height="61dp"> |
| 23 | 25 | ... | ... |