use of cn.wildfirechat.model.UserInfo in project android-chat by wildfirechat.
the class UserCardMessageContentViewHolder method onUserCardClick.
@OnClick(R2.id.contentLayout)
void onUserCardClick() {
Intent intent = new Intent(fragment.getContext(), UserInfoActivity.class);
UserInfo userInfo = ChatManager.Instance().getUserInfo(userCardMessageContent.getTarget(), false);
intent.putExtra("userInfo", userInfo);
fragment.startActivity(intent);
}
use of cn.wildfirechat.model.UserInfo in project android-chat by wildfirechat.
the class PickOrCreateConversationActivity method initSearch.
private void initSearch() {
searchableModules = new ArrayList<>();
SearchableModule module = new ContactSearchModule();
module.setOnResultItemListener(new OnResultItemClickListener<UserInfo>() {
@Override
public void onResultItemClick(Fragment fragment, View itemView, View view, UserInfo userInfo) {
Conversation conversation = new Conversation(Conversation.ConversationType.Single, userInfo.uid, 0);
onPickOrCreateConversation(conversation);
}
});
searchableModules.add(module);
module = new GroupSearchViewModule();
module.setOnResultItemListener(new OnResultItemClickListener<GroupSearchResult>() {
@Override
public void onResultItemClick(Fragment fragment, View itemView, View view, GroupSearchResult gr) {
Conversation conversation = new Conversation(Conversation.ConversationType.Group, gr.groupInfo.target, 0);
onPickOrCreateConversation(conversation);
}
});
searchableModules.add(module);
}
use of cn.wildfirechat.model.UserInfo in project android-chat by wildfirechat.
the class GroupViewModel method createGroup.
public MutableLiveData<OperateResult<String>> createGroup(Context context, List<UserInfo> checkedUsers, MessageContent notifyMsg, List<Integer> lines) {
List<String> selectedIds = new ArrayList<>(checkedUsers.size());
List<UserInfo> selectedUsers = new ArrayList<>();
for (UserInfo userInfo : checkedUsers) {
selectedIds.add(userInfo.uid);
selectedUsers.add(userInfo);
}
String id = ChatManager.Instance().getUserId();
if (!selectedIds.contains(id)) {
selectedIds.add(id);
selectedUsers.add(ChatManager.Instance().getUserInfo(id, false));
}
String groupName = "";
for (int i = 0; i < 3 && i < selectedUsers.size(); i++) {
groupName += selectedUsers.get(i).displayName + "、";
}
groupName = groupName.substring(0, groupName.length() - 1);
if (selectedUsers.size() > 3) {
groupName += " ...";
}
groupName = groupName.substring(0, groupName.length() - 1);
MutableLiveData<OperateResult<String>> groupLiveData = new MutableLiveData<>();
String finalGroupName = groupName;
ChatManager.Instance().createGroup(null, finalGroupName, null, GroupInfo.GroupType.Restricted, null, selectedIds, null, lines, notifyMsg, new GeneralCallback2() {
@Override
public void onSuccess(String groupId) {
groupLiveData.setValue(new OperateResult<>(groupId, 0));
}
@Override
public void onFail(int errorCode) {
groupLiveData.setValue(new OperateResult<>(errorCode));
}
});
return groupLiveData;
}
use of cn.wildfirechat.model.UserInfo in project android-chat by wildfirechat.
the class GroupViewModel method generateGroupPortrait.
@Nullable
private String generateGroupPortrait(Context context, List<UserInfo> userInfos) throws Exception {
List<Bitmap> bitmaps = new ArrayList<>();
for (UserInfo userInfo : userInfos) {
Drawable drawable;
try {
drawable = GlideApp.with(context).load(userInfo.portrait).placeholder(R.mipmap.avatar_def).submit(60, 60).get();
} catch (Exception e) {
e.printStackTrace();
drawable = GlideApp.with(context).load(R.mipmap.avatar_def).submit(60, 60).get();
}
if (drawable instanceof BitmapDrawable) {
bitmaps.add(((BitmapDrawable) drawable).getBitmap());
}
}
Bitmap bitmap = CombineBitmapTools.combimeBitmap(context, 60, 60, bitmaps);
if (bitmap == null) {
return null;
}
// create a file to write bitmap data
File f = new File(context.getCacheDir(), System.currentTimeMillis() + ".png");
f.createNewFile();
// Convert bitmap to byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, /*ignored for PNG*/
bos);
byte[] bitmapData = bos.toByteArray();
// write the bytes in file
FileOutputStream fos = new FileOutputStream(f);
fos.write(bitmapData);
fos.flush();
fos.close();
return f.getAbsolutePath();
}
use of cn.wildfirechat.model.UserInfo in project android-chat by wildfirechat.
the class GroupMemberListAdapter method removeMembers.
public void removeMembers(List<String> memberIds) {
Iterator<UserInfo> iterator = members.iterator();
while (iterator.hasNext()) {
UserInfo userInfo = iterator.next();
if (memberIds.contains(userInfo.uid)) {
iterator.remove();
memberIds.remove(userInfo.uid);
}
if (memberIds.size() == 0) {
break;
}
}
notifyDataSetChanged();
}
Aggregations