Prechádzať zdrojové kódy

消息中心代码,

yuanshenglan 7 rokov pred
rodič
commit
7d9199845d

+ 35 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/MessageInteractionActivity.java

@@ -0,0 +1,35 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+
+import com.sheep.jiuyan.samllsheep.R;
+
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+/**
+ * created on:2018/8/28 on 17:15
+ * created by: YSL
+ * 描述:消息互动中item点击展开后的activity
+ */
+public class MessageInteractionActivity extends AppCompatActivity {
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_message_interaction);
+        ButterKnife.bind(this);
+    }
+
+    @OnClick({R.id.img_baseactivity_title})
+    public void initClick(View view) {
+        switch (view.getId()) {
+            case R.id.img_baseactivity_title:
+                MessageInteractionActivity.this.finish();
+                break;
+        }
+    }
+}

+ 53 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/MessageSystemActivity.java

@@ -0,0 +1,53 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.sheep.jiuyan.samllsheep.R;
+import com.umeng.commonsdk.debug.I;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+
+/**
+ * created on:2018/8/28 on 17:55
+ * created by: YSL
+ * 描述:
+ */
+public class MessageSystemActivity extends AppCompatActivity {
+    @BindView(R.id.tv_content)
+    TextView tvContent;
+    @BindView(R.id.tv_title)
+    TextView tvTitle;
+    @BindView(R.id.txt_baseactivity_title)
+    TextView tvBaseTitle;
+
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_messagesystem);
+        ButterKnife.bind(this);
+    }
+
+    @OnClick({R.id.img_baseactivity_title})
+    public void initClick(View view) {
+        switch (view.getId()) {
+            case R.id.img_baseactivity_title:
+                MessageSystemActivity.this.finish();
+                break;
+        }
+
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+
+    }
+}

+ 82 - 0
app/src/main/java/com/sheep/gamegroup/view/adapter/MessageInteractionAdapter.java

@@ -0,0 +1,82 @@
+package com.sheep.gamegroup.view.adapter;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.jiuyan.samllsheep.R;
+
+import java.util.List;
+
+/**
+ * created on:2018/8/28 on 17:26
+ * created by: YSL
+ * 描述:消息互动中item点击展开后FAQ的形式
+ */
+public class MessageInteractionAdapter extends RecyclerView.Adapter<MessageInteractionAdapter.MyHolder> {
+    private Context mContext;
+    private List<?> mList;
+
+    public MessageInteractionAdapter(Context mContext, List<?> mList) {
+        this.mContext = mContext;
+        this.mList = mList;
+    }
+
+    @NonNull
+    @Override
+    public MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
+        View view = null;
+        if (mList == null || mList.isEmpty()) {
+            view = LayoutInflater.from(mContext).inflate(R.layout.empty_view, null);
+        } else {
+            view = LayoutInflater.from(mContext).inflate(R.layout.adapter_message_interaction, null);
+        }
+        return new MyHolder(view);
+    }
+
+    @Override
+    public void onBindViewHolder(@NonNull MyHolder viewHolder, int i) {
+        if (mList == null || mList.isEmpty()) {
+            return;
+        } else {
+            if (i == mList.size() - 1) {
+                viewHolder.viewLine.setVisibility(View.GONE);//最后一条数据隐藏线条
+            }
+            GlideImageLoader.centerImage(viewHolder.ivIcon, "");
+            viewHolder.tvPeople.setText("");
+            viewHolder.tvTime.setText("");
+            viewHolder.tvContent.setText("");
+        }
+    }
+
+    @Override
+    public int getItemCount() {
+        return mList == null ? 0 : mList.size();
+    }
+
+    class MyHolder extends RecyclerView.ViewHolder {
+        private ImageView ivIcon;//头像
+        private TextView tvPeople;//标题
+        private TextView tvTime;//谁的消息
+        private TextView tvContent;//每条消息的内容,这里最多只显示一行
+        private View viewLine;//item之间的线条
+        private LinearLayout itemLayout;//整个item布局
+
+        public MyHolder(View view) {
+            super(view);
+            ivIcon = view.findViewById(R.id.iv_icon);
+            tvPeople = view.findViewById(R.id.tv_people);
+            tvTime = view.findViewById(R.id.tv_time);
+            tvContent = view.findViewById(R.id.tv_content);
+            viewLine = view.findViewById(R.id.view_line);
+            itemLayout = view.findViewById(R.id.item_layout);
+        }
+    }
+}

+ 105 - 0
app/src/main/java/com/sheep/gamegroup/view/adapter/MessageLeftAdapter.java

@@ -0,0 +1,105 @@
+package com.sheep.gamegroup.view.adapter;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.jiuyan.samllsheep.R;
+
+
+import java.util.List;
+
+
+/**
+ * created on:2018/8/28 on 16:08
+ * created by: YSL
+ * 描述:
+ */
+public class MessageLeftAdapter extends RecyclerView.Adapter<MessageLeftAdapter.Myholder> {
+    private Context mContext;
+    private List<?> mList;
+    private ItemOnClickListener itemClick;
+    private int position;
+
+    public MessageLeftAdapter(Context mContext, List<?> mList, ItemOnClickListener itemClick) {
+        this.mContext = mContext;
+        this.mList = mList;
+        this.itemClick = itemClick;
+    }
+
+
+    @NonNull
+    @Override
+    public Myholder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
+        View view = null;
+        if (mList == null || mList.isEmpty()) {
+            view = LayoutInflater.from(mContext).inflate(R.layout.empty_view, null);
+        } else {
+            view = LayoutInflater.from(mContext).inflate(R.layout.adapter_message_left_fragment, null);
+        }
+        return new Myholder(view);
+    }
+
+    @Override
+    public void onBindViewHolder(@NonNull Myholder viewHolder, int i) {
+        if (mList == null || mList.isEmpty()) {
+            return;
+        } else {
+            if (i == mList.size() - 1) {
+                viewHolder.viewLine.setVisibility(View.GONE);//最后一条数据隐藏线条
+            }
+            GlideImageLoader.centerImage(viewHolder.ivIcon, "");
+            viewHolder.tvTitle.setText("");
+            viewHolder.tvTime.setText("");
+            viewHolder.tvContent.setText("");
+            position = i;
+            viewHolder.itemLayout.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    itemClick.itemClick(position);
+                }
+            });
+        }
+    }
+
+    @Override
+    public int getItemCount() {
+        return mList == null ? 0 : mList.size();
+    }
+
+    class Myholder extends RecyclerView.ViewHolder {
+        private ImageView ivIcon;//头像
+        private TextView tvTitle;//标题
+        private TextView tvTime;//时间
+        private TextView tvContent;//每条消息的内容,这里最多只显示一行
+        private View viewLine;//item之间的线条
+        private LinearLayout itemLayout;//整个item布局
+
+        public Myholder(View view) {
+            super(view);
+            ivIcon = view.findViewById(R.id.iv_icon);
+            tvTitle = view.findViewById(R.id.tv_title);
+            tvTime = view.findViewById(R.id.tv_time);
+            tvContent = view.findViewById(R.id.tv_content);
+            viewLine = view.findViewById(R.id.view_line);
+            itemLayout = view.findViewById(R.id.item_layout);
+        }
+    }
+
+    /**
+     * 设置每一条消息的回调
+     */
+    public interface ItemOnClickListener {
+        /**
+         * @param position,当前消息在获取数据集合中的对应位置
+         */
+        void itemClick(int position);
+    }
+}

+ 24 - 2
app/src/main/java/com/sheep/gamegroup/view/fragment/FragmentMessageCenter.java

@@ -6,20 +6,31 @@ import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.OrientationHelper;
+import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
 
+import com.sheep.gamegroup.view.adapter.MessageLeftAdapter;
 import com.sheep.jiuyan.samllsheep.R;
 
+import java.util.List;
+
 /**
  * created on:2018/8/28 on 12:32
  * created by: YSL
  * 描述:
  */
 @SuppressLint("ValidFragment")
-public class FragmentMessageCenter extends Fragment{
+public class FragmentMessageCenter extends Fragment implements MessageLeftAdapter.ItemOnClickListener{
     private Context mContext;
+    private RecyclerView recyclerView;
+    private MessageLeftAdapter adapter;
+    private List<?>mList;
 
     public FragmentMessageCenter(Context mContext) {
         this.mContext = mContext;
@@ -28,12 +39,23 @@ public class FragmentMessageCenter extends Fragment{
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        View view=LayoutInflater.from(mContext).inflate(R.layout.layout_fragment_mseeages,null);
+        View view = LayoutInflater.from(mContext).inflate(R.layout.fragment_messagecenter, null);
+        recyclerView = view.findViewById(R.id.recycle_fragment_message_center);
         return view;
     }
 
     @Override
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
+        adapter = new MessageLeftAdapter(mContext,mList ,this);
+        LinearLayoutManager manager=new LinearLayoutManager(mContext);
+        manager.setOrientation(OrientationHelper.VERTICAL);
+        recyclerView.setLayoutManager(manager);
+        recyclerView.setAdapter(adapter);
+    }
+
+    @Override
+    public void itemClick(int position) {
+
     }
 }

+ 24 - 0
app/src/main/res/layout/activity_message_interaction.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <include layout="@layout/title" />
+
+    <TextView
+        android:id="@+id/tv_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="17dp"
+        android:layout_marginTop="17dp"
+        android:text="关于小绵羊的优化建议?"
+        android:textColor="#ff333333"
+        android:textSize="18sp" />
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/recycle_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginTop="15dp" />
+</LinearLayout>

+ 30 - 0
app/src/main/res/layout/activity_messagesystem.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <include layout="@layout/title" />
+
+    <TextView
+        android:id="@+id/tv_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="10dp"
+        android:text="xxxx任务上线"
+        android:textColor="#ff333333"
+        android:textSize="18sp" />
+
+    <TextView
+        android:id="@+id/tv_content"
+        android:layout_width="328dp"
+        android:layout_height="48dp"
+        android:layout_marginEnd="16dp"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="15dp"
+        android:text="xx任务上线,限量1000分,任务奖励1元,赶紧去领取吧
+~!xx任务上线,限量1000分,任务奖励1元,赶紧去领取吧~!"
+        android:textColor="#ff666666"
+        android:textSize="13sp" />
+</LinearLayout>

+ 68 - 0
app/src/main/res/layout/adapter_message_interaction.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:id="@+id/item_layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+
+        <com.kfzs.android.view.widget.CircleImageView
+            android:id="@+id/iv_icon"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginBottom="15dp"
+            android:layout_marginStart="17dp"
+            android:layout_marginTop="15dp"
+            android:src="@mipmap/add_black_img" />
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="40dp"
+            android:layout_marginBottom="15dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginTop="15dp">
+
+            <TextView
+                android:id="@+id/tv_people"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="我回复"
+                android:textColor="#ff999999"
+                android:textSize="11sp"
+                />
+            <TextView
+                android:id="@+id/tv_time"
+                android:layout_toRightOf="@id/tv_people"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="10dp"
+                android:text="06-12 10:30"
+                android:textColor="#ff999999"
+                android:textSize="11sp"
+                />
+
+            <TextView
+                android:id="@+id/tv_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:singleLine="true"
+                android:text="xx任务上线,限量1000分,任务奖励1元,赶紧去领.102122."
+                android:textColor="#ff666666"
+                android:textSize="13sp" />
+
+        </RelativeLayout>
+
+    </LinearLayout>
+
+    <View
+        android:id="@+id/view_line"
+        android:layout_width="match_parent"
+        android:layout_height="2px"
+        android:layout_marginStart="68dp"
+        android:background="@color/gray_5" />
+</LinearLayout>

+ 68 - 0
app/src/main/res/layout/adapter_message_left_fragment.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:id="@+id/item_layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+
+        <com.kfzs.android.view.widget.CircleImageView
+            android:id="@+id/iv_icon"
+            android:layout_width="40dp"
+            android:layout_height="40dp"
+            android:layout_marginBottom="15dp"
+            android:layout_marginStart="17dp"
+            android:layout_marginTop="15dp"
+            android:src="@mipmap/add_black_img" />
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="40dp"
+            android:layout_marginBottom="15dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginTop="15dp">
+
+            <TextView
+                android:id="@+id/tv_title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="系统消息"
+                android:textColor="#ff333333"
+                android:textSize="15sp"
+                android:textStyle="bold" />
+
+            <TextView
+                android:id="@+id/tv_time"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_marginEnd="20dp"
+                android:text="今天 8:58"
+                android:textColor="#ff999999"
+                android:textSize="11sp" />
+
+            <TextView
+                android:id="@+id/tv_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:singleLine="true"
+                android:text="xx任务上线,限量1000分,任务奖励1元,赶紧去领.102122."
+                android:textColor="#ff666666"
+                android:textSize="13sp" />
+
+        </RelativeLayout>
+
+    </LinearLayout>
+
+    <View
+        android:id="@+id/view_line"
+        android:layout_width="match_parent"
+        android:layout_height="2px"
+        android:layout_marginStart="68dp"
+        android:background="@color/gray_5" />
+</LinearLayout>

+ 10 - 0
app/src/main/res/layout/fragment_messagecenter.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/recycle_fragment_message_center"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+</android.support.constraint.ConstraintLayout>