3838import com .getstream .sdk .chat .model .ModelType ;
3939import com .getstream .sdk .chat .model .channel .Channel ;
4040import com .getstream .sdk .chat .model .channel .Event ;
41+ import com .getstream .sdk .chat .model .enums .FilterQuery ;
4142import com .getstream .sdk .chat .rest .Parser ;
4243import com .getstream .sdk .chat .rest .apimodel .request .AddDeviceRequest ;
4344import com .getstream .sdk .chat .rest .apimodel .request .ChannelDetailRequest ;
6667import java .util .HashMap ;
6768import java .util .List ;
6869import java .util .Map ;
70+ import java .util .Set ;
6971
7072public class ChannelListFragment extends Fragment implements WSResponseHandler {
7173
@@ -88,7 +90,8 @@ public static ChannelListFragment newInstance() {
8890 }
8991
9092
91- public ChannelListFragment (){ }
93+ public ChannelListFragment () {
94+ }
9295
9396 // region LifeCycle
9497 @ Override
@@ -328,20 +331,46 @@ private JSONObject getPayload() {
328331
329332 // Filter option
330333 filter_conditions .put ("type" , "messaging" );
331- if (component .channel .getFilterOptions ().size () == 1 ){
334+ if (component .channel .getFilterOptions ().size () == 1 ) {
332335 FilterOption filterOption = component .channel .getFilterOptions ().get (0 );
333- filter_conditions .put (filterOption .getKey (), filterOption .getValue ());
334- }else {
335- if (!TextUtils .isEmpty (component .channel .getQuery ())){
336- List <Map <String ,Object >> filterOptions = new ArrayList <>();
337- for (FilterOption filterOption : component .channel .getFilterOptions ()){
338- Map <String , Object > map = new HashMap <>();
339- map .put (filterOption .getKey (),filterOption .getValue ());
340- filterOptions .add (map );
336+
337+ // Convert from FilterQuery to String
338+ Log .d (TAG ,"FilterOption Value: " + filterOption .getValue ());
339+ Map <FilterQuery , Object > mapFilterValue = (Map <FilterQuery , Object >) filterOption .getValue ();
340+
341+ Map <String , Object > mapFilterValue_ = new HashMap <>();
342+ Set keys = mapFilterValue .keySet ();
343+ for (Object key : keys ){
344+ mapFilterValue_ .put (((FilterQuery )key ).get (),mapFilterValue .get (key ));
345+ }
346+
347+ filter_conditions .put (filterOption .getKey (), mapFilterValue_ );
348+ } else {
349+ if (component .channel .getQuery () != null ) {
350+
351+ List <Map <String , Object >> filterOptions = new ArrayList <>();
352+
353+ for (FilterOption filterOption : component .channel .getFilterOptions ()) {
354+ // Convert from FilterQuery to String
355+ if (filterOption .getValue ().getClass ().equals (String .class )){
356+ Map <String , Object > map = new HashMap <>();
357+ map .put (filterOption .getKey (), filterOption .getValue ());
358+ filterOptions .add (map );
359+ }else {
360+ Map <FilterQuery , Object > mapFilterValue = (Map <FilterQuery , Object >) filterOption .getValue ();
361+ Map <String , Object > mapFilterValue_ = new HashMap <>();
362+ Set keys = mapFilterValue .keySet ();
363+ for (Object key : keys ){
364+ mapFilterValue_ .put (((FilterQuery )key ).get (),mapFilterValue .get (key ));
365+ }
366+ Map <String , Object > map = new HashMap <>();
367+ map .put (filterOption .getKey (), mapFilterValue_ );
368+ filterOptions .add (map );
369+ }
341370 }
342- filter_conditions .put (component .channel .getQuery (), filterOptions );
343- }else {
344- Utils .showMessage (getActivity (),"You must set filter query!" );
371+ filter_conditions .put (component .channel .getQuery (). get () , filterOptions );
372+ } else {
373+ Utils .showMessage (getActivity (), "You must set filter query!" );
345374 }
346375 }
347376
@@ -356,7 +385,7 @@ private JSONObject getPayload() {
356385 }
357386
358387 payload .put ("filter_conditions" , filter_conditions );
359-
388+ Log . d ( TAG , "filter_conditions: " + payload );
360389
361390 payload .put ("message_limit" , Constant .CHANNEL_MESSAGE_LIMIT );
362391 if (Global .channels .size () > 0 )
0 commit comments