public static synchronized void setChannelGroups ( Collection < WonderPushChannelGroup > channelGroups ) { if ( channelGroups == null ) return ; boolean save = false ; try { Set < String > groupIdsToRemove = new HashSet <> ( sChannelGroups . keySet ( ) ) ; for ( WonderPushChannelGroup channelGroup : channelGroups ) { if ( channelGroup == null ) continue ; groupIdsToRemove . remove ( channelGroup . getId ( ) ) ; if ( _putChannelGroup ( channelGroup ) ) save = true ; } for ( String groupId : groupIdsToRemove ) { if ( _removeChannelGroup ( groupId ) ) save = true ; } } catch ( Exception ex ) { Log . e ( WonderPush . TAG , "Unexpected error while setting channel groups " + channelGroups , ex ) ; } finally { try { if ( save ) { save ( ) ; } } catch ( Exception ex ) { Log . e ( WonderPush . TAG , "Unexpected error while setting channel groups " + channelGroups , ex ) ; } } }
Create update and remove channel existing groups to match the given channel groups .