90
91
        SoftKeyBoardListener.setListener(getActivity(), new SoftKeyBoardListener.OnSoftKeyBoardChangeListener() {
92
            @Override
93
            public void keyBoardShow(int height) {
94
95
            }
96
97
            @Override
98
            public void keyBoardHide(int height) {
99
                dialogFragment.dismiss();
100
            }
101
        });
102
        return dialogFragment;
103
    }
104
105
    @Override
106
    public void onClick(View view) {
107
        switch (view.getId()) {
108
            case R.id.dialogPublish:
109
                if (commonDialogFragmentListener != null && editText.getText().toString().trim().length() > 0) {
110
                    dismiss();
111
                    commonDialogFragmentListener.publish();
112
                }
113
                break;
114
        }
115
    }
116
117
    public interface OnCommonDialogFragmentListener {
118
        void updateComment(String comment);
119
        void publish();
120
    }
121
122
    public void setOnCommonDialogFragmentListener(OnCommonDialogFragmentListener listener) {
123
        this.commonDialogFragmentListener = listener;
124
    }
125
126
}

+ 62 - 0
app/src/main/java/com/electric/chargingpile/iview/SoftKeyBoardListener.java

@ -0,0 +1,62 @@
1
package com.electric.chargingpile.iview;
2
3
import android.app.Activity;
4
import android.graphics.Rect;
5
import android.view.View;
6
import android.view.ViewTreeObserver;
7
8
public class SoftKeyBoardListener {
9
    private View rootView;  //activity的根视图
10
    int rootViewVisibleHeight;  //纪录根视图的显示高度
11
    private OnSoftKeyBoardChangeListener onSoftKeyBoardChangeListener;
12
    public SoftKeyBoardListener(Activity activity) {
13
        //获取activity的根视图
14
        rootView = activity.getWindow().getDecorView();
15
        //监听视图树中全局布局发生改变或者视图树中的某个视图的可视状态发生改变
16
        rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
17
            @Override
18
            public void onGlobalLayout() {
19
                //获取当前根视图在屏幕上显示的大小
20
                Rect r = new Rect();
21
                rootView.getWindowVisibleDisplayFrame(r);
22
                int visibleHeight = r.height();
23
                System.out.println(""+visibleHeight);
24
                if (rootViewVisibleHeight == 0) {
25
                    rootViewVisibleHeight = visibleHeight;
26
                    return;
27
                }
28
                //根视图显示高度没有变化,可以看作软键盘显示/隐藏状态没有改变
29
                if (rootViewVisibleHeight == visibleHeight) {
30
                    return;
31
                }
32
                //根视图显示高度变小超过200,可以看作软键盘显示了
33
                if (rootViewVisibleHeight - visibleHeight > 200) {
34
                    if (onSoftKeyBoardChangeListener != null) {
35
                        onSoftKeyBoardChangeListener.keyBoardShow(rootViewVisibleHeight - visibleHeight);
36
                    }
37
                    rootViewVisibleHeight = visibleHeight;
38
                    return;
39
                }
40
                //根视图显示高度变大超过200,可以看作软键盘隐藏了
41
                if (visibleHeight - rootViewVisibleHeight > 200) {
42
                    if (onSoftKeyBoardChangeListener != null) {
43
                        onSoftKeyBoardChangeListener.keyBoardHide(visibleHeight - rootViewVisibleHeight);
44
                    }
45
                    rootViewVisibleHeight = visibleHeight;
46
                    return;
47
                }
48
            }
49
        });
50
    }
51
    private void setOnSoftKeyBoardChangeListener(OnSoftKeyBoardChangeListener onSoftKeyBoardChangeListener) {
52
        this.onSoftKeyBoardChangeListener = onSoftKeyBoardChangeListener;
53
    }
54
    public interface OnSoftKeyBoardChangeListener {
55
        void keyBoardShow(int height);
56
        void keyBoardHide(int height);
57
    }
58
    public static void setListener(Activity activity, OnSoftKeyBoardChangeListener onSoftKeyBoardChangeListener) {
59
        SoftKeyBoardListener softKeyBoardListener = new SoftKeyBoardListener(activity);
60
        softKeyBoardListener.setOnSoftKeyBoardChangeListener(onSoftKeyBoardChangeListener);
61
    }
62
}

+ 7 - 7
app/src/main/res/layout/activity_publish_items.xml

@ -53,10 +53,9 @@
53 53
            android:orientation="horizontal">
54 54

55 55
            <LinearLayout
56
                android:id="@+id/publish_picture"
56
                android:id="@+id/publish_video"
57 57
                android:layout_width="wrap_content"
58 58
                android:layout_height="wrap_content"
59
                android:layout_centerHorizontal="true"
60 59
                android:gravity="center"
61 60
                android:orientation="vertical"
62 61
                android:padding="20dp">
@ -64,21 +63,22 @@
64 63
                <ImageView
65 64
                    android:layout_width="wrap_content"
66 65
                    android:layout_height="wrap_content"
67
                    android:background="@drawable/app_publish_pic_icon" />
66
                    android:background="@drawable/app_publish_video_icon" />
68 67

69 68
                <TextView
70 69
                    android:layout_width="wrap_content"
71 70
                    android:layout_height="wrap_content"
72 71
                    android:layout_marginTop="10dp"
73
                    android:text="图文"
72
                    android:text="视频"
74 73
                    android:textColor="@color/color_222222"
75 74
                    android:textSize="15sp" />
76 75
            </LinearLayout>
77 76

78 77
            <LinearLayout
79
                android:id="@+id/publish_video"
78
                android:id="@+id/publish_picture"
80 79
                android:layout_width="wrap_content"
81 80
                android:layout_height="wrap_content"
81
                android:layout_centerHorizontal="true"
82 82
                android:gravity="center"
83 83
                android:orientation="vertical"
84 84
                android:padding="20dp">
@ -86,13 +86,13 @@
86 86
                <ImageView
87 87
                    android:layout_width="wrap_content"
88 88
                    android:layout_height="wrap_content"
89
                    android:background="@drawable/app_publish_video_icon" />
89
                    android:background="@drawable/app_publish_pic_icon" />
90 90

91 91
                <TextView
92 92
                    android:layout_width="wrap_content"
93 93
                    android:layout_height="wrap_content"
94 94
                    android:layout_marginTop="10dp"
95
                    android:text="视频"
95
                    android:text="图文"
96 96
                    android:textColor="@color/color_222222"
97 97
                    android:textSize="15sp" />
98 98
            </LinearLayout>

+ 1 - 0
app/src/main/res/layout/fragment_chat_content_pictures.xml

@ -111,6 +111,7 @@
111 111
                    android:id="@+id/topicTitle"
112 112
                    android:layout_width="wrap_content"
113 113
                    android:layout_height="wrap_content"
114
                    android:ellipsize="end"
114 115
                    android:maxLines="1"
115 116
                    android:paddingLeft="5dp"
116 117
                    android:textColor="#ffffff"

+ 2 - 1
app/src/main/res/layout/fragment_chat_content_video.xml

@ -127,6 +127,7 @@
127 127
                    android:id="@+id/topicTitle"
128 128
                    android:layout_width="wrap_content"
129 129
                    android:layout_height="wrap_content"
130
                    android:ellipsize="end"
130 131
                    android:maxLines="1"
131 132
                    android:paddingLeft="5dp"
132 133
                    android:textColor="#ffffff"
@ -134,7 +135,7 @@
134 135
                    app:layout_constraintBottom_toBottomOf="parent"
135 136
                    app:layout_constraintLeft_toRightOf="@+id/topicIcon"
136 137
                    app:layout_constraintTop_toTopOf="parent"
137
                    tools:text="#新能源#" />
138
                    tools:text="#新能源#是的咖啡机圣诞快乐附件可是大家反馈律师费了十多斤风口浪尖水电费会计师了多费劲考虑送到" />
138 139
            </android.support.constraint.ConstraintLayout>
139 140
140 141

+ 73 - 0
app/src/main/res/layout/fragment_common_dialog.xml

@ -0,0 +1,73 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:background="#00f00f"
7
    android:layout_height="match_parent">
8
9
    <!-- 底部评论输入及发布 -->
10
    <android.support.constraint.ConstraintLayout
11
        android:layout_width="match_parent"
12
        android:layout_height="wrap_content"
13
        android:background="#535353"
14
        android:minHeight="54dp"
15
        app:layout_constraintBottom_toBottomOf="parent"
16
        app:layout_constraintEnd_toEndOf="parent"
17
        app:layout_constraintStart_toStartOf="parent">
18
19
        <android.support.constraint.ConstraintLayout
20
            android:id="@+id/bWriteComment"
21
            android:layout_width="0dp"
22
            android:layout_height="30dp"
23
            android:layout_marginLeft="15dp"
24
            android:background="@drawable/bg_comment_shape"
25
            app:layout_constraintBottom_toBottomOf="parent"
26
            app:layout_constraintLeft_toLeftOf="parent"
27
            app:layout_constraintRight_toLeftOf="@+id/dialogPublish"
28
            app:layout_constraintTop_toTopOf="parent">
29
30
            <ImageView
31
                android:id="@+id/dialogIcon"
32
                android:layout_width="wrap_content"
33
                android:layout_height="wrap_content"
34
                android:layout_marginStart="15dp"
35
                android:paddingRight="5dp"
36
                app:layout_constraintBottom_toBottomOf="parent"
37
                app:layout_constraintStart_toStartOf="parent"
38
                app:layout_constraintTop_toTopOf="parent"
39
                app:srcCompat="@drawable/write_comment_icon" />
40
41
            <EditText
42
                android:id="@+id/dialogEdit"
43
                android:background="@null"
44
                android:layout_width="0dp"
45
                android:layout_height="wrap_content"
46
                android:hint="优质评论会被优先展示"
47
                android:textColor="#ffffff"
48
                android:textColorHint="#7e7e7e"
49
                android:textSize="14sp"
50
                app:layout_constraintBottom_toBottomOf="parent"
51
                app:layout_constraintRight_toRightOf="parent"
52
                app:layout_constraintLeft_toRightOf="@+id/dialogIcon"
53
                app:layout_constraintTop_toTopOf="parent" />
54
        </android.support.constraint.ConstraintLayout>
55
56
        <TextView
57
            android:id="@+id/dialogPublish"
58
            android:layout_width="wrap_content"
59
            android:layout_height="0dp"
60
            android:gravity="center_vertical"
61
            android:paddingLeft="13dp"
62
            android:paddingRight="15dp"
63
            android:text="发布"
64
            android:textColor="#7e7e7e"
65
            android:textSize="14sp"
66
            app:layout_constraintBottom_toBottomOf="parent"
67
            app:layout_constraintRight_toRightOf="parent"
68
            app:layout_constraintTop_toTopOf="parent"
69
            tools:layout_editor_absoluteX="348dp"
70
            tools:layout_editor_absoluteY="19dp" />
71
    </android.support.constraint.ConstraintLayout>
72
73
</android.support.constraint.ConstraintLayout>

+ 6 - 0
app/src/main/res/values/styles.xml

@ -6,6 +6,12 @@
6 6
        <item name="colorAccent">@color/colorAccent</item>
7 7

8 8
    </style>
9
    <style name="BottomDialog" parent="@style/AppTheme">
10
        <item name="android:layout_width">match_parent</item>
11
        <item name="android:layout_height">wrap_content</item>
12
        <item name="android:windowIsFloating">true</item>
13
        <item name="android:windowSoftInputMode">stateAlwaysVisible</item><!--显示软件盘-->
14
    </style>
9 15

10 16
    <style name="actionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
11 17
        <item name="android:textColorPrimary">@android:color/primary_text_light</item>

首页分享图标优化 · e85f381d0b - Gogs: Go Git Service
Преглед на файлове

首页分享图标优化

huyuguo преди 7 години
родител
ревизия
e85f381d0b

BIN
app/.DS_Store


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

@ -234,6 +234,15 @@ public class ChatRecommendAdapter extends RecyclerView.Adapter<IViewHolder> {
234 234
            } else {
235 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,32 +0,0 @@
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,7 +7,6 @@ import android.support.v4.app.Fragment;
7 7
import android.support.v7.widget.RecyclerView;
8 8
import android.support.v7.widget.StaggeredGridLayoutManager;
9 9
import android.text.TextUtils;
10
import android.util.Log;
11 10
import android.view.LayoutInflater;
12 11
import android.view.View;
13 12
import android.view.ViewGroup;
@ -22,7 +21,6 @@ import com.electric.chargingpile.activity.PublishItemsActivity;
22 21
import com.electric.chargingpile.activity.TopicDetailActivity;
23 22
import com.electric.chargingpile.activity.VideoDetaislActivity;
24 23
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
25
import com.electric.chargingpile.adapter.ChatRecommendItemDecoration;
26 24
import com.electric.chargingpile.adapter.TopicDetailAdapter;
27 25
import com.electric.chargingpile.application.MainApplication;
28 26
import com.electric.chargingpile.data.ChatBeanLab;
@ -37,9 +35,18 @@ import com.electric.chargingpile.util.ToastUtil;
37 35
import com.zhy.http.okhttp.OkHttpUtils;
38 36
import com.zhy.http.okhttp.callback.StringCallback;
39 37
38
import java.io.Serializable;
40 39
import java.util.ArrayList;
41 40
import java.util.HashMap;
41
import java.util.List;
42 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 50
import okhttp3.Call;
44 51
45 52
public class ChatRecommendFragment extends Fragment implements View.OnClickListener {
@ -118,52 +125,35 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
118 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,51 +30,15 @@
30 30
        android:id="@+id/chat_share_info_remind"
31 31
        android:layout_width="wrap_content"
32 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 35
        android:layout_marginRight="3dp"
35
        android:layout_marginBottom="24dp"
36 36
        android:layout_toLeftOf="@+id/iv_ask"
37 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 39
    <include
76
        android:visibility="gone"
77 40
        layout="@layout/activity_no_net_img"
78 41
        android:layout_width="match_parent"
79
        android:layout_height="match_parent" />
42
        android:layout_height="match_parent"
43
        android:visibility="gone" />
80 44
</RelativeLayout>