Skip to content

Commit

Permalink
Reverse the order of items in MarkdownBottomBarRecyclerViewAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Sep 19, 2024
1 parent 4f414ea commit fa9387e
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public void onSelectGiphyGif() {
});

binding.commentMarkdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManagerBugFixed.HORIZONTAL, false));
LinearLayoutManagerBugFixed.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.commentMarkdownBottomBarRecyclerView.setAdapter(adapter);

binding.commentAccountLinearLayout.setOnClickListener(view -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewEditCommentActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewEditCommentActivity.setAdapter(adapter);

binding.commentEditTextEditCommentActivity.requestFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewEditPostActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManagerBugFixed.HORIZONTAL, false));
LinearLayoutManagerBugFixed.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewEditPostActivity.setAdapter(adapter);

binding.postContentEditTextEditPostActivity.requestFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostGalleryActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostGalleryActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostImageActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostImageActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostLinkActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostLinkActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostPollActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostPollActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostTextActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostTextActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public void onUploadImage() {
});

binding.markdownBottomBarRecyclerViewPostVideoActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
LinearLayoutManager.HORIZONTAL, false));
LinearLayoutManager.HORIZONTAL, true).setStackFromEndAndReturnCurrentObject());
binding.markdownBottomBarRecyclerViewPostVideoActivity.setAdapter(adapter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

public static final int BOLD = 0;
public static final int ITALIC = 1;
public static final int LINK = 2;
public static final int STRIKE_THROUGH = 3;
public static final int SUPERSCRIPT = 4;
public static final int BOLD = 10;
public static final int ITALIC = 9;
public static final int LINK = 8;
public static final int STRIKE_THROUGH = 7;
public static final int SUPERSCRIPT = 6;
public static final int HEADER = 5;
public static final int ORDERED_LIST = 6;
public static final int UNORDERED_LIST = 7;
public static final int SPOILER = 8;
public static final int QUOTE = 9;
public static final int CODE_BLOCK = 10;
public static final int ORDERED_LIST = 4;
public static final int UNORDERED_LIST = 3;
public static final int SPOILER = 2;
public static final int QUOTE = 1;
public static final int CODE_BLOCK = 0;
public static final int UPLOAD_IMAGE = 11;
public static final int GIPHY_GIF = 12;

private static final int ITEM_COUNT = 11;
private static final int REGULAR_ITEM_COUNT = 11;

private final CustomThemeWrapper customThemeWrapper;
private final boolean canUploadImage;
Expand Down Expand Up @@ -121,7 +121,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi

@Override
public int getItemCount() {
return canUploadImage ? (canSendGiphyGIf ? ITEM_COUNT + 2 : ITEM_COUNT + 1) : ITEM_COUNT;
return canUploadImage ? (canSendGiphyGIf ? REGULAR_ITEM_COUNT + 2 : REGULAR_ITEM_COUNT + 1) : REGULAR_ITEM_COUNT;
}

public static void bindEditTextWithItemClickListener(Activity activity, EditText commentEditText, int item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public LinearLayoutManagerBugFixed(Context context, AttributeSet attrs, int defS
public boolean supportsPredictiveItemAnimations() {
return false;
}

public LinearLayoutManagerBugFixed setStackFromEndAndReturnCurrentObject() {
setStackFromEnd(true);
return this;
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
app:reverseLayout="true"
android:layout_gravity="bottom" />

</LinearLayout>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_post_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:layout_gravity="bottom" />
android:layout_gravity="bottom"
app:reverseLayout="true"
app:stackFromEnd="true" />

</LinearLayout>

Expand Down

0 comments on commit fa9387e

Please sign in to comment.