Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 6620fb0

Browse files
committed
Fix #174 where padding is being added btw conversations unnecessarily
1 parent 00388ab commit 6620fb0

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

app/src/main/java/com/zulip/android/activities/MessageListFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
* initiated and called by {@link ZulipActivity}
4949
*/
5050
public class MessageListFragment extends Fragment implements MessageListener {
51-
private static final int PIXEL_OFFSET_MESSAGE_HEADERS = 24;
5251
private LinearLayoutManager linearLayoutManager;
5352
private MutedTopics mMutedTopics;
5453

@@ -154,7 +153,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
154153
linearLayoutManager = new LinearLayoutManager(getContext());
155154
recyclerView.setLayoutManager(linearLayoutManager);
156155
adapter = new RecyclerMessageAdapter(messageList, getActivity(), (filter != null));
157-
recyclerView.addItemDecoration(new HeaderSpaceItemDecoration(PIXEL_OFFSET_MESSAGE_HEADERS, getContext()));
156+
recyclerView.addItemDecoration(new HeaderSpaceItemDecoration(getContext()));
158157
recyclerView.setAdapter(adapter);
159158
registerForContextMenu(recyclerView);
160159
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

app/src/main/java/com/zulip/android/viewholders/HeaderSpaceItemDecoration.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
*/
1515
public class HeaderSpaceItemDecoration extends RecyclerView.ItemDecoration {
1616

17-
private final int verticalMargin;
18-
1917
private int toolbarHeight;
2018

21-
public HeaderSpaceItemDecoration(int verticalMargin, Context context) {
22-
this.verticalMargin = verticalMargin;
19+
public HeaderSpaceItemDecoration(Context context) {
2320
TypedValue tv = new TypedValue();
2421
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
2522
toolbarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
@@ -33,11 +30,9 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
3330
int position = parent.getChildAdapterPosition(view);
3431
int size = parent.getAdapter().getItemCount();
3532
int viewType = parent.getAdapter().getItemViewType(position);
36-
if (viewType == RecyclerMessageAdapter.VIEWTYPE_MESSAGE_HEADER && position != 0) {
37-
outRect.top = verticalMargin;
38-
} else if (viewType == RecyclerMessageAdapter.VIEWTYPE_HEADER) {
33+
if (viewType == RecyclerMessageAdapter.VIEWTYPE_HEADER) {
3934
outRect.top = toolbarHeight;
4035
}
41-
outRect.bottom = (position == size - 2) ? verticalMargin : 0;
36+
outRect.bottom = 0;
4237
}
4338
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns:tools="http://schemas.android.com/tools"
33
android:layout_width="match_parent"
44
android:layout_height="wrap_content"
5+
android:layout_marginTop="12dp"
56
android:background="@color/messageHeaderBackground">
67

78
<TextView

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
tools:background="#FFF">
3030

3131
<TextView
32-
android:paddingTop="10dp"
3332
android:id="@+id/senderName"
33+
android:paddingTop="10dp"
3434
android:layout_width="0dp"
3535
android:layout_height="wrap_content"
3636
android:layout_weight="1"

0 commit comments

Comments
 (0)