Skip to content

Commit 0f35f79

Browse files
committed
闪存UI细节优化
1 parent 489be63 commit 0f35f79

File tree

15 files changed

+120
-24
lines changed

15 files changed

+120
-24
lines changed

app/src/main/java/com/rae/cnblogs/adapter/MomentAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public void onBindViewHolder(SimpleViewHolder viewHolder, int position, MomentBe
130130
holder.authorView.setText(m.getAuthorName());
131131
holder.dateView.setText(m.getPostTime());
132132
holder.summaryView.setText(m.getContent());
133-
holder.commentView.setText(m.getCommentCount());
133+
holder.androidTagView.setVisibility(m.isAndroidClient() ? View.VISIBLE : View.GONE);
134+
holder.commentView.setVisibility("0".equals(m.getCommentCount()) ? View.GONE : View.VISIBLE);
135+
holder.commentView.setText("0".equals(m.getCommentCount()) ? "" : m.getCommentCount() + "条回复");
134136
}
135137

136138
private static class ItemDeleteClickListener implements View.OnClickListener {

app/src/main/java/com/rae/cnblogs/fragment/MomentFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
5+
import android.util.Log;
56
import android.view.View;
67

78
import com.jcodecraeer.xrecyclerview.XRecyclerView;
@@ -210,6 +211,11 @@ public void onDeleteMomentSuccess() {
210211
AppUI.success(getContext(), R.string.tips_del_moment_success);
211212
}
212213

214+
@Override
215+
public void onReplyContChanged(int number) {
216+
Log.i("rae", "有回复我的;" + number);
217+
}
218+
213219
/**
214220
* 滚动到顶部
215221
*/

app/src/main/java/com/rae/cnblogs/model/MomentHolder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class MomentHolder extends SimpleViewHolder {
4141
public View deleteView; // 删除
4242
public Button followView; // 关注
4343
public ImageView thumbView; // 单张图片
44+
public View androidTagView; // 客户端标志
4445

4546

4647
// @BindView(R.id.img_blog_list_large_thumb)
@@ -63,6 +64,7 @@ public MomentHolder(View itemView) {
6364
deleteView = itemView.findViewById(R.id.img_close);
6465
thumbView = itemView.findViewById(R.id.img_thumb);
6566
followView = itemView.findViewById(R.id.btn_blogger_follow);
67+
androidTagView = itemView.findViewById(R.id.tv_android_tag);
6668
ButterKnife.bind(this, itemView);
6769
}
6870
}

app/src/main/java/com/rae/cnblogs/presenter/IMomentContract.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ interface View extends IPageView<MomentBean> {
3232
*/
3333
void onDeleteMomentSuccess();
3434

35+
/**
36+
* 有回复我的消息数量
37+
*/
38+
void onReplyContChanged(int number);
3539
}
3640
}

app/src/main/java/com/rae/cnblogs/presenter/impl/MomentPresenterImpl.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.rae.cnblogs.sdk.Empty;
1313
import com.rae.cnblogs.sdk.api.IMomentApi;
1414
import com.rae.cnblogs.sdk.bean.MomentBean;
15+
import com.rae.swift.Rx;
1516

1617
import org.greenrobot.eventbus.EventBus;
1718
import org.greenrobot.eventbus.Subscribe;
@@ -48,6 +49,25 @@ protected Observable<List<MomentBean>> onCreateObserver(int page) {
4849
public void start() {
4950
super.start();
5051
mPageObservable.start();
52+
53+
// 查询回复我的数量
54+
if (isLogin()) {
55+
createObservable(mMomentApi.queryReplyCount(System.currentTimeMillis()))
56+
.subscribe(new ApiDefaultObserver<String>() {
57+
@Override
58+
protected void onError(String message) {
59+
60+
}
61+
62+
@Override
63+
protected void accept(String s) {
64+
int number = Rx.parseInt(s);
65+
if (number > 0) {
66+
mView.onReplyContChanged(number);
67+
}
68+
}
69+
});
70+
}
5171
}
5272

5373
@Override

app/src/main/java/com/rae/cnblogs/presenter/impl/PostMomentPresenterImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public boolean post() {
7474
mView.onPostMomentInProgress();
7575
return false;
7676
} else {
77+
78+
// 加上客户端标志
79+
content = "[来自Android客户端] " + content;
80+
7781
createObservable(mMomentApi.publish(content, 1))
7882
.subscribe(new ApiDefaultObserver<Empty>() {
7983
@Override
Loading

app/src/main/res/layout/fm_sns.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@
4646

4747
</android.support.design.widget.DesignTabLayout>
4848

49-
<TextView
49+
<ImageView
5050
android:id="@+id/tv_post"
5151
android:layout_width="wrap_content"
5252
android:layout_height="wrap_content"
53+
android:layout_alignParentEnd="true"
5354
android:layout_alignParentRight="true"
54-
android:padding="12dp"
55-
android:text="发布"/>
55+
android:layout_centerVertical="true"
56+
android:layout_marginRight="@dimen/default_margin"
57+
android:src="@drawable/ic_moment_post"/>
5658

5759
</RelativeLayout>
5860
</android.support.v7.widget.Toolbar>

app/src/main/res/layout/item_moment_list.xml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RelativeLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
54
android:layout_width="match_parent"
65
android:layout_height="wrap_content"
7-
android:layout_marginBottom="4dp"
6+
android:layout_marginBottom="1dp"
87
android:background="@drawable/bg_blog_item_selector"
98
android:foreground="?selectableItemBackground"
109
android:orientation="vertical"
11-
android:paddingBottom="@dimen/default_margin"
10+
android:paddingBottom="12dp"
1211
android:paddingLeft="@dimen/default_margin"
1312
android:paddingRight="@dimen/default_margin"
14-
android:paddingTop="@dimen/default_margin">
13+
android:paddingTop="18dp">
1514

16-
<ImageButton
15+
<ImageView
1716
android:id="@+id/img_close"
18-
android:layout_width="32dp"
19-
android:layout_height="32dp"
17+
android:layout_width="30dp"
18+
android:layout_height="30dp"
2019
android:layout_alignParentRight="true"
2120
android:background="@android:color/transparent"
22-
android:scaleType="center"
21+
android:padding="8dp"
22+
android:scaleType="fitCenter"
2323
android:src="@drawable/ic_close"/>
2424

25-
<com.makeramen.roundedimageview.RoundedImageView
25+
<ImageView
2626
android:id="@+id/img_blog_avatar"
2727
android:layout_width="40dp"
2828
android:layout_height="40dp"
2929
android:layout_marginRight="12dp"
3030
android:scaleType="centerCrop"
31-
android:src="@drawable/bg_user_avatar"
32-
app:riv_corner_radius="4dp"/>
31+
android:src="@drawable/bg_user_avatar"/>
3332

3433

3534
<com.rae.cnblogs.widget.RaeTextView
@@ -40,7 +39,7 @@
4039
android:layout_alignTop="@+id/img_blog_avatar"
4140
android:layout_toRightOf="@+id/img_blog_avatar"
4241
android:text="RAE"
43-
android:textColor="@color/ph2"
42+
android:textColor="@color/moment_author"
4443
android:textSize="@dimen/h2"/>
4544

4645
<com.rae.cnblogs.widget.RaeTextView
@@ -53,7 +52,7 @@
5352
android:gravity="bottom"
5453
android:text="今天18:30"
5554
android:textAlignment="gravity"
56-
android:textColor="@color/ph3"
55+
android:textColor="#767676"
5756
android:textSize="11sp"/>
5857

5958
<com.rae.cnblogs.widget.RaeTextView
@@ -94,12 +93,31 @@
9493
android:layout_below="@+id/img_thumb"
9594
android:layout_marginTop="18dp"
9695
android:layout_toRightOf="@+id/img_blog_avatar"
97-
android:drawableLeft="@drawable/ic_comment_min"
98-
android:drawablePadding="7dp"
99-
android:gravity="center"
100-
android:text="0"
101-
android:textColor="@color/ph2"
102-
android:textSize="@dimen/h2"/>
96+
android:drawableLeft="@drawable/ic_moment_comment"
97+
android:drawablePadding="6dp"
98+
android:gravity="center_vertical|end"
99+
android:minWidth="45dp"
100+
android:text="0条回复"
101+
android:textColor="#c4c4c4"
102+
android:textSize="@dimen/h3"/>
103+
104+
<TextView
105+
android:id="@+id/tv_android_tag"
106+
android:layout_width="wrap_content"
107+
android:layout_height="wrap_content"
108+
android:layout_alignBaseline="@+id/tv_blog_comment"
109+
android:layout_alignParentRight="true"
110+
android:layout_below="@+id/img_thumb"
111+
android:text="客户端"
112+
android:textColor="@color/dividerColor"
113+
android:textSize="@dimen/h3"/>
114+
115+
<!-- <View
116+
android:layout_width="match_parent"
117+
android:layout_height="1dp"
118+
android:layout_below="@+id/tv_blog_comment"
119+
android:layout_marginTop="12dp"
120+
android:background="@color/dividerPrimary"/>-->
103121

104122

105123
</RelativeLayout>

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<color name="dividerColor">#dedede</color>
1414
<color name="ph1">#2d2d2d</color>
1515
<color name="ph2">#595959</color>
16+
<color name="moment_author">#576b95</color>
1617
<color name="ph3">#929292</color>
1718
<color name="ph4">#999999</color>
1819
<color name="default_background">#f9f9f9</color>

0 commit comments

Comments
 (0)