44import android .content .Context ;
55import android .content .res .ColorStateList ;
66import android .os .Bundle ;
7- import android .text .Editable ;
8- import android .text .TextWatcher ;
97import android .view .LayoutInflater ;
108import android .view .View ;
11- import android .widget .EditText ;
129import android .widget .ImageView ;
1310import android .widget .LinearLayout ;
1411import android .widget .TextView ;
1512import android .widget .Toast ;
1613
14+ import com .drapps .selectionalertdialog .MulitpleSelectionAdapter ;
15+ import com .drapps .selectionalertdialog .MultiSelection ;
16+ import com .drapps .selectionalertdialog .MultiSelectionListener ;
17+ import com .drapps .selectionalertdialog .R ;
18+
1719import java .util .ArrayList ;
1820
1921import androidx .annotation .Nullable ;
2022import androidx .appcompat .app .AppCompatActivity ;
21- import androidx .core .view .ViewCompat ;
2223import androidx .recyclerview .widget .LinearLayoutManager ;
2324import androidx .recyclerview .widget .RecyclerView ;
2425
@@ -31,7 +32,7 @@ public class MultiSelectionDialog extends AppCompatActivity {
3132 private ArrayList <MultiSelection > temp_data_list = new ArrayList <>();
3233 private String headerTitle = "Select" ;
3334 private Boolean isSearchEnabled = false ;
34- SingleSelectionAdapter dialogAdapter ;
35+ MulitpleSelectionAdapter dialogAdapter ;
3536 private String currentField = "" , currentValue = "" , currentPosition = "" , tag = "" , hintText = "Search here" ;
3637 private int headerColor ;
3738 MultiSelectionListener multiSelectionListener ;
@@ -56,8 +57,10 @@ public void setContent(ArrayList<String> contentProvide) {
5657
5758 if (list != null && list .size () > 0 ) {
5859 for (int i = 0 ; i < list .size (); i ++) {
59- multiList .get (i ).setTitle (list .get (i ));
60- temp_data_list .get (i ).setTitle (list .get (i ));
60+ MultiSelection multiSelection = new MultiSelection ();
61+ multiSelection .setTitle (list .get (i ));
62+ multiList .add (multiSelection );
63+ temp_data_list .add (multiSelection );
6164 }
6265 }
6366
@@ -71,16 +74,16 @@ public void setTitle(String mTitle) {
7174 }
7275 }
7376
74- public void enableSearch (Boolean value , String hint ) {
75- isSearchEnabled = value ;
76- hintText = hint ;
77- }
77+ // public void enableSearch(Boolean value, String hint) {
78+ // isSearchEnabled = value;
79+ // hintText = hint;
80+ // }
7881
7982 public void setColor (int color ) {
8083 headerColor = color ;
8184 }
8285
83- public void setSelectedField (String selectedField ) {
86+ public void setSelectedFields (String selectedField ) {
8487 currentField = selectedField ;
8588 }
8689
@@ -140,14 +143,16 @@ public void onItemLongClick(View view, int position) {
140143 public void onClick (View view ) {
141144 String getAssetsValue = "" ;
142145 String assetValue = "" ;
146+ ArrayList <String > temp_string_list = new ArrayList <>();
143147 if (multiList != null && multiList .size () > 0 ) {
144148 for (int i = 0 ; i < multiList .size (); i ++) {
145149 if (multiList .get (i ).getCheck ()) {
150+ temp_string_list .add (multiList .get (i ).getTitle ());
146151 getAssetsValue += multiList .get (i ).getTitle () + "," ;
147152 assetValue = getAssetsValue .substring (0 , getAssetsValue .length () - 1 );
148153 }
149154 }
150- multiSelectionListener .onMultiDialogItemsSelected (assetValue , tag );
155+ multiSelectionListener .onMultiDialogItemsSelected (assetValue , tag , temp_string_list );
151156 }
152157
153158 dialog .dismiss ();
@@ -185,14 +190,15 @@ public void onClick(View view) {
185190// }
186191//// });
187192//
188- // if (list != null && list.size() > 0) {
189- // dialogAdapter = new SingleSelectionAdapter(list, context, currentField, headerColor);
190- // recyclerView.setAdapter(dialogAdapter);
191- // dialog.show();
192- // } else {
193- // Toast.makeText(context, "List is empty", Toast.LENGTH_SHORT).show();
194- // }
193+ if (list != null && list .size () > 0 ) {
194+ dialogAdapter = new MulitpleSelectionAdapter ( multiList , currentField ,context , headerColor );
195+ recyclerView .setAdapter (dialogAdapter );
196+ dialog .show ();
197+ } else {
198+ Toast .makeText (context , "List is empty" , Toast .LENGTH_SHORT ).show ();
199+ }
195200
201+ dialog .show ();
196202 } catch (Exception e ) {
197203 e .printStackTrace ();
198204 }
0 commit comments