Skip to content

Commit ddbb84d

Browse files
committed
Set ReactionsDialog max width equals to the screen width
1 parent ed31fb3 commit ddbb84d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

reactbutton/src/main/java/com/amrdeveloper/reactbutton/ReactButton.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public class ReactButton
8989
private final int REACTION_ICON_SIZE = (ICON_SIZE_WITH_PADDING *
9090
getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
9191

92+
/**
93+
* The maximum width of the screen in pixels
94+
*/
95+
private final int SCREEN_MAX_WIDTH = getResources().getDisplayMetrics().widthPixels;
96+
9297
public interface OnReactionDialogStateListener {
9398
void onDialogOpened();
9499

@@ -160,9 +165,6 @@ private void showReactionsDialog() {
160165
GridView reactionsGrid = dialogView.findViewById(R.id.reactionsList);
161166
ReactionAdapter adapter = new ReactionAdapter(context, mReactions);
162167
reactionsGrid.setAdapter(adapter);
163-
164-
// Setup the columns number
165-
if (mDialogColumnsNumber == 0) mDialogColumnsNumber = mReactions.size();
166168
reactionsGrid.setNumColumns(mDialogColumnsNumber);
167169

168170
reactionsGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@@ -193,6 +195,7 @@ public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
193195
if (mOnReactionDialogStateListener != null) mOnReactionDialogStateListener.onDialogOpened();
194196

195197
int dialogWidth = REACTION_ICON_SIZE * mDialogColumnsNumber;
198+
if (dialogWidth > SCREEN_MAX_WIDTH) dialogWidth = SCREEN_MAX_WIDTH;
196199
window.setLayout(dialogWidth, WindowManager.LayoutParams.WRAP_CONTENT);
197200

198201
mReactAlertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

0 commit comments

Comments
 (0)