use of org.matrix.androidsdk.rest.model.group.GroupProfile in project matrix-android-sdk by matrix-org.
the class GroupsManager method createGroup.
/**
* Create a group.
*
* @param localPart the local part
* @param groupName the group human name
* @param callback the asynchronous callback
*/
public void createGroup(String localPart, String groupName, final ApiCallback<String> callback) {
final CreateGroupParams params = new CreateGroupParams();
params.localpart = localPart;
params.profile = new GroupProfile();
params.profile.name = groupName;
getGroupsRestClient().createGroup(params, new ApiCallback<String>() {
@Override
public void onSuccess(String groupId) {
Group group = getGroup(groupId);
// if the group does not exist, create it
if (null == group) {
group = new Group(groupId);
group.setGroupProfile(params.profile);
group.setMembership(RoomMember.MEMBERSHIP_JOIN);
mStore.storeGroup(group);
}
callback.onSuccess(groupId);
}
@Override
public void onNetworkError(Exception e) {
callback.onNetworkError(e);
}
@Override
public void onMatrixError(MatrixError e) {
callback.onMatrixError(e);
}
@Override
public void onUnexpectedError(Exception e) {
callback.onUnexpectedError(e);
}
});
}
use of org.matrix.androidsdk.rest.model.group.GroupProfile in project matrix-android-sdk by matrix-org.
the class GroupsManager method onNewGroupInvitation.
/**
* Create a group from an invitation.
*
* @param groupId the group id
* @param profile the profile
* @param inviter the inviter
* @param notify true to notify
*/
public void onNewGroupInvitation(final String groupId, final GroupSyncProfile profile, final String inviter, final boolean notify) {
Group group = getGroup(groupId);
// it should always be null
if (null == group) {
group = new Group(groupId);
}
GroupSummary summary = new GroupSummary();
summary.profile = new GroupProfile();
if (null != profile) {
summary.profile.name = profile.name;
summary.profile.avatarUrl = profile.avatarUrl;
}
group.setGroupSummary(summary);
group.setInviter(inviter);
group.setMembership(RoomMember.MEMBERSHIP_INVITE);
mStore.storeGroup(group);
if (notify) {
mUIHandler.post(new Runnable() {
@Override
public void run() {
mDataHandler.onNewGroupInvitation(groupId);
}
});
}
}
Aggregations