Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
new chat date divider
Browse files Browse the repository at this point in the history
  • Loading branch information
gerc99 committed Feb 29, 2016
1 parent b618233 commit 661a586
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion res/drawable/list_selector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
<solid android:color="#0f000000" />
</shape>
</item>
<item android:drawable="@android:drawable/screen_background_light_transparent" />
<item android:drawable="@drawable/screen_background_light_transparent" />
</selector>
22 changes: 16 additions & 6 deletions res/layout/chat_view_header.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:textSize="18sp"
android:background="#a0efebe9" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">

<TextView
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text"
android:gravity="center_horizontal"
android:textSize="14sp"
android:background="@drawable/chat_time_header_background"
android:layout_gravity="center_horizontal"
android:padding="5dp" />
</LinearLayout>
16 changes: 0 additions & 16 deletions res/layout/header_chat_inline.xml

This file was deleted.

2 changes: 2 additions & 0 deletions res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@
<item>#FF795548</item>
<item>#FF607d8b</item>
</array>

<drawable name="screen_background_light_transparent">#00ffffff</drawable>
</resources>
21 changes: 11 additions & 10 deletions src/ru/sawim/models/MessagesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* To change this template use File | Settings | File Templates.
*/
public class MessagesAdapter extends RecyclerView.Adapter<MessagesAdapter.ViewHolder>
implements StickyRecyclerHeadersAdapter<RecyclerView.ViewHolder>, View.OnClickListener {
implements StickyRecyclerHeadersAdapter<MessagesAdapter.HeaderHolder>, View.OnClickListener {

private List<MessData> items;

Expand Down Expand Up @@ -157,21 +157,22 @@ public void onViewRecycled(ViewHolder holder) {
@Override
public long getHeaderId(int position) {
MessData current = getItem(position);
return TimeUnit.MILLISECONDS.toDays(current.getTime());
if (current != null) {
return TimeUnit.MILLISECONDS.toDays(current.getTime());
}
return -1;
}

@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
public HeaderHolder onCreateHeaderViewHolder(ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.chat_view_header, parent, false);
return new RecyclerView.ViewHolder(view) {
};
return new HeaderHolder(view);
}

@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int position) {
TextView textView = (TextView) holder.itemView;
textView.setText(formatDate(getItem(position).getTime()));
public void onBindHeaderViewHolder(HeaderHolder holder, int position) {
holder.header.setText(formatDate(getItem(position).getTime()));
}

@Override
Expand Down Expand Up @@ -225,12 +226,12 @@ public ViewHolder(View itemView) {
}

static class HeaderHolder extends RecyclerView.ViewHolder {
public TextView header;
TextView header;

public HeaderHolder(View itemView) {
super(itemView);

header = (TextView) itemView;
header = (TextView) itemView.findViewById(R.id.text);
}
}

Expand Down

0 comments on commit 661a586

Please sign in to comment.