Skip to content

Commit d7ba76a

Browse files
Changes in Button
1 parent 09f7844 commit d7ba76a

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

selectionalertdialog/src/main/java/com/drapps/selectionalertdialog/MultiSelectionDialog.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class MultiSelectionDialog extends AppCompatActivity {
5454
private String currentField = "", currentValue = "", currentPosition = "", tag = "", hintText = "Search here", positiveText = "", negativeText = "";
5555
private int headerColor, textColor, positiveTextColor, negativeTextColor;
5656
MultiSelectionListener multiSelectionListener;
57-
private boolean doneVisibility;
57+
private boolean doneVisibility, positiveVisiblity, negativeVisiblity;
5858

5959
@Override
6060
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -86,6 +86,8 @@ private MultiSelectionDialog(Builder builder) {
8686
positiveText = builder.positiveText;
8787
negativeText = builder.negativeText;
8888
doneVisibility = builder.doneVisibility;
89+
positiveVisiblity = builder.positiveVisibility;
90+
negativeVisiblity = builder.negativeVisibility;
8991
Log.d("TAG--", headerTitle);
9092
}
9193

@@ -125,18 +127,31 @@ public void show() {
125127
}
126128
if (positiveTextColor != 0) {
127129
try {
128-
tvPositive.setBackgroundColor(positiveTextColor);
130+
tvPositive.setTextColor(positiveTextColor);
129131
} catch (Exception e) {
130132
e.printStackTrace();
131133
}
132134
}
133135
if (negativeTextColor != 0) {
134136
try {
135-
tvPositive.setBackgroundColor(negativeTextColor);
137+
tvPositive.setTextColor(negativeTextColor);
136138
} catch (Exception e) {
137139
e.printStackTrace();
138140
}
139141
}
142+
if (positiveVisiblity) {
143+
tvPositive.setVisibility(View.VISIBLE);
144+
} else {
145+
tvPositive.setVisibility(View.INVISIBLE);
146+
}
147+
if (negativeVisiblity) {
148+
tvNegative.setVisibility(View.VISIBLE);
149+
} else {
150+
tvNegative.setVisibility(View.INVISIBLE);
151+
}
152+
if (negativeVisiblity && positiveVisiblity) {
153+
linearBtn.setVisibility(View.GONE);
154+
}
140155

141156
recyclerView.addOnItemTouchListener(
142157
new RecyclerItemClickListener(context, recyclerView,
@@ -248,7 +263,7 @@ public static class Builder {
248263
private String currentField = "", tag = "", hintText = "Search here", positiveText = "", negativeText = "";
249264
private int headerColor, textColor, positiveColor, negativeColor;
250265
MultiSelectionListener multiSelectionListener;
251-
private boolean doneVisibility = true;
266+
private boolean doneVisibility = true, negativeVisibility = true, positiveVisibility = true;
252267

253268
public Builder(Context ctx, String tag) {
254269
this.context = ctx;
@@ -280,15 +295,18 @@ public Builder setColor(int color) {
280295
return this;
281296
}
282297

283-
public Builder setPositiveButton(String text, int color) {
298+
public Builder setPositiveButton(String text, int color, boolean visible) {
284299
positiveColor = color;
285300
positiveText = text;
301+
positiveVisibility = visible;
302+
286303
return this;
287304
}
288305

289-
public Builder setNegativeButton(String text, int color) {
306+
public Builder setNegativeButton(String text, int color, boolean visible) {
290307
negativeColor = color;
291308
negativeText = text;
309+
negativeVisibility = visible;
292310
return this;
293311
}
294312

selectionalertdialog/src/main/res/layout/multi_selection_dialog.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
android:layout_below="@id/recycler_multi_dialog"
5050
android:layout_marginTop="10dp"
5151
android:orientation="horizontal"
52-
android:weightSum="2">
52+
android:weightSum="2"
53+
android:layout_marginBottom="15dp"
54+
>
5355

5456
<TextView
5557
android:id="@+id/tv_negative_multi_dialog"

0 commit comments

Comments
 (0)