316044749 пре 7 година
родитељ
комит
013d8c3508

+ 1 - 0
app/build.gradle

@@ -49,6 +49,7 @@ dependencies {
     compile 'com.muddzdev:styleabletoast:2.0.1'
     compile 'org.greenrobot:eventbus:3.1.1'
     compile 'me.zhanghai.android.materialratingbar:library:1.2.0'
+    compile 'com.github.vipulasri:timelineview:1.0.6'
     //导航
     compile 'com.amap.api:navi-3dmap:5.6.0_3dmap5.7.0'
     //定位

+ 54 - 5
app/src/main/java/com/ynstkz/shitu/android/activity/MineCommentActivity.java

@@ -2,6 +2,8 @@ package com.ynstkz.shitu.android.activity;
 
 import android.os.Bundle;
 import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
@@ -9,10 +11,14 @@ import com.common.library.okhttp.callback.Callback;
 import com.common.library.pulltorefresh.PullToRefreshListView;
 import com.google.gson.Gson;
 import com.ynstkz.shitu.android.R;
+import com.ynstkz.shitu.android.adapter.MineCommentItemAdapter;
 import com.ynstkz.shitu.android.base.TitleBarActivity;
 import com.ynstkz.shitu.android.bean.MyCommnetBean;
 import com.ynstkz.shitu.android.data.RequestGroup;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import butterknife.Bind;
 import okhttp3.Call;
 import okhttp3.Response;
@@ -29,6 +35,18 @@ public class MineCommentActivity extends TitleBarActivity {
     RelativeLayout viewTitle;
     @Bind(R.id.pullToRefresh)
     PullToRefreshListView pullToRefresh;
+    @Bind(R.id.rl_nodata)
+    RelativeLayout rlNodata;
+    @Bind(R.id.iv_back)
+    ImageView ivBack;
+    @Bind(R.id.iv_nodata_icon)
+    ImageView ivNodataIcon;
+    @Bind(R.id.tv_nodata_lab)
+    TextView tvNodataLab;
+
+    private int pageNumber;
+    private List<OrgCommentItemBean> listOrgComments;
+    private MineCommentItemAdapter mineCommentItemAdapter;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -50,6 +68,7 @@ public class MineCommentActivity extends TitleBarActivity {
 
     private void initData() {
 
+        pageNumber = 1;
         getMyCommnet();
     }
 
@@ -62,7 +81,7 @@ public class MineCommentActivity extends TitleBarActivity {
      */
     private void getMyCommnet() {
 
-        RequestGroup.getMyCommentList(new Callback() {
+        RequestGroup.getMyCommentList(pageNumber + "", new Callback() {
             @Override
             public Object parseNetworkResponse(Response response, int id) throws Exception {
                 return new Gson().fromJson(response.body().string(), MyCommnetBean.class);
@@ -75,10 +94,30 @@ public class MineCommentActivity extends TitleBarActivity {
 
             @Override
             public void onResponse(Object response, int id) {
-                MyCommnetBean myCommnetBean = (MyCommnetBean)response;
-                if(myCommnetBean != null){
-                    if("200".equals(myCommnetBean.getCode())){
-
+                MyCommnetBean myCommnetBean = (MyCommnetBean) response;
+                if (myCommnetBean != null) {
+                    if ("200".equals(myCommnetBean.getCode())) {
+                        if (myCommnetBean.getData() != null) {
+                            if (myCommnetBean.getData().getEvaluateList() != null && myCommnetBean.getData().getEvaluateList().size() > 0) {
+                                if (pageNumber == 1) {
+                                    if (listOrgComments == null) {
+                                        listOrgComments = new ArrayList<>();
+                                    }
+                                    listOrgComments.clear();
+                                    listOrgComments.addAll(myCommnetBean.getData().getEvaluateList());
+                                    mineCommentItemAdapter = new MineCommentItemAdapter(MineCommentActivity.this, listOrgComments);
+                                    pullToRefresh.setAdapter(mineCommentItemAdapter);
+                                    mineCommentItemAdapter.notifyDataSetChanged();
+                                } else {
+                                    listOrgComments.addAll(myCommnetBean.getData().getEvaluateList());
+                                    mineCommentItemAdapter.notifyDataSetChanged();
+                                }
+                            } else {
+                                showNoData();
+                            }
+                        } else {
+                            showNoData();
+                        }
                     } else {
                         showToast(myCommnetBean.getMsg());
                     }
@@ -86,4 +125,14 @@ public class MineCommentActivity extends TitleBarActivity {
             }
         });
     }
+
+    /**
+     * 显示无数据
+     */
+    private void showNoData() {
+        pullToRefresh.setVisibility(View.GONE);
+        rlNodata.setVisibility(View.VISIBLE);
+        ivNodataIcon.setImageResource(R.drawable.nodata_common);
+        tvNodataLab.setText(getString(R.string.nodata_comment));
+    }
 }

+ 9 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/OrgCommentItemBean.java

@@ -18,6 +18,7 @@ public class OrgCommentItemBean extends BaseBean{
     private String content;
     private int evaluateId;
     private int memberId;
+    private String address;
     private List<EvaluatePicListBean> evaluatePicList;
 
     public int getScore() {
@@ -92,6 +93,14 @@ public class OrgCommentItemBean extends BaseBean{
         this.evaluatePicList = evaluatePicList;
     }
 
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
     public static class EvaluatePicListBean {
         /**
          * evaluatePicId : 3

+ 96 - 0
app/src/main/java/com/ynstkz/shitu/android/adapter/MineCommentItemAdapter.java

@@ -0,0 +1,96 @@
+package com.ynstkz.shitu.android.adapter;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.common.library.adapter.CCAdapterHolder;
+import com.common.library.adapter.CCListAdapter;
+import com.common.library.utils.DateUtil;
+import com.github.vipulasri.timelineview.TimelineView;
+import com.ynstkz.shitu.android.R;
+import com.ynstkz.shitu.android.activity.OrgCommentItemBean;
+import com.ynstkz.shitu.android.utils.VectorDrawableUtils;
+
+import java.util.Date;
+import java.util.List;
+
+import me.zhanghai.android.materialratingbar.MaterialRatingBar;
+
+/**
+ * 作者:fuchangle on 2018/3/17 10:20
+ */
+
+public class MineCommentItemAdapter extends CCListAdapter{
+
+    private Context context;
+    private List<OrgCommentItemBean> adapterContent;
+    /**
+     * Construct list adapter.
+     *
+     * @param context        Context.
+     * @param adapterContent Content to display.
+     */
+    public MineCommentItemAdapter(Context context, List<OrgCommentItemBean> adapterContent) {
+        super(context, adapterContent);
+        this.context = context;
+        this.adapterContent = adapterContent;
+    }
+
+    @Override
+    public CCAdapterHolder createHolder(int type) {
+        return new CCAdapterHolder() {
+
+            TextView tvDate;
+            TimelineView timeMarker;
+            MaterialRatingBar rbScore;
+            TextView tvContent;
+            TextView tvOrgName;
+            ImageView ivOrgIcon;
+            TextView tvAddress;
+
+            @Override
+            public int getResource() {
+                return R.layout.item_minecomment_list;
+            }
+
+            @Override
+            public void initializeView(View convertView) {
+                tvDate = convertView.findViewById(R.id.tv_date);
+                timeMarker = convertView.findViewById(R.id.time_marker);
+                rbScore = convertView.findViewById(R.id.rb_score);
+                tvContent = convertView.findViewById(R.id.tv_content);
+                tvOrgName = convertView.findViewById(R.id.tv_org_name);
+                ivOrgIcon = convertView.findViewById(R.id.iv_org_icon);
+                tvAddress = convertView.findViewById(R.id.tv_address);
+            }
+
+            @SuppressLint("SetTextI18n")
+            @Override
+            public void updateView(Object content, int position) {
+
+                OrgCommentItemBean orgCommentItemBean = adapterContent.get(position);
+                if(position == 0){
+                    timeMarker.setMarker(VectorDrawableUtils.getDrawable(context, R.drawable.ic_marker_inactive, R.color.main_color));
+                    tvDate.setText(DateUtil.format(new Date(orgCommentItemBean.getCreateTime()), "yyyy") + "\n" +
+                            DateUtil.format(new Date(orgCommentItemBean.getCreateTime()), "MM-dd"));
+                } else if (position == 1){
+                    timeMarker.setMarker(VectorDrawableUtils.getDrawable(context, R.drawable.ic_marker_active, R.color.main_color));
+                    tvDate.setText(DateUtil.format(new Date(orgCommentItemBean.getCreateTime()), "MM-dd"));
+                } else {
+                    timeMarker.setMarker(ContextCompat.getDrawable(context, R.drawable.ic_marker), ContextCompat.getColor(context, R.color.colorPrimary));
+                    tvDate.setText(DateUtil.format(new Date(orgCommentItemBean.getCreateTime()), "MM-dd"));
+                }
+                rbScore.setProgress(orgCommentItemBean.getScore() * 2);
+                tvContent.setText(orgCommentItemBean.getContent());
+                tvOrgName.setText(orgCommentItemBean.getMemberName());
+                Glide.with(context).load(orgCommentItemBean.getHeadPic()).into(ivOrgIcon);
+                tvAddress.setText(orgCommentItemBean.getAddress());
+            }
+        };
+    }
+}

+ 81 - 0
app/src/main/java/com/ynstkz/shitu/android/bean/TimeLineModelBean.java

@@ -0,0 +1,81 @@
+package com.ynstkz.shitu.android.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * 作者:fuchangle on 2018/3/17 10:22
+ */
+
+public class TimeLineModelBean implements Parcelable{
+
+    private String mMessage;
+    private String mDate;
+    private TimeLineStatus mStatus;
+
+    public TimeLineModelBean() {
+    }
+
+    public TimeLineModelBean(String mMessage, String mDate, TimeLineStatus mStatus) {
+        this.mMessage = mMessage;
+        this.mDate = mDate;
+        this.mStatus = mStatus;
+    }
+
+    public String getMessage() {
+        return mMessage;
+    }
+
+    public void semMessage(String message) {
+        this.mMessage = message;
+    }
+
+    public String getDate() {
+        return mDate;
+    }
+
+    public void setDate(String date) {
+        this.mDate = date;
+    }
+
+    public TimeLineStatus getStatus() {
+        return mStatus;
+    }
+
+    public void setStatus(TimeLineStatus mStatus) {
+        this.mStatus = mStatus;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(this.mMessage);
+        dest.writeString(this.mDate);
+        dest.writeInt(this.mStatus == null ? -1 : this.mStatus.ordinal());
+    }
+
+    protected TimeLineModelBean(Parcel in) {
+        this.mMessage = in.readString();
+        this.mDate = in.readString();
+        int tmpMStatus = in.readInt();
+        this.mStatus = tmpMStatus == -1 ? null : TimeLineStatus.values()[tmpMStatus];
+    }
+
+    public static final Parcelable.Creator<TimeLineModelBean> CREATOR = new Parcelable.Creator<TimeLineModelBean>() {
+        @Override
+        public TimeLineModelBean createFromParcel(Parcel source) {
+            return new TimeLineModelBean(source);
+        }
+
+        @Override
+        public TimeLineModelBean[] newArray(int size) {
+            return new TimeLineModelBean[size];
+        }
+    };
+}
+
+

+ 12 - 0
app/src/main/java/com/ynstkz/shitu/android/bean/TimeLineStatus.java

@@ -0,0 +1,12 @@
+package com.ynstkz.shitu.android.bean;
+
+/**
+ * Created by HP-HP on 07-06-2016.
+ */
+public enum TimeLineStatus {
+
+    COMPLETED,
+    ACTIVE,
+    INACTIVE;
+
+}

+ 2 - 1
app/src/main/java/com/ynstkz/shitu/android/data/RequestGroup.java

@@ -227,8 +227,9 @@ public class RequestGroup {
     /**
      * 我的评论
      */
-    public static void getMyCommentList(Callback callback){
+    public static void getMyCommentList(String pageNumber, Callback callback){
         Map<String, String> params = getSystemParams();
+        params.put("pageNumber", pageNumber);
         OkHttpUtils.get().url(UrlCat.URL_MY_COMMENT).addHeader(KEY_TOKEN,
                 SharedPreferencesUtils.getToken()).params(params).build().execute(callback);
     }

+ 37 - 0
app/src/main/java/com/ynstkz/shitu/android/utils/VectorDrawableUtils.java

@@ -0,0 +1,37 @@
+package com.ynstkz.shitu.android.utils;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.support.graphics.drawable.VectorDrawableCompat;
+import android.support.v4.content.ContextCompat;
+
+/**
+ * Created by Vipul on 28/12/16.
+ */
+
+public class VectorDrawableUtils {
+
+    public static Drawable getDrawable(Context context, int drawableResId) {
+        return VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme());
+    }
+
+    public static Drawable getDrawable(Context context, int drawableResId, int colorFilter) {
+        Drawable drawable = getDrawable(context, drawableResId);
+        drawable.setColorFilter(ContextCompat.getColor(context, colorFilter), PorterDuff.Mode.SRC_IN);
+        return drawable;
+    }
+
+    public static Bitmap getBitmap(Context context, int drawableId) {
+        Drawable drawable = getDrawable(context, drawableId);
+
+        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+        Canvas canvas = new Canvas(bitmap);
+        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+        drawable.draw(canvas);
+
+        return bitmap;
+    }
+}

+ 8 - 0
app/src/main/res/drawable/ic_marker.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+
+    <solid android:color="@color/main_color"/>
+
+</shape>

+ 6 - 0
app/src/main/res/drawable/ic_marker_active.xml

@@ -0,0 +1,6 @@
+<vector android:height="24dp" android:viewportHeight="426.667"
+    android:viewportWidth="426.667" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M213.3,0C95.5,0 0,95.5 0,213.3s95.5,213.3 213.3,213.3s213.3,-95.5 213.3,-213.3S331.2,0 213.3,0zM213.3,387.4c-96.1,0 -174.1,-77.9 -174.1,-174.1s77.9,-174.1 174.1,-174.1c96.1,0.1 174,78 174.1,174.1C387.4,309.5 309.5,387.4 213.3,387.4z"/>
+    <path android:fillColor="#FF000000" android:pathData="M213.3,213.3m-64,0a64,64 0,1 1,128 0a64,64 0,1 1,-128 0"/>
+    <path android:fillColor="#FF000000" android:pathData="M213.3,128C166.2,128 128,166.2 128,213.3s38.2,85.3 85.3,85.3s85.3,-38.2 85.3,-85.3S260.5,128 213.3,128zM213.3,256c-23.6,0 -42.7,-19.1 -42.7,-42.7s19.1,-42.7 42.7,-42.7S256,189.8 256,213.3S236.9,256 213.3,256z"/>
+</vector>

+ 4 - 0
app/src/main/res/drawable/ic_marker_inactive.xml

@@ -0,0 +1,4 @@
+<vector android:height="24dp" android:viewportHeight="426.667"
+    android:viewportWidth="426.667" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M213.3,0C95.5,0 0,95.5 0,213.3s95.5,213.3 213.3,213.3s213.3,-95.5 213.3,-213.3S331.2,0 213.3,0zM213.3,387.4c-96.1,0 -174.1,-77.9 -174.1,-174.1s77.9,-174.1 174.1,-174.1c96.1,0.1 174,78 174.1,174.1C387.4,309.5 309.5,387.4 213.3,387.4z"/>
+</vector>

+ 13 - 1
app/src/main/res/layout/activity_minecomment.xml

@@ -9,6 +9,18 @@
     <com.common.library.pulltorefresh.PullToRefreshListView
         android:id="@+id/pullToRefresh"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
+        android:layout_height="match_parent"
+        android:padding="@dimen/default_content_margin"
+        android:divider="@null"/>
+
+    <RelativeLayout
+        android:id="@+id/rl_nodata"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="gone">
+
+        <include layout="@layout/view_nodata"/>
+
+    </RelativeLayout>
 
 </LinearLayout>

+ 117 - 0
app/src/main/res/layout/item_minecomment_list.xml

@@ -0,0 +1,117 @@
+<?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="match_parent"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/tv_date"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="日期"/>
+
+    <com.github.vipulasri.timelineview.TimelineView
+        android:id="@+id/time_marker"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        app:markerInCenter = "false"
+        app:markerSize="20dp"
+        app:lineSize="3dp"
+        app:line="@color/colorPrimary"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="@dimen/company_10dp"
+        android:orientation="vertical">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="@dimen/company_15sp"
+            android:textColor="@color/main_color"
+            android:text="发布了评论"/>
+
+        <me.zhanghai.android.materialratingbar.MaterialRatingBar
+            android:id="@+id/rb_score"
+            android:layout_width="@dimen/company_90dp"
+            android:layout_height="@dimen/company_20dp"
+            android:layout_marginTop="@dimen/company_5dp"
+            android:isIndicator="true"
+            app:mrb_progressTint="@color/rb_color"
+            app:mrb_secondaryProgressTint="@color/color_999"
+            android:stepSize="0.5"
+            style="@style/Widget.MaterialRatingBar.RatingBar" />
+
+        <TextView
+            android:id="@+id/tv_content"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="@dimen/company_16sp"
+            android:textColor="@color/color_666"/>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/company_60dp"
+            android:orientation="horizontal"
+            android:padding="@dimen/company_5dp"
+            android:background="#F0F0F0">
+
+            <ImageView
+                android:id="@+id/iv_org_icon"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:src="@mipmap/ic_launcher"
+                android:scaleType="centerCrop"/>
+
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_marginLeft="@dimen/company_10dp">
+
+                <TextView
+                    android:id="@+id/tv_org_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="@dimen/company_15sp"
+                    android:textColor="@color/color_999"
+                    android:text="新东方英语学校"/>
+
+                <RelativeLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentBottom="true">
+
+                    <TextView
+                        android:id="@+id/tv_course_name"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textSize="@dimen/company_14sp"
+                        android:textColor="@color/color_999"
+                        android:text="初中英语"
+                        android:visibility="gone"/>
+
+                    <TextView
+                        android:id="@+id/tv_address"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_alignParentRight="true"
+                        android:textColor="@color/color_999"
+                        android:textSize="11sp"
+                        android:text="未名湖"/>
+
+                </RelativeLayout>
+
+            </RelativeLayout>
+
+        </LinearLayout>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/company_40dp" />
+
+    </LinearLayout>
+
+</LinearLayout>

+ 1 - 1
app/src/main/res/layout/view_phone_server.xml

@@ -51,7 +51,7 @@
             android:gravity="center"
             android:textSize="@dimen/company_16sp"
             android:textColor="@color/black"
-            android:text="我再逛逛"/>
+            android:text="联系客服"/>
 
     </LinearLayout>
 

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -9,5 +9,6 @@
 
     <string name="nodata_msg">亲,你还没有通知哦~</string>
     <string name="nodata_collect">亲,你还没有收藏哦~</string>
+    <string name="nodata_comment">亲,你还没有评论哦~</string>
 
 </resources>