6.3 Get Unjoined Public Groups

The getUnjoinedPublicGroups returns all the public groups, an employee is not a member of. The Groups are returned as an ArrayList of HashMap through success callback, where each map represents a group with keys - groupKey, id, name, type.

Method parameters :
  • success: Success block to be executed after public groups are successfully retrieved.
  • failure: Failure block to be executed if public groups could not be retrieved, returns BayunError.

Java
Kotlin
ArrayList<HashMap<String, String>> unjoinedGroupsArray;

// Callbacks to get User's unjoined public groups
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Get unjoined public groups call successful.");
        unjoinedGroupsArray = (ArrayList<HashMap<String, String>>)message.getData().getSerializable("BayunUnjoinedGroupsArray");

        for (HashMap<String, String> group: unjoinedGroupsArray) {
            Log.d(TAG, "groupKey: " + group.get("groupKey"));
            Log.d(TAG, "id: " + group.get("id"));
            Log.d(TAG, "name: " + group.get("name"));
            Log.d(TAG, "type: " + group.get("type"));
        }
        return false;
    }
};

Handler.Callback failure = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String error = message.getData().getString("BayunError", "");
        if (error.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) {

        } else if (error.equalsIgnoreCase(BayunError.ERROR_REQUEST_TIMEOUT)) {

        }
        return false; 
    }
};

bayunCore.getUnjoinedPublicGroups(success, failure);
var unjoinedGroupsArray: ArrayList<HashMap<String, String>>

// Callbacks to get User's unjoined public groups
val success = Handler.Callback {
    Log.d(TAG, "Get unjoined public groups call successful.")

    unjoinedGroupsArray = it.data.getSerializable("BayunUnjoinedGroupsArray")
            as ArrayList<HashMap<String, String>>

    for (group in unjoinedGroupsArray) {
        Log.d(TAG, "groupKey: " + group["groupKey"])
        Log.d(TAG, "id: " + group["id"])
        Log.d(TAG, "name: " + group["name"])
        Log.d(TAG, "type: " + group["type"])
    }

    false
}

val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    if (error == BayunError.ERROR_INTERNET_CONNECTION) {

    } else if (error == BayunError.ERROR_REQUEST_TIMEOUT) {

    }

    false
}

bayunCore.getUnjoinedPublicGroups(success, failure)

results matching ""

    No results matching ""