Parcourir la Source

首页分享图标优化

huyuguo 5 ans auparavant
Parent
commit
e85f381d0b

BIN
app/.DS_Store


+ 9 - 0
app/src/main/java/com/electric/chargingpile/adapter/ChatRecommendAdapter.java

234
            } else {
234
            } else {
235
                contentViewHolder.likeNum.setVisibility(View.GONE);
235
                contentViewHolder.likeNum.setVisibility(View.GONE);
236
            }
236
            }
237
238
            contentViewHolder.image_video_item.setOnClickListener(new View.OnClickListener() {
239
                @Override
240
                public void onClick(View view) {
241
                    if (onRecyclerItemClickListener != null) {
242
                        onRecyclerItemClickListener.onItemClickListener(position, 1);
243
                    }
244
                }
245
            });
237
        }
246
        }
238
247
239
    }
248
    }

+ 0 - 32
app/src/main/java/com/electric/chargingpile/adapter/ChatRecommendItemDecoration.java

1
package com.electric.chargingpile.adapter;
2
3
import android.graphics.Rect;
4
import android.support.v7.widget.RecyclerView;
5
import android.support.v7.widget.StaggeredGridLayoutManager;
6
import android.util.Log;
7
import android.view.View;
8
9
import com.electric.chargingpile.util.DensityUtil;
10
11
public class ChatRecommendItemDecoration extends RecyclerView.ItemDecoration {
12
    private static final String TAG = "ChatRecommendItemDecoration";
13
    private StaggeredGridLayoutManager.LayoutParams layoutParams;
14
15
    @Override
16
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
17
        layoutParams = (StaggeredGridLayoutManager.LayoutParams)view.getLayoutParams();
18
19
        int position = parent.getChildAdapterPosition(view);
20
        Log.d(TAG, "getItemOffsets: " + position + view.getClass() + ":" + parent.getClass());
21
        if (position > 0) {
22
            if (layoutParams.getSpanIndex() %2 == 0) {
23
                outRect.left = DensityUtil.dip2px(view.getContext(), 15);
24
                outRect.right = DensityUtil.dip2px(view.getContext(), 5);
25
            } else {
26
                outRect.right = DensityUtil.dip2px(view.getContext(), 15);
27
                outRect.left = DensityUtil.dip2px(view.getContext(), 5);
28
            }
29
        }
30
31
    }
32
}

+ 36 - 46
app/src/main/java/com/electric/chargingpile/fragment/ChatRecommendFragment.java

7
import android.support.v7.widget.RecyclerView;
7
import android.support.v7.widget.RecyclerView;
8
import android.support.v7.widget.StaggeredGridLayoutManager;
8
import android.support.v7.widget.StaggeredGridLayoutManager;
9
import android.text.TextUtils;
9
import android.text.TextUtils;
10
import android.util.Log;
11
import android.view.LayoutInflater;
10
import android.view.LayoutInflater;
12
import android.view.View;
11
import android.view.View;
13
import android.view.ViewGroup;
12
import android.view.ViewGroup;
22
import com.electric.chargingpile.activity.TopicDetailActivity;
21
import com.electric.chargingpile.activity.TopicDetailActivity;
23
import com.electric.chargingpile.activity.VideoDetaislActivity;
22
import com.electric.chargingpile.activity.VideoDetaislActivity;
24
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
23
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
25
import com.electric.chargingpile.adapter.ChatRecommendItemDecoration;
26
import com.electric.chargingpile.adapter.TopicDetailAdapter;
24
import com.electric.chargingpile.adapter.TopicDetailAdapter;
27
import com.electric.chargingpile.application.MainApplication;
25
import com.electric.chargingpile.application.MainApplication;
28
import com.electric.chargingpile.data.ChatBeanLab;
26
import com.electric.chargingpile.data.ChatBeanLab;
37
import com.zhy.http.okhttp.OkHttpUtils;
35
import com.zhy.http.okhttp.OkHttpUtils;
38
import com.zhy.http.okhttp.callback.StringCallback;
36
import com.zhy.http.okhttp.callback.StringCallback;
39
37
38
import java.io.Serializable;
40
import java.util.ArrayList;
39
import java.util.ArrayList;
41
import java.util.HashMap;
40
import java.util.HashMap;
41
import java.util.List;
42
import java.util.Map;
42
import java.util.Map;
43
44
import io.reactivex.Observable;
45
import io.reactivex.android.schedulers.AndroidSchedulers;
46
import io.reactivex.disposables.Disposable;
47
import io.reactivex.functions.Consumer;
48
import io.reactivex.functions.Predicate;
49
import io.reactivex.schedulers.Schedulers;
43
import okhttp3.Call;
50
import okhttp3.Call;
44
51
45
public class ChatRecommendFragment extends Fragment implements View.OnClickListener {
52
public class ChatRecommendFragment extends Fragment implements View.OnClickListener {
118
                    return;
125
                    return;
119
                }
126
                }
120
127
121
                if (type == 2) {
122
128
123
                }
129
                final List<ChatRecommendBean> beans = ChatBeanLab.get(getContext()).beans();
130
                ChatRecommendBean bean = beans.get(position - 1);
131
                Disposable disposable = Observable.fromIterable(beans).filter(new Predicate<ChatRecommendBean>() {
132
                    @Override
133
                    public boolean test(ChatRecommendBean chatRecommendBean) throws Exception {
134
                        return chatRecommendBean.targetType != 25;
135
                    }
136
                }).toList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<ChatRecommendBean>>() {
137
                    @Override
138
                    public void accept(List<ChatRecommendBean> list) throws Exception {
139
                        ChatRecommendBean chatRecommendBean = beans.get(position - 1);
124
140
125
//                final ArrayList<ChatRecommendBean> beans = chatRecommendAdapter.getCurrentData();
126
//                ChatRecommendBean bean = beans.get(position - 1);
127
//                if (bean.targetType == ChatRecommendBean.TARGET_TYPE_IMAGE_TOPIC) {
128
//                    Intent intent = new Intent(getActivity(), TopicDetailActivity.class);
129
//                    intent.putExtra("topicId", bean.targetId);
130
//                    startActivity(intent);
131
//                } else {
132
//                    Disposable disposable = Observable
133
//                            .fromIterable(beans)
134
//                            .filter(new Predicate<ChatRecommendBean>() {
135
//                                @Override
136
//                                public boolean test(ChatRecommendBean chatRecommendBean) throws Exception {
137
//                                    return chatRecommendBean.targetType != 25;
138
//                                }
139
//                            }).toList()
140
//                            .subscribeOn(Schedulers.io())
141
//                            .observeOn(AndroidSchedulers.mainThread())
142
//                            .subscribe(new Consumer<List<ChatRecommendBean>>() {
143
//                                @Override
144
//                                public void accept(List<ChatRecommendBean> list) throws Exception {
145
//                                    ChatRecommendBean chatRecommendBean = beans.get(position - 1);
146
//
147
//                                    int index = 0;
148
//                                    for (int i = 0; i < list.size(); i++) {
149
//                                        ChatRecommendBean tmp = list.get(i);
150
//                                        if (tmp.targetType == chatRecommendBean.targetType &&
151
//                                                tmp.targetId == chatRecommendBean.targetId) {
152
//                                            index = i;
153
//                                            break;
154
//                                        }
155
//                                    }
156
//
157
//                                    Intent intent = new Intent(getActivity(), VideoDetaislActivity.class);
158
//                                    intent.putExtra("list", (Serializable) list);
159
//                                    intent.putExtra("pos", index);
160
//                                    startActivity(intent);
161
//
162
//                                }
163
//                            });
164
//                }
165
                // TODO update by huyuguo
166
                Log.d(TAG, "onItemClickListener: position:" + position + ",type:" + type);
141
                        int index = 0;
142
                        for (int i = 0; i < list.size(); i++) {
143
                            ChatRecommendBean tmp = list.get(i);
144
                            if (tmp.targetType == chatRecommendBean.targetType &&
145
                                    tmp.targetId == chatRecommendBean.targetId) {
146
                                index = i;
147
                                break;
148
                            }
149
                        }
150
151
                        Intent intent = new Intent(getActivity(), VideoDetaislActivity.class);
152
                        intent.putExtra("list", (Serializable) list);
153
                        intent.putExtra("pos", index);
154
                        startActivity(intent);
155
                    }
156
                });
167
            }
157
            }
168
        });
158
        });
169
159

BIN
app/src/main/res/drawable-hdpi/app_share_talk_icon.png


BIN
app/src/main/res/drawable-mdpi/app_share_talk_icon.png


BIN
app/src/main/res/drawable-xhdpi/app_share_talk_icon.png


BIN
app/src/main/res/drawable-xxhdpi/app_share_talk_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/app_share_talk_icon.png


+ 4 - 40
app/src/main/res/layout/fragment_chat_recommend.xml

30
        android:id="@+id/chat_share_info_remind"
30
        android:id="@+id/chat_share_info_remind"
31
        android:layout_width="wrap_content"
31
        android:layout_width="wrap_content"
32
        android:layout_height="wrap_content"
32
        android:layout_height="wrap_content"
33
        android:layout_alignParentBottom="true"
33
        android:layout_alignTop="@+id/iv_ask"
34
        android:layout_alignBottom="@+id/iv_ask"
34
        android:layout_marginRight="3dp"
35
        android:layout_marginRight="3dp"
35
        android:layout_marginBottom="24dp"
36
        android:layout_toLeftOf="@+id/iv_ask"
36
        android:layout_toLeftOf="@+id/iv_ask"
37
        android:src="@drawable/chat_share_info_remind" />
37
        android:src="@drawable/chat_share_info_remind" />
38
38
39
    <LinearLayout
40
        android:id="@+id/chat_share_info_remindxx"
41
        android:layout_width="wrap_content"
42
        android:layout_height="40dp"
43
        android:layout_alignParentBottom="true"
44
        android:layout_marginBottom="24dp"
45
        android:layout_toLeftOf="@+id/iv_ask"
46
        android:gravity="center_vertical"
47
        android:orientation="horizontal"
48
        android:visibility="gone">
49
50
        <RelativeLayout
51
            android:layout_width="wrap_content"
52
            android:layout_height="match_parent"
53
            android:background="@drawable/bg_yuan_black">
54
55
            <TextView
56
                android:id="@+id/chat_share_info"
57
                android:layout_width="wrap_content"
58
                android:layout_height="match_parent"
59
                android:gravity="center"
60
                android:paddingLeft="10dp"
61
                android:paddingRight="10dp"
62
                android:text="分享内容获电币"
63
                android:textColor="@color/white" />
64
        </RelativeLayout>
65
66
67
        <ImageView
68
            android:layout_width="15dp"
69
            android:layout_height="15dp"
70
            android:layout_marginLeft="-5dp"
71
            android:alpha="0.5"
72
            android:src="@drawable/app_sanjiao_right" />
73
    </LinearLayout>
74
75
    <include
39
    <include
76
        android:visibility="gone"
77
        layout="@layout/activity_no_net_img"
40
        layout="@layout/activity_no_net_img"
78
        android:layout_width="match_parent"
41
        android:layout_width="match_parent"
79
        android:layout_height="match_parent" />
42
        android:layout_height="match_parent"
43
        android:visibility="gone" />
80
</RelativeLayout>
44
</RelativeLayout>