Search in sources :

Example 1 with UserInfo

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);
}
Also used : Intent(android.content.Intent) UserInfo(cn.wildfirechat.model.UserInfo) OnClick(butterknife.OnClick)

Example 2 with UserInfo

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);
}
Also used : ContactSearchModule(cn.wildfire.chat.kit.search.module.ContactSearchModule) GroupSearchViewModule(cn.wildfire.chat.kit.search.module.GroupSearchViewModule) GroupSearchResult(cn.wildfirechat.model.GroupSearchResult) SearchableModule(cn.wildfire.chat.kit.search.SearchableModule) UserInfo(cn.wildfirechat.model.UserInfo) Conversation(cn.wildfirechat.model.Conversation) SearchFragment(cn.wildfire.chat.kit.search.SearchFragment) Fragment(androidx.fragment.app.Fragment) BindView(butterknife.BindView) View(android.view.View)

Example 3 with UserInfo

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;
}
Also used : OperateResult(cn.wildfire.chat.kit.common.OperateResult) ArrayList(java.util.ArrayList) MutableLiveData(androidx.lifecycle.MutableLiveData) GeneralCallback2(cn.wildfirechat.remote.GeneralCallback2) UIUserInfo(cn.wildfire.chat.kit.contact.model.UIUserInfo) UserInfo(cn.wildfirechat.model.UserInfo)

Example 4 with UserInfo

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();
}
Also used : Bitmap(android.graphics.Bitmap) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) UIUserInfo(cn.wildfire.chat.kit.contact.model.UIUserInfo) UserInfo(cn.wildfirechat.model.UserInfo) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Nullable(androidx.annotation.Nullable)

Example 5 with UserInfo

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();
}
Also used : UserInfo(cn.wildfirechat.model.UserInfo)

Aggregations

UserInfo (cn.wildfirechat.model.UserInfo)81 ArrayList (java.util.ArrayList)23 UIUserInfo (cn.wildfire.chat.kit.contact.model.UIUserInfo)16 UserViewModel (cn.wildfire.chat.kit.user.UserViewModel)13 AVEngineKit (cn.wildfirechat.avenginekit.AVEngineKit)10 Intent (android.content.Intent)9 GroupInfo (cn.wildfirechat.model.GroupInfo)9 DisplayMetrics (android.util.DisplayMetrics)8 ViewGroup (android.view.ViewGroup)8 Conversation (cn.wildfirechat.model.Conversation)7 List (java.util.List)7 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 MutableLiveData (androidx.lifecycle.MutableLiveData)5 GroupMember (cn.wildfirechat.model.GroupMember)5 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)5 SharedPreferences (android.content.SharedPreferences)4 SpannableString (android.text.SpannableString)4 BindView (butterknife.BindView)4