初始代码
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.TopicInfoActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.CommunitySettingsActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.CreateTopicActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.CommunityMemberActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.JoinCommunityActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.qcloud.tuikit.tuicommunity.ui.page.CreateCommunityActivity"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="false" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,362 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupChangeInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupListener;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicInfo;
|
||||
import com.tencent.qcloud.tuicore.ServiceInitializer;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.annotations.TUIInitializerDependency;
|
||||
import com.tencent.qcloud.tuicore.annotations.TUIInitializerID;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUIExtension;
|
||||
import com.tencent.qcloud.tuicore.interfaces.ITUINotification;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionEventListener;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionInfo;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUIInitializer;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUILoginListener;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityChangeBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.CommunityEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.TopicInfoActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityParser;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AutoService(TUIInitializer.class)
|
||||
@TUIInitializerDependency("TIMCommon")
|
||||
@TUIInitializerID("TUICommunity")
|
||||
public class TUICommunityService implements TUIInitializer, ITUINotification, ITUIExtension {
|
||||
private static final String TAG = TUICommunityService.class.getSimpleName();
|
||||
private static TUICommunityService instance;
|
||||
|
||||
public static TUICommunityService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<WeakReference<CommunityEventListener>> communityEventList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
instance = this;
|
||||
initEvent();
|
||||
initExtension();
|
||||
initSdkListener();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
TUICore.registerEvent(TUIConstants.TUIChat.EVENT_KEY_MESSAGE_EVENT, TUIConstants.TUIChat.EVENT_SUB_KEY_SEND_MESSAGE_SUCCESS, this);
|
||||
TUICore.registerEvent(TUIConstants.TUIChat.EVENT_KEY_MESSAGE_EVENT, TUIConstants.TUIChat.EVENT_SUB_KEY_REPLY_MESSAGE_SUCCESS, this);
|
||||
TUICore.registerEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_COMMUNITY, this);
|
||||
TUICore.registerEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_ADD_COMMUNITY, this);
|
||||
TUICore.registerEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_DISBAND_COMMUNITY, this);
|
||||
TUICore.registerEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_TOPIC, this);
|
||||
TUICore.registerEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_DELETE_TOPIC, this);
|
||||
TUICore.registerEvent(TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_INFO_UPDATED, this);
|
||||
}
|
||||
|
||||
private void initExtension() {
|
||||
TUICore.registerExtension(TUIConstants.TUIChat.Extension.ChatNavigationMoreItem.CLASSIC_EXTENSION_ID, this);
|
||||
}
|
||||
|
||||
private void initSdkListener() {
|
||||
TUILogin.addLoginListener(new TUILoginListener() {
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onNetworkStateChanged(CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECTING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onNetworkStateChanged(CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFailed(int code, String error) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onNetworkStateChanged(CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECT_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
V2TIMManager.getInstance().addGroupListener(new V2TIMGroupListener() {
|
||||
@Override
|
||||
public void onMemberEnter(String groupID, List<V2TIMGroupMemberInfo> memberList) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
String selfID = V2TIMManager.getInstance().getLoginUser();
|
||||
for (V2TIMGroupMemberInfo memberInfo : memberList) {
|
||||
if (TextUtils.equals(memberInfo.getUserID(), selfID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onJoinedCommunity(groupID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberInvited(String groupID, V2TIMGroupMemberInfo opUser, List<V2TIMGroupMemberInfo> memberList) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
String selfID = V2TIMManager.getInstance().getLoginUser();
|
||||
for (V2TIMGroupMemberInfo memberInfo : memberList) {
|
||||
if (TextUtils.equals(memberInfo.getUserID(), selfID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onJoinedCommunity(groupID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupCreated(String groupID) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityCreated(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupDismissed(String groupID, V2TIMGroupMemberInfo opUser) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityDeleted(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupRecycled(String groupID, V2TIMGroupMemberInfo opUser) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityDeleted(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupInfoChanged(String groupID, List<V2TIMGroupChangeInfo> changeInfos) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
TUICommunityLog.i(TAG, "onGroupInfoChanged groupID = " + groupID);
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
List<CommunityChangeBean> communityChangeBeans = new ArrayList<>();
|
||||
for (V2TIMGroupChangeInfo v2TIMGroupChangeInfo : changeInfos) {
|
||||
CommunityChangeBean communityChangeBean = new CommunityChangeBean();
|
||||
communityChangeBean.setV2TIMGroupChangeInfo(v2TIMGroupChangeInfo);
|
||||
communityChangeBeans.add(communityChangeBean);
|
||||
}
|
||||
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityInfoChanged(groupID, communityChangeBeans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuitFromGroup(String groupID) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityDeleted(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberKicked(String groupID, V2TIMGroupMemberInfo opUser, List<V2TIMGroupMemberInfo> memberList) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
String selfID = V2TIMManager.getInstance().getLoginUser();
|
||||
for (V2TIMGroupMemberInfo memberInfo : memberList) {
|
||||
if (TextUtils.equals(memberInfo.getUserID(), selfID)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityDeleted(groupID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGroupAttributeChanged(String groupID, Map<String, String> groupAttributeMap) {
|
||||
if (CommunityUtil.isCommunityGroup(groupID)) {
|
||||
TUICommunityLog.i(TAG, "onGroupAttributeChanged groupID = " + groupID);
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onGroupAttrChanged(groupID, groupAttributeMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicCreated(String groupID, String topicID) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onTopicCreated(groupID, topicID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicDeleted(String groupID, List<String> topicIDList) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onTopicDeleted(groupID, topicIDList);
|
||||
}
|
||||
for (String topicID : topicIDList) {
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIContact.GROUP_ID, topicID);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_GROUP, TUIConstants.TUIContact.EVENT_SUB_KEY_GROUP_DISMISS, param);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicInfoChanged(String groupID, V2TIMTopicInfo topicInfo) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
TopicBean topicBean = CommunityParser.parseTopicBean(topicInfo);
|
||||
communityEventListener.onTopicChanged(groupID, topicBean);
|
||||
}
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIContact.GROUP_ID, topicInfo.getTopicID());
|
||||
param.put(TUIConstants.TUIContact.GROUP_NAME, topicInfo.getTopicName());
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_GROUP, TUIConstants.TUIContact.EVENT_SUB_KEY_GROUP_INFO_CHANGED, param);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<CommunityEventListener> getCommunityEventListenerList() {
|
||||
List<CommunityEventListener> listeners = new ArrayList<>();
|
||||
Iterator<WeakReference<CommunityEventListener>> iterator = communityEventList.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
WeakReference<CommunityEventListener> listenerWeakReference = iterator.next();
|
||||
CommunityEventListener listener = listenerWeakReference.get();
|
||||
if (listener == null) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
|
||||
public void addCommunityEventListener(CommunityEventListener communityListener) {
|
||||
if (communityListener == null) {
|
||||
return;
|
||||
}
|
||||
for (WeakReference<CommunityEventListener> listenerWeakReference : communityEventList) {
|
||||
if (listenerWeakReference.get() == communityListener) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
communityEventList.add(new WeakReference<>(communityListener));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotifyEvent(String key, String subKey, Map<String, Object> param) {
|
||||
if (TextUtils.equals(key, TUIConstants.TUIChat.EVENT_KEY_MESSAGE_EVENT)) {
|
||||
String experienceName = null;
|
||||
if (param != null && !param.isEmpty()) {
|
||||
String chatId = (String) param.get(TUIConstants.TUIChat.CHAT_ID);
|
||||
if (CommunityUtil.isTopicGroup(chatId)) {
|
||||
if (TextUtils.equals(subKey, TUIConstants.TUIChat.EVENT_SUB_KEY_SEND_MESSAGE_SUCCESS)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_SEND_MESSAGE_IN_TOPIC_KEY;
|
||||
} else if (TextUtils.equals(subKey, TUIConstants.TUIChat.EVENT_SUB_KEY_REPLY_MESSAGE_SUCCESS)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_REPLY_MESSAGE_IN_TOPIC_KEY;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(experienceName)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityExperienceChanged(experienceName);
|
||||
}
|
||||
}
|
||||
} else if (TextUtils.equals(key, TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE)) {
|
||||
String experienceName = null;
|
||||
if (TextUtils.equals(subKey, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_COMMUNITY)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_CREATE_COMMUNITY_KEY;
|
||||
} else if (TextUtils.equals(subKey, TUIConstants.TUICommunity.EVENT_SUB_KEY_ADD_COMMUNITY)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_ADD_COMMUNITY_KEY;
|
||||
} else if (TextUtils.equals(subKey, TUIConstants.TUICommunity.EVENT_SUB_KEY_DISBAND_COMMUNITY)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_DISBAND_COMMUNITY_KEY;
|
||||
} else if (TextUtils.equals(subKey, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_TOPIC)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_CREATE_TOPIC_KEY;
|
||||
} else if (TextUtils.equals(subKey, TUIConstants.TUICommunity.EVENT_SUB_KEY_DELETE_TOPIC)) {
|
||||
experienceName = CommunityConstants.COMMUNITY_EXPERIENCE_DELETE_TOPIC_KEY;
|
||||
}
|
||||
if (!TextUtils.isEmpty(experienceName)) {
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onCommunityExperienceChanged(experienceName);
|
||||
}
|
||||
}
|
||||
} else if (TextUtils.equals(key, TUIConstants.TUILogin.EVENT_LOGIN_STATE_CHANGED)) {
|
||||
if (TextUtils.equals(subKey, TUIConstants.TUILogin.EVENT_SUB_KEY_USER_INFO_UPDATED)) {
|
||||
if (param != null) {
|
||||
String faceUrl = (String) param.get(TUIConstants.TUILogin.SELF_FACE_URL);
|
||||
List<CommunityEventListener> listeners = getCommunityEventListenerList();
|
||||
for (CommunityEventListener communityEventListener : listeners) {
|
||||
communityEventListener.onSelfFaceChanged(faceUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TUIExtensionInfo> onGetExtension(String extensionID, Map<String, Object> param) {
|
||||
if (TextUtils.equals(extensionID, TUIConstants.TUIChat.Extension.ChatNavigationMoreItem.CLASSIC_EXTENSION_ID)) {
|
||||
Object topicID = param.get(TUIConstants.TUIChat.Extension.ChatNavigationMoreItem.TOPIC_ID);
|
||||
if (topicID instanceof String) {
|
||||
TUIExtensionInfo extensionInfo = new TUIExtensionInfo();
|
||||
extensionInfo.setIcon(R.drawable.community_chat_extension_title_bar_more_menu_light);
|
||||
extensionInfo.setExtensionListener(new TUIExtensionEventListener() {
|
||||
@Override
|
||||
public void onClicked(Map<String, Object> param) {
|
||||
Intent intent = new Intent(getAppContext(), TopicInfoActivity.class);
|
||||
intent.putExtra(TUIConstants.TUICommunity.TOPIC_ID, (String) topicID);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getAppContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
return Collections.singletonList(extensionInfo);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Context getAppContext() {
|
||||
return ServiceInitializer.getAppContext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityBean implements Comparable<CommunityBean>, Serializable {
|
||||
public static final int ROLE_UNDEFINED = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_UNDEFINED;
|
||||
public static final int ROLE_ADMIN = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_ROLE_ADMIN;
|
||||
public static final int ROLE_OWNER = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_ROLE_OWNER;
|
||||
public static final int ROLE_MEMBER = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_ROLE_MEMBER;
|
||||
|
||||
private String groupId;
|
||||
private String groupFaceUrl;
|
||||
private String communityName;
|
||||
private String introduction;
|
||||
private String coverUrl;
|
||||
private String owner;
|
||||
private int role;
|
||||
private long createTime;
|
||||
private long joinTime;
|
||||
private long lastMessageTime;
|
||||
private long lastInfoTime;
|
||||
private List<String> topicCategories;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public void setLastMessageTime(long lastMessageTime) {
|
||||
this.lastMessageTime = lastMessageTime;
|
||||
}
|
||||
|
||||
public long getLastMessageTime() {
|
||||
return lastMessageTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public void setJoinTime(long joinTime) {
|
||||
this.joinTime = joinTime;
|
||||
}
|
||||
|
||||
public void setLastInfoTime(long lastInfoTime) {
|
||||
this.lastInfoTime = lastInfoTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public long getJoinTime() {
|
||||
return joinTime;
|
||||
}
|
||||
|
||||
public long getLastInfoTime() {
|
||||
return lastInfoTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by latest event time
|
||||
*/
|
||||
public long getSortTime() {
|
||||
long sortTime = createTime;
|
||||
sortTime = Math.max(sortTime, joinTime);
|
||||
sortTime = Math.max(sortTime, lastInfoTime);
|
||||
sortTime = Math.max(sortTime, lastMessageTime);
|
||||
return sortTime;
|
||||
}
|
||||
|
||||
public String getGroupFaceUrl() {
|
||||
return groupFaceUrl;
|
||||
}
|
||||
|
||||
public void setGroupFaceUrl(String groupFaceUrl) {
|
||||
this.groupFaceUrl = groupFaceUrl;
|
||||
}
|
||||
|
||||
public String getCommunityName() {
|
||||
return communityName;
|
||||
}
|
||||
|
||||
public void setCommunityName(String communityName) {
|
||||
this.communityName = communityName;
|
||||
}
|
||||
|
||||
public String getIntroduction() {
|
||||
return introduction;
|
||||
}
|
||||
|
||||
public void setIntroduction(String introduction) {
|
||||
this.introduction = introduction;
|
||||
}
|
||||
|
||||
public int getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(int role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public String getCoverUrl() {
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public void setTopicCategories(List<String> topicCategories) {
|
||||
this.topicCategories = topicCategories;
|
||||
}
|
||||
|
||||
public List<String> getTopicCategories() {
|
||||
return topicCategories;
|
||||
}
|
||||
|
||||
public boolean isOwner() {
|
||||
return TextUtils.equals(owner, TUILogin.getLoginUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CommunityBean o) {
|
||||
if (getSortTime() > o.getSortTime()) {
|
||||
return -1;
|
||||
} else if (getSortTime() == o.getSortTime()) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupChangeInfo;
|
||||
|
||||
public class CommunityChangeBean {
|
||||
private V2TIMGroupChangeInfo v2TIMGroupChangeInfo;
|
||||
public static final int CHANGE_TYPE_INVALID = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_INVALID;
|
||||
|
||||
public static final int CHANGE_TYPE_NAME = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_NAME;
|
||||
|
||||
public static final int CHANGE_TYPE_INTRODUCTION = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_INTRODUCTION;
|
||||
|
||||
public static final int CHANGE_TYPE_NOTIFICATION = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_NOTIFICATION;
|
||||
|
||||
public static final int CHANGE_TYPE_FACE_URL = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_FACE_URL;
|
||||
|
||||
public static final int CHANGE_TYPE_OWNER = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER;
|
||||
|
||||
public static final int CHANGE_TYPE_CUSTOM = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_CUSTOM;
|
||||
|
||||
public static final int CHANGE_TYPE_SHUT_UP_ALL = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_SHUT_UP_ALL;
|
||||
|
||||
public static final int CHANGE_TYPE_RECEIVE_MESSAGE_OPT = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_RECEIVE_MESSAGE_OPT;
|
||||
|
||||
public static final int CHANGE_TYPE_GROUP_ADD_OPT = V2TIMGroupChangeInfo.V2TIM_GROUP_INFO_CHANGE_TYPE_GROUP_ADD_OPT;
|
||||
|
||||
public int getType() {
|
||||
if (v2TIMGroupChangeInfo != null) {
|
||||
return v2TIMGroupChangeInfo.getType();
|
||||
}
|
||||
return CHANGE_TYPE_INVALID;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
if (v2TIMGroupChangeInfo != null) {
|
||||
return v2TIMGroupChangeInfo.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
if (v2TIMGroupChangeInfo != null) {
|
||||
return v2TIMGroupChangeInfo.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setV2TIMGroupChangeInfo(V2TIMGroupChangeInfo v2TIMGroupChangeInfo) {
|
||||
this.v2TIMGroupChangeInfo = v2TIMGroupChangeInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CommunityMemberBean implements Serializable {
|
||||
private String account;
|
||||
private String avatar;
|
||||
private String nameCard;
|
||||
private String nickName;
|
||||
private String friendRemark;
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getNameCard() {
|
||||
return nameCard;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNameCard(String nameCard) {
|
||||
this.nameCard = nameCard;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public void setFriendRemark(String friendRemark) {
|
||||
this.friendRemark = friendRemark;
|
||||
}
|
||||
|
||||
public String getFriendRemark() {
|
||||
return friendRemark;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
String displayName = account;
|
||||
if (!TextUtils.isEmpty(nameCard)) {
|
||||
displayName = nameCard;
|
||||
} else if (!TextUtils.isEmpty(friendRemark)) {
|
||||
displayName = friendRemark;
|
||||
} else if (!TextUtils.isEmpty(nickName)) {
|
||||
displayName = nickName;
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import android.text.Html;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupAtInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicInfo;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TopicBean implements Serializable, ITopicBean {
|
||||
public static final int CHAT_TYPE_GROUP = V2TIMConversation.V2TIM_GROUP;
|
||||
|
||||
public static final int TOPIC_TYPE_TEXT = 1;
|
||||
|
||||
private String id;
|
||||
private String topicName;
|
||||
private String faceUrl;
|
||||
private String draftText;
|
||||
private V2TIMMessage lastMessage;
|
||||
private V2TIMTopicInfo v2TIMTopicInfo;
|
||||
private CharSequence lastMessageAbstract;
|
||||
private long unreadCount;
|
||||
private String category;
|
||||
private int type;
|
||||
private boolean isAllMute = false;
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setID(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTopicName() {
|
||||
return topicName;
|
||||
}
|
||||
|
||||
public void setTopicName(String topicName) {
|
||||
this.topicName = topicName;
|
||||
}
|
||||
|
||||
public String getFaceUrl() {
|
||||
return faceUrl;
|
||||
}
|
||||
|
||||
public void setFaceUrl(String faceUrl) {
|
||||
this.faceUrl = faceUrl;
|
||||
}
|
||||
|
||||
public void setAllMute(boolean allMute) {
|
||||
isAllMute = allMute;
|
||||
}
|
||||
|
||||
public boolean isAllMute() {
|
||||
return isAllMute;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
public V2TIMMessage getLastMessage() {
|
||||
return lastMessage;
|
||||
}
|
||||
|
||||
public void setLastMessage(V2TIMMessage lastMessage) {
|
||||
this.lastMessage = lastMessage;
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put(TUIConstants.TUIChat.V2TIMMESSAGE, lastMessage);
|
||||
String lastMsgDisplayString = (String) TUICore.callService(TUIConstants.TUIChat.SERVICE_NAME, TUIConstants.TUIChat.METHOD_GET_DISPLAY_STRING, param);
|
||||
|
||||
// Get the characters to display
|
||||
if (lastMsgDisplayString != null) {
|
||||
lastMessageAbstract = Html.fromHtml(lastMsgDisplayString);
|
||||
}
|
||||
}
|
||||
|
||||
public long getUnreadCount() {
|
||||
return unreadCount;
|
||||
}
|
||||
|
||||
public void setUnreadCount(long unreadCount) {
|
||||
this.unreadCount = unreadCount;
|
||||
}
|
||||
|
||||
public CharSequence getLastMsgAbstract() {
|
||||
return lastMessageAbstract;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getAtType() {
|
||||
int atInfoType = 0;
|
||||
boolean atMe = false;
|
||||
boolean atAll = false;
|
||||
|
||||
if (v2TIMTopicInfo == null) {
|
||||
return V2TIMGroupAtInfo.TIM_AT_UNKNOWN;
|
||||
}
|
||||
|
||||
List<V2TIMGroupAtInfo> atInfoList = v2TIMTopicInfo.getGroupAtInfoList();
|
||||
for (V2TIMGroupAtInfo atInfo : atInfoList) {
|
||||
if (atInfo.getAtType() == V2TIMGroupAtInfo.TIM_AT_ME) {
|
||||
atMe = true;
|
||||
continue;
|
||||
}
|
||||
if (atInfo.getAtType() == V2TIMGroupAtInfo.TIM_AT_ALL) {
|
||||
atAll = true;
|
||||
continue;
|
||||
}
|
||||
if (atInfo.getAtType() == V2TIMGroupAtInfo.TIM_AT_ALL_AT_ME) {
|
||||
atMe = true;
|
||||
atAll = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (atAll && atMe) {
|
||||
atInfoType = V2TIMGroupAtInfo.TIM_AT_ALL_AT_ME;
|
||||
} else if (atAll) {
|
||||
atInfoType = V2TIMGroupAtInfo.TIM_AT_ALL;
|
||||
} else if (atMe) {
|
||||
atInfoType = V2TIMGroupAtInfo.TIM_AT_ME;
|
||||
} else {
|
||||
atInfoType = V2TIMGroupAtInfo.TIM_AT_UNKNOWN;
|
||||
}
|
||||
|
||||
return atInfoType;
|
||||
}
|
||||
|
||||
public void setV2TIMTopicInfo(V2TIMTopicInfo v2TIMTopicInfo) {
|
||||
this.v2TIMTopicInfo = v2TIMTopicInfo;
|
||||
}
|
||||
|
||||
public V2TIMTopicInfo getV2TIMTopicInfo() {
|
||||
return v2TIMTopicInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ITopicBean o) {
|
||||
if (o instanceof TopicFoldBean) {
|
||||
return -1;
|
||||
}
|
||||
TopicBean topicBean = (TopicBean) o;
|
||||
return topicName.compareTo(topicBean.topicName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TopicFoldBean implements ITopicBean, Serializable {
|
||||
private String foldName;
|
||||
|
||||
public String getFoldName() {
|
||||
return foldName;
|
||||
}
|
||||
|
||||
public void setFoldName(String foldName) {
|
||||
this.foldName = foldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ITopicBean o) {
|
||||
if (o instanceof TopicBean) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TreeNode<T extends Comparable<T>> implements Serializable, Comparable<TreeNode<T>> {
|
||||
private String nodeName;
|
||||
private int level = 0;
|
||||
private boolean isCollapse = false;
|
||||
private List<TreeNode<T>> childList;
|
||||
private TreeNode<T> parent;
|
||||
private T data;
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setChildList(List<TreeNode<T>> childList) {
|
||||
this.childList = childList;
|
||||
}
|
||||
|
||||
public void setCollapse(boolean collapse) {
|
||||
isCollapse = collapse;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public List<TreeNode<T>> getChildList() {
|
||||
return childList;
|
||||
}
|
||||
|
||||
public String getNodeName() {
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public boolean isCollapse() {
|
||||
return isCollapse(this);
|
||||
}
|
||||
|
||||
private boolean isCollapse(TreeNode<T> node) {
|
||||
if (node.isCollapse) {
|
||||
return true;
|
||||
} else {
|
||||
if (node.parent != null) {
|
||||
return isCollapse(node.parent);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getNodeCount() {
|
||||
return getChildCount(this) + 1;
|
||||
}
|
||||
|
||||
public void setParent(TreeNode<T> parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public TreeNode<T> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean hasChild() {
|
||||
return childList != null && !childList.isEmpty();
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return getChildCount(this);
|
||||
}
|
||||
|
||||
private int getChildCount(TreeNode<T> treeNode) {
|
||||
if (treeNode.childList == null) {
|
||||
return 0;
|
||||
}
|
||||
int count = treeNode.childList.size();
|
||||
for (TreeNode<T> node : treeNode.childList) {
|
||||
count += getChildCount(node);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public void addNodes(List<TreeNode<T>> nodeList) {
|
||||
if (nodeList == null) {
|
||||
return;
|
||||
}
|
||||
for (TreeNode<T> node : nodeList) {
|
||||
addNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void addNode(TreeNode<T> node) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
if (childList == null) {
|
||||
childList = new ArrayList<>();
|
||||
}
|
||||
node.parent = this;
|
||||
node.level = this.level + 1;
|
||||
childList.add(node);
|
||||
Collections.sort(childList);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
childList = null;
|
||||
isCollapse = false;
|
||||
parent = null;
|
||||
data = null;
|
||||
level = 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean remove() {
|
||||
return remove(false);
|
||||
}
|
||||
|
||||
public boolean remove(boolean deleteChildren) {
|
||||
return delete(this, deleteChildren);
|
||||
}
|
||||
|
||||
public boolean delete(TreeNode<T> node) {
|
||||
return delete(node, false);
|
||||
}
|
||||
|
||||
public boolean delete(TreeNode<T> node, boolean deleteChildren) {
|
||||
if (node == null) {
|
||||
return true;
|
||||
}
|
||||
return delete(this, node, deleteChildren);
|
||||
}
|
||||
|
||||
private boolean delete(TreeNode<T> parent, TreeNode<T> node, boolean deleteChildren) {
|
||||
if (parent.nodeEquals(node)) {
|
||||
TreeNode<T> parentParent = parent.getParent();
|
||||
if (parentParent != null) {
|
||||
return delete(parentParent, parent, deleteChildren);
|
||||
}
|
||||
// if root node, return false
|
||||
return false;
|
||||
}
|
||||
List<TreeNode<T>> nodeList = parent.childList;
|
||||
if (nodeList == null || nodeList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (TreeNode<T> treeNode : nodeList) {
|
||||
if (node.nodeEquals(treeNode)) {
|
||||
if (!deleteChildren) {
|
||||
if (node.hasChild()) {
|
||||
List<TreeNode<T>> deleteNodeChildList = node.childList;
|
||||
parent.addNodes(deleteNodeChildList);
|
||||
}
|
||||
}
|
||||
return nodeList.remove(treeNode);
|
||||
}
|
||||
if (treeNode.hasChild()) {
|
||||
boolean treeNodeDelete = delete(treeNode, node, deleteChildren);
|
||||
if (treeNodeDelete) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsNode(TreeNode<T> node) {
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
return containsNode(this, node);
|
||||
}
|
||||
|
||||
private boolean containsNode(TreeNode<T> parent, TreeNode<T> node) {
|
||||
if (parent.nodeEquals(node)) {
|
||||
return true;
|
||||
}
|
||||
List<TreeNode<T>> nodeList = parent.childList;
|
||||
if (nodeList == null || nodeList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (TreeNode<T> treeNode : nodeList) {
|
||||
if (node.nodeEquals(treeNode)) {
|
||||
return true;
|
||||
}
|
||||
if (treeNode.hasChild()) {
|
||||
boolean treeNodeContains = containsNode(treeNode, node);
|
||||
if (treeNodeContains) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TreeNode<T> getRoot() {
|
||||
return getRoot(this);
|
||||
}
|
||||
|
||||
private TreeNode<T> getRoot(TreeNode<T> node) {
|
||||
if (node.parent != null) {
|
||||
return getRoot(node.parent);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public int indexOf(TreeNode<T> node) {
|
||||
List<TreeNode<T>> list = getRoot().toList();
|
||||
return list.indexOf(node);
|
||||
}
|
||||
|
||||
public List<TreeNode<T>> toList() {
|
||||
List<TreeNode<T>> nodeList = new ArrayList<>();
|
||||
visitNode(nodeList, this);
|
||||
nodeList.remove(this);
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
public void visitNode(List<TreeNode<T>> list, TreeNode<T> node) {
|
||||
list.add(node);
|
||||
if (!node.hasChild()) {
|
||||
return;
|
||||
}
|
||||
for (TreeNode<T> child : node.childList) {
|
||||
visitNode(list, child);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean nodeEquals(TreeNode<T> node1, TreeNode<T> node2) {
|
||||
return node1 == node2;
|
||||
}
|
||||
|
||||
public final boolean nodeEquals(TreeNode<T> node) {
|
||||
return nodeEquals(this, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TreeNode<T> o) {
|
||||
return compareDataTo(o.getData());
|
||||
}
|
||||
|
||||
public int compareDataTo(T data) {
|
||||
if (this.data != null && data != null) {
|
||||
return this.data.compareTo(data);
|
||||
} else if (this.data == null && data != null) {
|
||||
return -1;
|
||||
} else if (this.data != null && data == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.IPopupCard;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.IPopupView;
|
||||
import java.util.List;
|
||||
|
||||
public class SelectListPopupView extends FrameLayout implements IPopupView {
|
||||
private View contentView;
|
||||
private int maxHeightPx;
|
||||
private TextView title;
|
||||
private TextView cancelButton;
|
||||
private RecyclerView selectList;
|
||||
private LinearLayoutManager layoutManager;
|
||||
|
||||
private List<String> data;
|
||||
private SelectAdapter adapter;
|
||||
private OnSelectListener onSelectListener;
|
||||
private String selected;
|
||||
private IPopupCard popupCard;
|
||||
|
||||
public SelectListPopupView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public SelectListPopupView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public SelectListPopupView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public SelectListPopupView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attributeSet) {
|
||||
contentView = LayoutInflater.from(context).inflate(R.layout.community_select_list_popup_layout, this);
|
||||
title = contentView.findViewById(R.id.title);
|
||||
cancelButton = contentView.findViewById(R.id.cancel_button);
|
||||
selectList = contentView.findViewById(R.id.select_list);
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
selectList.setLayoutManager(layoutManager);
|
||||
adapter = new SelectAdapter();
|
||||
selectList.setAdapter(adapter);
|
||||
|
||||
cancelButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (popupCard != null) {
|
||||
popupCard.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int measuredHeight = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (maxHeightPx > 0 && maxHeightPx < measuredHeight) {
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeightPx, MeasureSpec.AT_MOST);
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
public void setTitle(int stringResID) {
|
||||
title.setText(stringResID);
|
||||
}
|
||||
|
||||
public void setTitle(String titleString) {
|
||||
title.setText(titleString);
|
||||
}
|
||||
|
||||
public void setMaxHeightPx(int maxHeightPx) {
|
||||
this.maxHeightPx = maxHeightPx;
|
||||
}
|
||||
|
||||
public void setData(List<String> data) {
|
||||
this.data = data;
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setSelected(String selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public void setOnSelectListener(OnSelectListener onSelectListener) {
|
||||
this.onSelectListener = onSelectListener;
|
||||
}
|
||||
|
||||
class SelectAdapter extends RecyclerView.Adapter<SelectAdapter.SelectViewHolder> {
|
||||
@NonNull
|
||||
@Override
|
||||
public SelectViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_select_list_popup_item_layout, parent, false);
|
||||
return new SelectViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull SelectViewHolder holder, int position) {
|
||||
String itemName = data.get(position);
|
||||
holder.textView.setText(itemName);
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selected = itemName;
|
||||
notifyDataSetChanged();
|
||||
if (onSelectListener != null) {
|
||||
onSelectListener.onSelected(itemName);
|
||||
}
|
||||
if (popupCard != null) {
|
||||
popupCard.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (TextUtils.equals(itemName, selected)) {
|
||||
holder.itemView.setBackgroundColor(getResources().getColor(R.color.community_list_selected_color));
|
||||
} else {
|
||||
holder.itemView.setBackgroundColor(getResources().getColor(R.color.community_list_normal_color));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return data.size();
|
||||
}
|
||||
|
||||
class SelectViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView textView;
|
||||
|
||||
public SelectViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
textView = itemView.findViewById(R.id.item_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopupCard(IPopupCard popupCard) {
|
||||
this.popupCard = popupCard;
|
||||
}
|
||||
|
||||
public interface OnSelectListener {
|
||||
void onSelected(String data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
import android.graphics.drawable.shapes.Shape;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class SelectTextButton extends AppCompatTextView {
|
||||
private int radius;
|
||||
private int borderWidth;
|
||||
private int color;
|
||||
|
||||
private int leftTopRadius;
|
||||
private int rightTopRadius;
|
||||
private int rightBottomRadius;
|
||||
private int leftBottomRadius;
|
||||
|
||||
public SelectTextButton(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public SelectTextButton(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public SelectTextButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
setGravity(Gravity.CENTER);
|
||||
if (attrs != null) {
|
||||
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SelectTextButton);
|
||||
radius = array.getDimensionPixelOffset(R.styleable.SelectTextButton_button_radius, 0);
|
||||
borderWidth = array.getDimensionPixelOffset(R.styleable.SelectTextButton_border_width, 2);
|
||||
color = array.getColor(R.styleable.SelectTextButton_color, 0xFFFFFF);
|
||||
leftTopRadius = array.getDimensionPixelOffset(R.styleable.SelectTextButton_button_left_top_radius, 0);
|
||||
rightTopRadius = array.getDimensionPixelOffset(R.styleable.SelectTextButton_button_right_top_radius, 0);
|
||||
rightBottomRadius = array.getDimensionPixelOffset(R.styleable.SelectTextButton_button_right_bottom_radius, 0);
|
||||
leftBottomRadius = array.getDimensionPixelOffset(R.styleable.SelectTextButton_button_left_bottom_radius, 0);
|
||||
array.recycle();
|
||||
}
|
||||
|
||||
if (leftTopRadius == 0) {
|
||||
leftTopRadius = radius;
|
||||
}
|
||||
if (rightTopRadius == 0) {
|
||||
rightTopRadius = radius;
|
||||
}
|
||||
if (rightBottomRadius == 0) {
|
||||
rightBottomRadius = radius;
|
||||
}
|
||||
if (leftBottomRadius == 0) {
|
||||
leftBottomRadius = radius;
|
||||
}
|
||||
setBackground();
|
||||
}
|
||||
|
||||
private void setBackground() {
|
||||
float[] radius = {
|
||||
leftTopRadius, leftTopRadius, rightTopRadius, rightTopRadius, rightBottomRadius, rightBottomRadius, leftBottomRadius, leftBottomRadius};
|
||||
RectF rectF = new RectF(borderWidth, borderWidth, borderWidth, borderWidth);
|
||||
RoundRectShape shape = new RoundRectShape(radius, rectF, radius);
|
||||
ShapeDrawable shapeDrawable = new ShapeDrawable(shape) {
|
||||
@Override
|
||||
protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
|
||||
paint.setColor(color);
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
paint.setAntiAlias(true);
|
||||
super.onDraw(shape, canvas, paint);
|
||||
}
|
||||
};
|
||||
|
||||
setBackground(shapeDrawable);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.RoundCornerImageView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class SettingsLinearView extends LinearLayout {
|
||||
private String name;
|
||||
private String content;
|
||||
private boolean isShowBottomLine;
|
||||
private boolean isShowTopLine;
|
||||
private boolean isShowArrow;
|
||||
private boolean isShowCopy;
|
||||
private boolean isShowContentText;
|
||||
private boolean isShowContentImage;
|
||||
|
||||
private TextView nameText;
|
||||
private TextView contentText;
|
||||
private ImageView arrowView;
|
||||
private View contentView;
|
||||
private RoundCornerImageView contentImage;
|
||||
private TextCopyView copyView;
|
||||
|
||||
private int nameColor;
|
||||
private int nameColorResID;
|
||||
private int contentColor;
|
||||
private int contentColorResID;
|
||||
|
||||
private int contentImageWidth;
|
||||
private int contentImageHeight;
|
||||
|
||||
public SettingsLinearView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public SettingsLinearView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public SettingsLinearView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public SettingsLinearView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
if (attrs == null) {
|
||||
setUpView();
|
||||
return;
|
||||
}
|
||||
LayoutInflater.from(context).inflate(R.layout.community_settings_linear_layout, this);
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SettingsLinearView, 0, 0);
|
||||
try {
|
||||
name = ta.getString(R.styleable.SettingsLinearView_setting_name);
|
||||
content = ta.getString(R.styleable.SettingsLinearView_setting_content);
|
||||
int defaultNameColor = getResources().getColor(R.color.community_setting_linear_name_default_color);
|
||||
nameColor = ta.getColor(R.styleable.SettingsLinearView_setting_name_color, defaultNameColor);
|
||||
nameColorResID = ta.getResourceId(R.styleable.SettingsLinearView_setting_name_color, 0);
|
||||
int defaultContentColor = getResources().getColor(R.color.community_setting_linear_content_default_color);
|
||||
contentColor = ta.getColor(R.styleable.SettingsLinearView_setting_content_color, defaultContentColor);
|
||||
contentColorResID = ta.getResourceId(R.styleable.SettingsLinearView_setting_content_color, 0);
|
||||
|
||||
isShowContentText = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_content_text, true);
|
||||
isShowContentImage = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_content_image, false);
|
||||
name = ta.getString(R.styleable.SettingsLinearView_setting_name);
|
||||
isShowBottomLine = ta.getBoolean(com.tencent.qcloud.tuikit.timcommon.R.styleable.LineControllerView_isBottom, false);
|
||||
isShowCopy = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_copy, false);
|
||||
isShowArrow = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_arrow, true);
|
||||
isShowTopLine = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_top_line, false);
|
||||
isShowBottomLine = ta.getBoolean(R.styleable.SettingsLinearView_setting_is_show_bottom_line, false);
|
||||
|
||||
contentImageWidth = ta.getDimensionPixelOffset(R.styleable.SettingsLinearView_setting_content_image_width, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
contentImageHeight = ta.getDimensionPixelOffset(R.styleable.SettingsLinearView_setting_content_image_height, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
} finally {
|
||||
ta.recycle();
|
||||
}
|
||||
setUpView();
|
||||
}
|
||||
|
||||
private void setUpView() {
|
||||
copyView = findViewById(R.id.copy_button);
|
||||
copyView.setVisibility(isShowCopy ? VISIBLE : GONE);
|
||||
|
||||
contentView = findViewById(R.id.content);
|
||||
// name text and color
|
||||
nameText = findViewById(R.id.name);
|
||||
nameText.setText(name);
|
||||
int tempNameColor = nameColor;
|
||||
if (nameColorResID != 0) {
|
||||
tempNameColor = getResources().getColor(nameColorResID);
|
||||
}
|
||||
nameText.setTextColor(tempNameColor);
|
||||
|
||||
// content text and color
|
||||
contentText = findViewById(R.id.content_text);
|
||||
setContent(content);
|
||||
int tempContentColor = contentColor;
|
||||
if (contentColorResID != 0) {
|
||||
tempContentColor = getResources().getColor(contentColorResID);
|
||||
}
|
||||
contentText.setTextColor(tempContentColor);
|
||||
contentText.setVisibility(isShowContentText ? VISIBLE : GONE);
|
||||
|
||||
View bottomLine = findViewById(R.id.bottom_line);
|
||||
View topLine = findViewById(R.id.top_line);
|
||||
bottomLine.setVisibility(isShowBottomLine ? VISIBLE : GONE);
|
||||
topLine.setVisibility(isShowTopLine ? VISIBLE : GONE);
|
||||
|
||||
setupArrow();
|
||||
|
||||
contentImage = findViewById(R.id.content_image);
|
||||
contentImage.setVisibility(isShowContentImage ? VISIBLE : GONE);
|
||||
ViewGroup.LayoutParams layoutParams = contentImage.getLayoutParams();
|
||||
layoutParams.width = contentImageWidth;
|
||||
layoutParams.height = contentImageHeight;
|
||||
contentImage.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
private void setupArrow() {
|
||||
arrowView = findViewById(R.id.right_arrow);
|
||||
arrowView.setVisibility(isShowArrow ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return contentText.getText().toString();
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
nameText.setText(name);
|
||||
}
|
||||
|
||||
public TextView getContentText() {
|
||||
return contentText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
contentText.setText(content);
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
copyView.setVisibility(GONE);
|
||||
} else {
|
||||
if (isShowCopy) {
|
||||
copyView.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
contentText.requestLayout();
|
||||
}
|
||||
|
||||
public void setShowArrow(boolean isShowArrow) {
|
||||
this.isShowArrow = isShowArrow;
|
||||
setupArrow();
|
||||
}
|
||||
|
||||
public void setOnContentClickListener(View.OnClickListener clickListener) {
|
||||
contentView.setOnClickListener(clickListener);
|
||||
}
|
||||
|
||||
public RoundCornerImageView getContentImage() {
|
||||
return contentImage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class TextCopyView extends AppCompatTextView {
|
||||
private int bindResID = 0;
|
||||
private TextView bindTextView = null;
|
||||
|
||||
public TextCopyView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public TextCopyView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public TextCopyView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
if (attrs != null) {
|
||||
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TextCopyView);
|
||||
bindResID = array.getResourceId(R.styleable.TextCopyView_bind_copy_text, 0);
|
||||
array.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(TextView textView) {
|
||||
if (textView == null) {
|
||||
return;
|
||||
}
|
||||
this.bindTextView = textView;
|
||||
setCopyAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
ViewParent parent = getParent();
|
||||
View textView = null;
|
||||
while (parent instanceof View) {
|
||||
textView = ((View) parent).findViewById(bindResID);
|
||||
if (textView != null) {
|
||||
break;
|
||||
} else {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
if (textView instanceof TextView) {
|
||||
this.bindTextView = (TextView) textView;
|
||||
setCopyAction();
|
||||
}
|
||||
}
|
||||
|
||||
private void setCopyAction() {
|
||||
if (this.bindTextView == null) {
|
||||
return;
|
||||
}
|
||||
setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (clipboard == null) {
|
||||
return;
|
||||
}
|
||||
CharSequence charSequence = bindTextView.getText();
|
||||
ClipData clip = ClipData.newPlainText("message", charSequence);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
if (!TextUtils.isEmpty(charSequence)) {
|
||||
String copySuccess = getResources().getString(R.string.community_copy_success_tip);
|
||||
ToastUtil.toastShortMessage(copySuccess);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class TextCountView extends AppCompatTextView implements TextWatcher {
|
||||
private int limit = 0;
|
||||
private int bindResID = 0;
|
||||
|
||||
public TextCountView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public TextCountView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public TextCountView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
if (attrs != null) {
|
||||
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TextCountView);
|
||||
limit = array.getInt(R.styleable.TextCountView_limit_count, limit);
|
||||
bindResID = array.getResourceId(R.styleable.TextCountView_bind_edit_text, 0);
|
||||
}
|
||||
if (limit != 0) {
|
||||
setText(0 + "/" + limit);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
if (limit != 0) {
|
||||
setText(0 + "/" + limit);
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(EditText editText) {
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
editText.addTextChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
ViewParent parent = getParent();
|
||||
View editText = null;
|
||||
while (parent instanceof View) {
|
||||
editText = ((View) parent).findViewById(bindResID);
|
||||
if (editText != null) {
|
||||
break;
|
||||
} else {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
if (editText instanceof EditText) {
|
||||
((EditText) editText).addTextChangedListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
String text = s.toString();
|
||||
setText(text.length() + "/" + limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component.banner;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BannerIndicatorView extends LinearLayout {
|
||||
private static final int PLAY_TIME = 150; // 300ms
|
||||
|
||||
private final List<ViewWrapper> viewWrappers = new ArrayList<>();
|
||||
private AnimatorSet showAnimSet;
|
||||
private AnimatorSet resetAnimSet;
|
||||
|
||||
private int normalWidth;
|
||||
private int selectedWidth;
|
||||
|
||||
public BannerIndicatorView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setOrientation(HORIZONTAL);
|
||||
setGravity(Gravity.CENTER);
|
||||
normalWidth = ScreenUtil.dip2px(8);
|
||||
selectedWidth = ScreenUtil.dip2px(16);
|
||||
}
|
||||
|
||||
public BannerIndicatorView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public void init(int count) {
|
||||
this.removeAllViews();
|
||||
for (int i = 0; i < count; i++) {
|
||||
ViewWrapper viewWrapper = new ViewWrapper(getContext());
|
||||
if (i == 0) {
|
||||
ViewGroup.LayoutParams layoutParams = viewWrapper.getView().getLayoutParams();
|
||||
layoutParams.width = selectedWidth;
|
||||
viewWrapper.getView().setLayoutParams(layoutParams);
|
||||
viewWrapper.setBackgroundColor(getContext().getResources().getColor(R.color.community_banner_selected_color));
|
||||
}
|
||||
this.addView(viewWrapper.getView(), viewWrapper.getView().getLayoutParams());
|
||||
viewWrappers.add(viewWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
public void playBy(int startPosition, int nextPosition) {
|
||||
boolean isShowInAnimOnly = false;
|
||||
if (startPosition < 0 || nextPosition < 0 || nextPosition == startPosition) {
|
||||
startPosition = nextPosition = 0;
|
||||
}
|
||||
|
||||
if (startPosition < 0) {
|
||||
isShowInAnimOnly = true;
|
||||
startPosition = nextPosition = 0;
|
||||
}
|
||||
|
||||
final ViewWrapper startView = viewWrappers.get(startPosition);
|
||||
final ViewWrapper nextView = viewWrappers.get(nextPosition);
|
||||
|
||||
if (resetAnimSet != null && resetAnimSet.isRunning()) {
|
||||
resetAnimSet.cancel();
|
||||
resetAnimSet = null;
|
||||
}
|
||||
ObjectAnimator animReset = ObjectAnimator.ofInt(startView, "width", selectedWidth, normalWidth);
|
||||
resetAnimSet = new AnimatorSet();
|
||||
resetAnimSet.setDuration(PLAY_TIME);
|
||||
resetAnimSet.play(animReset);
|
||||
|
||||
if (showAnimSet != null && showAnimSet.isRunning()) {
|
||||
showAnimSet.cancel();
|
||||
showAnimSet = null;
|
||||
}
|
||||
ObjectAnimator animShow = ObjectAnimator.ofInt(nextView, "width", normalWidth, selectedWidth);
|
||||
showAnimSet = new AnimatorSet();
|
||||
showAnimSet.setDuration(PLAY_TIME);
|
||||
showAnimSet.play(animShow);
|
||||
|
||||
if (isShowInAnimOnly) {
|
||||
showAnimSet.start();
|
||||
return;
|
||||
}
|
||||
|
||||
animReset.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
startView.setBackgroundColor(getResources().getColor(R.color.community_banner_normal_color));
|
||||
ObjectAnimator animFil1l = ObjectAnimator.ofInt(startView, "width", normalWidth);
|
||||
AnimatorSet mFillAnimatorSet = new AnimatorSet();
|
||||
mFillAnimatorSet.play(animFil1l);
|
||||
mFillAnimatorSet.start();
|
||||
nextView.setBackgroundColor(getResources().getColor(R.color.community_banner_selected_color));
|
||||
showAnimSet.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {}
|
||||
});
|
||||
resetAnimSet.start();
|
||||
}
|
||||
|
||||
private static class ViewWrapper {
|
||||
private final View view;
|
||||
private final ShapeDrawable drawable;
|
||||
|
||||
public ViewWrapper(Context context) {
|
||||
view = new View(context);
|
||||
int viewRadius = ScreenUtil.dip2px(1.5f);
|
||||
float[] radius = {viewRadius, viewRadius, viewRadius, viewRadius, viewRadius, viewRadius, viewRadius, viewRadius};
|
||||
RoundRectShape shape = new RoundRectShape(radius, null, null);
|
||||
drawable = new ShapeDrawable(shape);
|
||||
drawable.getPaint().setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
drawable.getPaint().setAntiAlias(true);
|
||||
drawable.getPaint().setColor(context.getResources().getColor(R.color.community_banner_normal_color));
|
||||
LayoutParams params = new LayoutParams(ScreenUtil.dip2px(8), ScreenUtil.dip2px(3));
|
||||
params.gravity = Gravity.CENTER;
|
||||
params.rightMargin = ScreenUtil.dip2px(3);
|
||||
view.setLayoutParams(params);
|
||||
view.setBackground(drawable);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int color) {
|
||||
drawable.getPaint().setColor(color);
|
||||
drawable.invalidateSelf();
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
layoutParams.width = width;
|
||||
view.setLayoutParams(layoutParams);
|
||||
view.requestLayout();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
return layoutParams.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component.banner;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ThreadUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class BannerView extends FrameLayout {
|
||||
private static final int DEFAULT_INTERVAL = 3000; // 1s
|
||||
|
||||
private RecyclerView bannerList;
|
||||
private BannerIndicatorView bannerIndicatorView;
|
||||
private LinearLayoutManager bannerLayoutManager;
|
||||
private BannerAdapter bannerListAdapter;
|
||||
private List<BannerItem> bannerData;
|
||||
|
||||
private int oldFacePageIndex = 0;
|
||||
private int interval = DEFAULT_INTERVAL;
|
||||
private Timer switchTimer;
|
||||
|
||||
public BannerView(Context context) {
|
||||
super(context);
|
||||
init(null);
|
||||
}
|
||||
|
||||
public BannerView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public BannerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public BannerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs) {
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.community_banner_view_layout, this);
|
||||
bannerList = view.findViewById(R.id.banner_list);
|
||||
bannerIndicatorView = view.findViewById(R.id.banner_indicator);
|
||||
bannerLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false) {
|
||||
@Override
|
||||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
||||
LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
|
||||
@Override
|
||||
protected int calculateTimeForScrolling(int dx) {
|
||||
return super.calculateTimeForScrolling(dx) * 9;
|
||||
}
|
||||
};
|
||||
linearSmoothScroller.setTargetPosition(position);
|
||||
startSmoothScroll(linearSmoothScroller);
|
||||
}
|
||||
};
|
||||
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
|
||||
bannerList.setLayoutManager(bannerLayoutManager);
|
||||
pagerSnapHelper.attachToRecyclerView(bannerList);
|
||||
bannerListAdapter = new BannerAdapter();
|
||||
bannerList.setAdapter(bannerListAdapter);
|
||||
bannerList.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
int currentFacePageIndex;
|
||||
if (dx >= 0) {
|
||||
currentFacePageIndex = bannerLayoutManager.findLastVisibleItemPosition();
|
||||
} else {
|
||||
currentFacePageIndex = bannerLayoutManager.findFirstVisibleItemPosition();
|
||||
}
|
||||
// the page is not be selected
|
||||
if (currentFacePageIndex == RecyclerView.NO_POSITION || oldFacePageIndex == currentFacePageIndex) {
|
||||
return;
|
||||
}
|
||||
bannerIndicatorView.playBy(oldFacePageIndex % bannerData.size(), currentFacePageIndex % bannerData.size());
|
||||
oldFacePageIndex = currentFacePageIndex;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setBannerData(List<BannerItem> data) {
|
||||
bannerData = data;
|
||||
bannerIndicatorView.init(data.size());
|
||||
bannerListAdapter.notifyDataSetChanged();
|
||||
switchTimer = new Timer();
|
||||
switchTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int nextIndex = oldFacePageIndex + 1;
|
||||
bannerList.smoothScrollToPosition(nextIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (switchTimer != null) {
|
||||
switchTimer.cancel();
|
||||
}
|
||||
switchTimer = null;
|
||||
}
|
||||
|
||||
public static class BannerItem {
|
||||
private Object imageUri;
|
||||
private OnClickListener onClickListener;
|
||||
|
||||
public void setImageUri(Object imageUri) {
|
||||
this.imageUri = imageUri;
|
||||
}
|
||||
|
||||
public void setOnClickListener(OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
}
|
||||
|
||||
class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerViewHolder> {
|
||||
@NonNull
|
||||
@Override
|
||||
public BannerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_banner_item_view_layout, parent, false);
|
||||
return new BannerViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BannerViewHolder holder, int position) {
|
||||
int realPosition = position % bannerData.size();
|
||||
holder.itemView.setOnClickListener(bannerData.get(realPosition).onClickListener);
|
||||
GlideEngine.loadImage(holder.imageView, bannerData.get(realPosition).imageUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (bannerData == null || bannerData.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
class BannerViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView imageView;
|
||||
|
||||
public BannerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class BottomPopupCard implements IPopupCard {
|
||||
private PopupWindow popupWindow;
|
||||
|
||||
public BottomPopupCard(Activity activity, View contentView) {
|
||||
if (!(contentView instanceof IPopupView)) {
|
||||
return;
|
||||
}
|
||||
((IPopupView) contentView).setPopupCard(this);
|
||||
popupWindow = new PopupWindow(contentView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, true) {
|
||||
@Override
|
||||
public void showAtLocation(View anchor, int gravity, int x, int y) {
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
Window window = activity.getWindow();
|
||||
startAnimation(window, true);
|
||||
}
|
||||
super.showAtLocation(anchor, gravity, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
Window window = activity.getWindow();
|
||||
startAnimation(window, false);
|
||||
}
|
||||
super.dismiss();
|
||||
}
|
||||
};
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
||||
popupWindow.setTouchable(true);
|
||||
popupWindow.setOutsideTouchable(false);
|
||||
popupWindow.setAnimationStyle(R.style.BottomPopupAnimation);
|
||||
}
|
||||
|
||||
private void startAnimation(Window window, boolean isShow) {
|
||||
ValueAnimator animator;
|
||||
if (isShow) {
|
||||
animator = ValueAnimator.ofFloat(1.0f, 0.5f);
|
||||
} else {
|
||||
animator = ValueAnimator.ofFloat(0.5f, 1.0f);
|
||||
}
|
||||
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.alpha = (float) animation.getAnimatedValue();
|
||||
window.setAttributes(lp);
|
||||
}
|
||||
});
|
||||
LinearInterpolator interpolator = new LinearInterpolator();
|
||||
animator.setDuration(200);
|
||||
animator.setInterpolator(interpolator);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
public void show(View rootView) {
|
||||
if (popupWindow != null) {
|
||||
popupWindow.showAtLocation(rootView, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard;
|
||||
|
||||
public interface IPopupCard {
|
||||
void dismiss();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard;
|
||||
|
||||
public interface IPopupView {
|
||||
void setPopupCard(IPopupCard popupCard);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityChangeBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CommunityEventListener {
|
||||
public void onCommunityCreated(String groupID) {}
|
||||
|
||||
public void onCommunityDeleted(String groupID) {}
|
||||
|
||||
public void onTopicCreated(String groupID, String topicID) {}
|
||||
|
||||
public void onTopicDeleted(String groupID, List<String> topicIDs) {}
|
||||
|
||||
public void onTopicChanged(String groupID, TopicBean topicBean) {}
|
||||
|
||||
public void onGroupAttrChanged(String groupID, Map<String, String> groupAttributeMap) {}
|
||||
|
||||
public void onCommunityInfoChanged(String groupID, List<CommunityChangeBean> communityChangeBeans) {}
|
||||
|
||||
public void onJoinedCommunity(String groupID) {}
|
||||
|
||||
public void onCommunityExperienceChanged(String experienceName) {}
|
||||
|
||||
public void onNetworkStateChanged(int state) {}
|
||||
|
||||
public void onSelfFaceChanged(String newFaceUrl) {}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.interfaces;
|
||||
|
||||
public interface ITopicBean extends Comparable<ITopicBean> {}
|
||||
@@ -0,0 +1,642 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.model;
|
||||
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.COMMUNITY_CUSTOM_INFO_COVER_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberOperationResult;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicInfoResult;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicOperationResult;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.util.ErrorMessageConverter;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityParser;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunityProvider {
|
||||
public static final String TAG = CommunityProvider.class.getSimpleName();
|
||||
|
||||
public void getJoinedCommunityList(IUIKitCallback<List<CommunityBean>> callback) {
|
||||
V2TIMManager.getGroupManager().getJoinedCommunityList(new V2TIMValueCallback<List<V2TIMGroupInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfo> v2TIMGroupInfos) {
|
||||
List<CommunityBean> communityBeans = CommunityParser.parseCommunityGroup(v2TIMGroupInfos);
|
||||
CommunityUtil.callbackOnSuccess(callback, communityBeans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getCommunityBean(String groupID, IUIKitCallback<CommunityBean> callback) {
|
||||
if (!CommunityUtil.isCommunityGroup(groupID)) {
|
||||
CommunityUtil.callbackOnError(callback, -1, "this groupType is not community");
|
||||
return;
|
||||
}
|
||||
List<String> groupIDs = new ArrayList<>();
|
||||
groupIDs.add(groupID);
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(groupIDs, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
V2TIMGroupInfoResult result = v2TIMGroupInfoResults.get(0);
|
||||
if (result.getResultCode() == 0) {
|
||||
V2TIMGroupInfo groupInfo = result.getGroupInfo();
|
||||
if (groupInfo.isSupportTopic()) {
|
||||
CommunityBean communityBean = CommunityParser.parseCommunityGroup(groupInfo);
|
||||
CommunityUtil.callbackOnSuccess(callback, communityBean);
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, -1, "not support topic");
|
||||
}
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, result.getResultCode(), result.getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createCommunityGroup(CommunityBean communityBean, IUIKitCallback<String> callback) {
|
||||
V2TIMGroupInfo v2TIMGroupInfo = new V2TIMGroupInfo();
|
||||
v2TIMGroupInfo.setGroupType(V2TIMManager.GROUP_TYPE_COMMUNITY);
|
||||
if (!TextUtils.isEmpty(communityBean.getCommunityName())) {
|
||||
v2TIMGroupInfo.setGroupName(communityBean.getCommunityName());
|
||||
}
|
||||
if (!TextUtils.isEmpty(communityBean.getGroupFaceUrl())) {
|
||||
v2TIMGroupInfo.setFaceUrl(communityBean.getGroupFaceUrl());
|
||||
}
|
||||
if (!TextUtils.isEmpty(communityBean.getIntroduction())) {
|
||||
v2TIMGroupInfo.setIntroduction(communityBean.getIntroduction());
|
||||
}
|
||||
|
||||
Map<String, byte[]> map = new HashMap<>();
|
||||
if (!TextUtils.isEmpty(communityBean.getCoverUrl())) {
|
||||
map.put(COMMUNITY_CUSTOM_INFO_COVER_KEY, communityBean.getCoverUrl().getBytes());
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
map.put(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY, gson.toJson(communityBean.getTopicCategories()).getBytes());
|
||||
v2TIMGroupInfo.setCustomInfo(map);
|
||||
|
||||
v2TIMGroupInfo.setSupportTopic(true);
|
||||
V2TIMManager.getGroupManager().createGroup(v2TIMGroupInfo, null, new V2TIMValueCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
CommunityUtil.callbackOnSuccess(callback, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int i, String s) {
|
||||
CommunityUtil.callbackOnError(callback, i, s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createTopic(String groupID, TopicBean topicBean, IUIKitCallback<String> callback) {
|
||||
V2TIMTopicInfo v2TIMTopicInfo = new V2TIMTopicInfo();
|
||||
v2TIMTopicInfo.setTopicName(topicBean.getTopicName());
|
||||
v2TIMTopicInfo.setTopicFaceUrl(topicBean.getFaceUrl());
|
||||
v2TIMTopicInfo.setAllMute(topicBean.isAllMute());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY, topicBean.getCategory());
|
||||
map.put(TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY, topicBean.getType());
|
||||
Gson gson = new Gson();
|
||||
v2TIMTopicInfo.setCustomString(gson.toJson(map));
|
||||
|
||||
V2TIMManager.getGroupManager().createTopicInCommunity(groupID, v2TIMTopicInfo, new V2TIMValueCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
CommunityUtil.callbackOnSuccess(callback, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyTopicCategory(TopicBean topicBean, String category, IUIKitCallback<Void> callback) {
|
||||
V2TIMTopicInfo v2TIMTopicInfo = topicBean.getV2TIMTopicInfo();
|
||||
Gson gson = new Gson();
|
||||
Map<String, Object> map = null;
|
||||
try {
|
||||
map = gson.fromJson(v2TIMTopicInfo.getCustomString(), Map.class);
|
||||
} catch (Exception e) {
|
||||
TUICommunityLog.e(TAG, e.getLocalizedMessage());
|
||||
}
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
}
|
||||
map.put(TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY, category);
|
||||
map.put(TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY, topicBean.getType());
|
||||
v2TIMTopicInfo.setCustomString(gson.toJson(map));
|
||||
V2TIMManager.getGroupManager().setTopicInfo(v2TIMTopicInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTopicList(String groupID, List<String> topicIDList, IUIKitCallback<List<TopicBean>> callback) {
|
||||
V2TIMManager.getGroupManager().getTopicInfoList(groupID, topicIDList, new V2TIMValueCallback<List<V2TIMTopicInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMTopicInfoResult> v2TIMTopicInfoResults) {
|
||||
List<V2TIMTopicInfo> timGroupInfoList = new ArrayList<>();
|
||||
for (V2TIMTopicInfoResult result : v2TIMTopicInfoResults) {
|
||||
timGroupInfoList.add(result.getTopicInfo());
|
||||
}
|
||||
List<TopicBean> topicBeanList = CommunityParser.parseTopicBeanList(timGroupInfoList);
|
||||
CommunityUtil.callbackOnSuccess(callback, topicBeanList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getSelfFaceUrl(IUIKitCallback<String> callback) {
|
||||
List<String> userIDList = new ArrayList<>();
|
||||
userIDList.add(TUILogin.getLoginUser());
|
||||
V2TIMManager.getInstance().getUsersInfo(userIDList, new V2TIMValueCallback<List<V2TIMUserFullInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMUserFullInfo> v2TIMUserFullInfos) {
|
||||
if (v2TIMUserFullInfos == null || v2TIMUserFullInfos.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
V2TIMUserFullInfo info = v2TIMUserFullInfos.get(0);
|
||||
CommunityUtil.callbackOnSuccess(callback, info.getFaceUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getGroupNameCard(String groupID, IUIKitCallback<String> callback) {
|
||||
List<String> userIDList = new ArrayList<>();
|
||||
userIDList.add(V2TIMManager.getInstance().getLoginUser());
|
||||
V2TIMManager.getGroupManager().getGroupMembersInfo(groupID, userIDList, new V2TIMValueCallback<List<V2TIMGroupMemberFullInfo>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupMemberFullInfo> v2TIMGroupMemberFullInfos) {
|
||||
CommunityUtil.callbackOnSuccess(callback, v2TIMGroupMemberFullInfos.get(0).getNameCard());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyTopicName(String topicID, String name, IUIKitCallback<Void> callback) {
|
||||
V2TIMTopicInfo v2TIMTopicInfo = new V2TIMTopicInfo();
|
||||
v2TIMTopicInfo.setTopicID(topicID);
|
||||
v2TIMTopicInfo.setTopicName(name);
|
||||
V2TIMManager.getGroupManager().setTopicInfo(v2TIMTopicInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteTopic(String groupID, String topicID, IUIKitCallback<Void> callback) {
|
||||
List<String> topicList = new ArrayList<>();
|
||||
topicList.add(topicID);
|
||||
V2TIMManager.getGroupManager().deleteTopicFromCommunity(groupID, topicList, new V2TIMValueCallback<List<V2TIMTopicOperationResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMTopicOperationResult> v2TIMTopicOperationResults) {
|
||||
V2TIMTopicOperationResult result = v2TIMTopicOperationResults.get(0);
|
||||
if (result.getErrorCode() == 0) {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
TUICore.notifyEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_DELETE_TOPIC, null);
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, result.getErrorCode(), result.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteTopicCategory(TopicBean topicBean, IUIKitCallback<Void> callback) {
|
||||
modifyTopicCategory(topicBean, "", callback);
|
||||
}
|
||||
|
||||
public void loadCommunityMembers(String groupID, int filter, long nextSeq, final IUIKitCallback<Pair<List<CommunityMemberBean>, Long>> callBack) {
|
||||
if (filter != V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_ALL && filter != V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_OWNER
|
||||
&& filter != V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_ADMIN && filter != V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_COMMON) {
|
||||
filter = V2TIMGroupMemberFullInfo.V2TIM_GROUP_MEMBER_FILTER_ALL;
|
||||
}
|
||||
V2TIMManager.getGroupManager().getGroupMemberList(groupID, filter, nextSeq, new V2TIMValueCallback<V2TIMGroupMemberInfoResult>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUICommunityLog.e(TAG, "loadCommunityMembers failed, code: " + code + "|desc: " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
CommunityUtil.callbackOnError(callBack, code, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMGroupMemberInfoResult v2TIMGroupMemberInfoResult) {
|
||||
List<CommunityMemberBean> members = CommunityParser.parseCommunityMemberBeanList(v2TIMGroupMemberInfoResult.getMemberInfoList());
|
||||
CommunityUtil.callbackOnSuccess(callBack, new Pair<>(members, v2TIMGroupMemberInfoResult.getNextSeq()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void joinCommunity(String groupID, String message, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getInstance().joinGroup(groupID, message, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
TUICore.notifyEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_ADD_COMMUNITY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createCategory(String groupID, String category, IUIKitCallback<Void> callback) {
|
||||
if (TextUtils.isEmpty(category)) {
|
||||
CommunityUtil.callbackOnError(callback, -1, "category is empty");
|
||||
return;
|
||||
}
|
||||
List<String> groupIDs = new ArrayList<>();
|
||||
groupIDs.add(groupID);
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(groupIDs, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
if (v2TIMGroupInfoResults.get(0).getResultCode() == 0) {
|
||||
V2TIMGroupInfo groupInfo = v2TIMGroupInfoResults.get(0).getGroupInfo();
|
||||
Map<String, byte[]> customMap = groupInfo.getCustomInfo();
|
||||
if (customMap == null) {
|
||||
customMap = new HashMap<>();
|
||||
}
|
||||
byte[] categoriesByteArray;
|
||||
Gson gson = new Gson();
|
||||
if (customMap.containsKey(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY)) {
|
||||
categoriesByteArray = customMap.get(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY);
|
||||
try {
|
||||
List<String> categoryList = gson.fromJson(new String(categoriesByteArray), List.class);
|
||||
if (categoryList == null) {
|
||||
categoryList = new ArrayList<>();
|
||||
}
|
||||
categoryList.add(category);
|
||||
categoriesByteArray = gson.toJson(categoryList).getBytes();
|
||||
} catch (JsonParseException parseException) {
|
||||
CommunityUtil.callbackOnError(callback, -1, parseException.getMessage());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
List<String> categoryList = new ArrayList<>();
|
||||
categoryList.add(category);
|
||||
categoriesByteArray = gson.toJson(categoryList).getBytes();
|
||||
}
|
||||
customMap.put(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY, categoriesByteArray);
|
||||
V2TIMGroupInfo modifyInfo = groupInfo;
|
||||
groupInfo.setCustomInfo(customMap);
|
||||
V2TIMManager.getGroupManager().setGroupInfo(modifyInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, v2TIMGroupInfoResults.get(0).getResultCode(), v2TIMGroupInfoResults.get(0).getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteCategory(String groupID, String category, IUIKitCallback<Void> callback) {
|
||||
if (TextUtils.isEmpty(category)) {
|
||||
CommunityUtil.callbackOnError(callback, -1, "category is empty");
|
||||
return;
|
||||
}
|
||||
List<String> groupIDs = new ArrayList<>();
|
||||
groupIDs.add(groupID);
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(groupIDs, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
if (v2TIMGroupInfoResults.get(0).getResultCode() == 0) {
|
||||
V2TIMGroupInfo groupInfo = v2TIMGroupInfoResults.get(0).getGroupInfo();
|
||||
Map<String, byte[]> customMap = groupInfo.getCustomInfo();
|
||||
if (customMap == null) {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
return;
|
||||
}
|
||||
byte[] categoriesByteArray;
|
||||
Gson gson = new Gson();
|
||||
if (customMap.containsKey(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY)) {
|
||||
categoriesByteArray = customMap.get(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY);
|
||||
try {
|
||||
List<String> categoryList = gson.fromJson(new String(categoriesByteArray), List.class);
|
||||
if (categoryList == null) {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
return;
|
||||
}
|
||||
categoryList.remove(category);
|
||||
categoriesByteArray = gson.toJson(categoryList).getBytes();
|
||||
customMap.put(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY, categoriesByteArray);
|
||||
V2TIMGroupInfo modifyInfo = groupInfo;
|
||||
groupInfo.setCustomInfo(customMap);
|
||||
V2TIMManager.getGroupManager().setGroupInfo(modifyInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
} catch (JsonParseException parseException) {
|
||||
CommunityUtil.callbackOnError(callback, -1, parseException.getMessage());
|
||||
}
|
||||
} else {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, v2TIMGroupInfoResults.get(0).getResultCode(), v2TIMGroupInfoResults.get(0).getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void quitCommunity(String groupID, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getInstance().quitGroup(groupID, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void disbandCommunity(String groupID, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getInstance().dismissGroup(groupID, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
TUICore.notifyEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_DISBAND_COMMUNITY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void removeGroupMembers(String groupId, List<String> members, final IUIKitCallback<List<String>> callBack) {
|
||||
if (members == null || members.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
V2TIMManager.getGroupManager().kickGroupMember(groupId, members, "", new V2TIMValueCallback<List<V2TIMGroupMemberOperationResult>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUICommunityLog.e(TAG, "removeGroupMembers failed, code: " + code + "|desc: " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
CommunityUtil.callbackOnError(callBack, code, ErrorMessageConverter.convertIMError(code, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupMemberOperationResult> v2TIMGroupMemberOperationResults) {
|
||||
List<String> dels = new ArrayList<>();
|
||||
for (int i = 0; i < v2TIMGroupMemberOperationResults.size(); i++) {
|
||||
V2TIMGroupMemberOperationResult res = v2TIMGroupMemberOperationResults.get(i);
|
||||
if (res.getResult() == V2TIMGroupMemberOperationResult.OPERATION_RESULT_SUCC) {
|
||||
dels.add(res.getMemberID());
|
||||
}
|
||||
}
|
||||
CommunityUtil.callbackOnSuccess(callBack, dels);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void inviteGroupMembers(String groupID, List<String> addMembers, final IUIKitCallback<List<String>> callBack) {
|
||||
if (addMembers == null || addMembers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
V2TIMManager.getGroupManager().inviteUserToGroup(groupID, addMembers, new V2TIMValueCallback<List<V2TIMGroupMemberOperationResult>>() {
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
TUICommunityLog.e(TAG, "addGroupMembers failed, code: " + code + "|desc: " + ErrorMessageConverter.convertIMError(code, desc));
|
||||
CommunityUtil.callbackOnError(callBack, code, ErrorMessageConverter.convertIMError(code, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupMemberOperationResult> v2TIMGroupMemberOperationResults) {
|
||||
final List<String> adds = new ArrayList<>();
|
||||
if (v2TIMGroupMemberOperationResults.size() > 0) {
|
||||
for (int i = 0; i < v2TIMGroupMemberOperationResults.size(); i++) {
|
||||
V2TIMGroupMemberOperationResult res = v2TIMGroupMemberOperationResults.get(i);
|
||||
if (res.getResult() == V2TIMGroupMemberOperationResult.OPERATION_RESULT_PENDING) {
|
||||
continue;
|
||||
}
|
||||
if (res.getResult() > 0) {
|
||||
adds.add(res.getMemberID());
|
||||
}
|
||||
}
|
||||
}
|
||||
CommunityUtil.callbackOnSuccess(callBack, adds);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyCommunityAvatar(String groupID, String groupFaceUrl, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupInfo v2TIMGroupInfo = new V2TIMGroupInfo();
|
||||
v2TIMGroupInfo.setGroupID(groupID);
|
||||
v2TIMGroupInfo.setFaceUrl(groupFaceUrl);
|
||||
V2TIMManager.getGroupManager().setGroupInfo(v2TIMGroupInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyCommunityCover(String groupID, String groupCoverUrl, IUIKitCallback<Void> callback) {
|
||||
List<String> groupIDs = new ArrayList<>();
|
||||
groupIDs.add(groupID);
|
||||
V2TIMManager.getGroupManager().getGroupsInfo(groupIDs, new V2TIMValueCallback<List<V2TIMGroupInfoResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<V2TIMGroupInfoResult> v2TIMGroupInfoResults) {
|
||||
V2TIMGroupInfoResult result = v2TIMGroupInfoResults.get(0);
|
||||
if (result.getResultCode() == 0) {
|
||||
V2TIMGroupInfo v2TIMGroupInfo = result.getGroupInfo();
|
||||
Map<String, byte[]> map = new HashMap<>();
|
||||
if (!TextUtils.isEmpty(groupCoverUrl)) {
|
||||
map.put(COMMUNITY_CUSTOM_INFO_COVER_KEY, groupCoverUrl.getBytes());
|
||||
}
|
||||
if (!map.isEmpty()) {
|
||||
v2TIMGroupInfo.setCustomInfo(map);
|
||||
}
|
||||
V2TIMManager.getGroupManager().setGroupInfo(v2TIMGroupInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
CommunityUtil.callbackOnError(callback, result.getResultCode(), result.getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void transferGroupOwner(String groupID, String newOwnerID, IUIKitCallback<Void> callback) {
|
||||
V2TIMManager.getGroupManager().transferGroupOwner(groupID, newOwnerID, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyCommunityName(String groupID, String name, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupInfo groupInfo = new V2TIMGroupInfo();
|
||||
groupInfo.setGroupID(groupID);
|
||||
groupInfo.setGroupName(name);
|
||||
V2TIMManager.getGroupManager().setGroupInfo(groupInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyCommunityIntroduction(String groupID, String introduction, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupInfo groupInfo = new V2TIMGroupInfo();
|
||||
groupInfo.setGroupID(groupID);
|
||||
groupInfo.setIntroduction(introduction);
|
||||
V2TIMManager.getGroupManager().setGroupInfo(groupInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modifyCommunitySelfNameCard(String groupID, String nameCard, IUIKitCallback<Void> callback) {
|
||||
V2TIMGroupMemberFullInfo v2TIMGroupMemberInfo = new V2TIMGroupMemberFullInfo();
|
||||
v2TIMGroupMemberInfo.setUserID(TUILogin.getLoginUser());
|
||||
v2TIMGroupMemberInfo.setNameCard(nameCard);
|
||||
V2TIMManager.getGroupManager().setGroupMemberInfo(groupID, v2TIMGroupMemberInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
CommunityUtil.callbackOnError(callback, code, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.presenter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.TUICommunityService;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.CommunityEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunitySelfView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunityExperiencePresenter {
|
||||
private static final String TAG = "CommunityExperiencePresenter";
|
||||
|
||||
private ICommunitySelfView iCommunitySelfView;
|
||||
private CommunityEventListener eventListener;
|
||||
private Map<String, Boolean> experienceMap;
|
||||
|
||||
public CommunityExperiencePresenter() {
|
||||
setExperienceChangedListener();
|
||||
setExperience();
|
||||
}
|
||||
|
||||
public void setCommunitySelfView(ICommunitySelfView iCommunitySelfView) {
|
||||
this.iCommunitySelfView = iCommunitySelfView;
|
||||
}
|
||||
|
||||
private void setExperienceChangedListener() {
|
||||
eventListener = new CommunityEventListener() {
|
||||
@Override
|
||||
public void onCommunityExperienceChanged(String experienceName) {
|
||||
if (experienceMap == null) {
|
||||
experienceMap = new HashMap<>();
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(experienceName))) {
|
||||
return;
|
||||
}
|
||||
experienceMap.put(experienceName, true);
|
||||
Gson gson = new Gson();
|
||||
String experienceString = gson.toJson(experienceMap);
|
||||
SPUtils.getInstance(CommunityConstants.COMMUNITY_SP_NAME).put(CommunityConstants.COMMUNITY_EXPERIENCE_SP_KEY, experienceString, true);
|
||||
if (iCommunitySelfView != null) {
|
||||
iCommunitySelfView.setExperience();
|
||||
}
|
||||
}
|
||||
};
|
||||
TUICommunityService.getInstance().addCommunityEventListener(eventListener);
|
||||
}
|
||||
|
||||
private void setExperience() {
|
||||
Gson gson = new Gson();
|
||||
String experience = SPUtils.getInstance(CommunityConstants.COMMUNITY_SP_NAME).getString(CommunityConstants.COMMUNITY_EXPERIENCE_SP_KEY);
|
||||
experienceMap = gson.fromJson(experience, TypeToken.getParameterized(Map.class, String.class, Boolean.class).getType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,614 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.TUICommunityService;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityChangeBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.CommunityEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.model.CommunityProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityDetailView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityFragment;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityGroupIconList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityMemberList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunitySettingsActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICreateTopicActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityPresenter {
|
||||
private static final String TAG = CommunityPresenter.class.getSimpleName();
|
||||
private static String switchCommunityID;
|
||||
|
||||
private final CommunityProvider provider;
|
||||
private ICommunityGroupIconList groupIconList;
|
||||
private ICommunityFragment communityFragment;
|
||||
private ICreateTopicActivity createTopicActivity;
|
||||
private ICommunitySettingsActivity settingsActivity;
|
||||
private ICommunityDetailView communityDetailView;
|
||||
private ICommunityMemberList communityMemberListView;
|
||||
|
||||
private final List<CommunityBean> joinedCommunityBeanList = new ArrayList<>();
|
||||
private final List<CommunityMemberBean> loadedCommunityMemberBeanList = new ArrayList<>();
|
||||
private final CommunityEventListener communityEventListener;
|
||||
|
||||
private CommunityBean currentCommunityBean;
|
||||
|
||||
public CommunityPresenter() {
|
||||
provider = new CommunityProvider();
|
||||
communityEventListener = new CommunityEventListener() {
|
||||
@Override
|
||||
public void onCommunityCreated(String groupID) {
|
||||
CommunityPresenter.this.addCommunityGroup(groupID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunityDeleted(String groupID) {
|
||||
CommunityPresenter.this.deleteCommunity(groupID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunityInfoChanged(String groupID, List<CommunityChangeBean> communityChangeBeans) {
|
||||
TUICommunityLog.i(TAG, "onCommunityInfoChanged groupID = " + groupID);
|
||||
CommunityPresenter.this.onCommunityBeanChanged(groupID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinedCommunity(String groupID) {
|
||||
CommunityPresenter.this.onJoinedCommunity(groupID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworkStateChanged(int state) {
|
||||
CommunityPresenter.this.onNetworkStateChanged(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelfFaceChanged(String newFaceUrl) {
|
||||
CommunityPresenter.this.onSelfFaceChanged(newFaceUrl);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setCommunityEventListener() {
|
||||
TUICommunityService.getInstance().addCommunityEventListener(communityEventListener);
|
||||
}
|
||||
|
||||
public void setCurrentCommunityBean(CommunityBean currentCommunityBean) {
|
||||
this.currentCommunityBean = currentCommunityBean;
|
||||
}
|
||||
|
||||
private void onNetworkStateChanged(int state) {
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onNetworkStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
private void onSelfFaceChanged(String newFaceUrl) {
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onSelfFaceChanged(newFaceUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void onJoinedCommunity(String groupID) {
|
||||
for (CommunityBean communityBean : joinedCommunityBeanList) {
|
||||
if (TextUtils.equals(communityBean.getGroupId(), groupID)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TextUtils.equals(switchCommunityID, groupID)) {
|
||||
addCommunityGroup(groupID, true);
|
||||
switchCommunityID = null;
|
||||
} else {
|
||||
addCommunityGroup(groupID);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommunityBeanChanged(String groupID) {
|
||||
provider.getCommunityBean(groupID, new IUIKitCallback<CommunityBean>() {
|
||||
@Override
|
||||
public void onSuccess(CommunityBean data) {
|
||||
TUICommunityLog.i(TAG, "onCommunityBeanChanged getCommunityBean success");
|
||||
onCommunityChanged(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e(TAG, "onCommunityBeanChanged getCommunityBean error, code=" + errCode + " errMsg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCommunityMemberListView(ICommunityMemberList communityMemberListView) {
|
||||
this.communityMemberListView = communityMemberListView;
|
||||
}
|
||||
|
||||
public void setCommunityDetailView(ICommunityDetailView communityDetailView) {
|
||||
this.communityDetailView = communityDetailView;
|
||||
}
|
||||
|
||||
public void setSettingsActivity(ICommunitySettingsActivity settingsActivity) {
|
||||
this.settingsActivity = settingsActivity;
|
||||
}
|
||||
|
||||
public void setCreateTopicActivity(ICreateTopicActivity createTopicActivity) {
|
||||
this.createTopicActivity = createTopicActivity;
|
||||
}
|
||||
|
||||
public void setGroupIconList(ICommunityGroupIconList groupIconList) {
|
||||
this.groupIconList = groupIconList;
|
||||
}
|
||||
|
||||
public void setCommunityFragment(ICommunityFragment communityFragment) {
|
||||
this.communityFragment = communityFragment;
|
||||
}
|
||||
|
||||
public void getSelfFaceUrl(IUIKitCallback<String> callback) {
|
||||
provider.getSelfFaceUrl(callback);
|
||||
}
|
||||
|
||||
public void getGroupNameCard(String groupID, IUIKitCallback<String> callback) {
|
||||
provider.getGroupNameCard(groupID, callback);
|
||||
}
|
||||
|
||||
public void loadJoinedCommunityList() {
|
||||
provider.getJoinedCommunityList(new IUIKitCallback<List<CommunityBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<CommunityBean> data) {
|
||||
onNewCommunity(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
super.onError(module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addCommunityGroup(String groupID, boolean isSwitch) {
|
||||
for (CommunityBean communityBean : joinedCommunityBeanList) {
|
||||
if (TextUtils.equals(communityBean.getGroupId(), groupID)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
provider.getCommunityBean(groupID, new IUIKitCallback<CommunityBean>() {
|
||||
@Override
|
||||
public void onSuccess(CommunityBean data) {
|
||||
onNewCommunity(data);
|
||||
if (isSwitch) {
|
||||
switchToCommunity(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
super.onError(module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addCommunityGroup(String groupID) {
|
||||
addCommunityGroup(groupID, false);
|
||||
}
|
||||
|
||||
private void switchToCommunity(CommunityBean communityBean) {
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onCommunitySelected(communityBean);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteCommunity(String groupID) {
|
||||
for (CommunityBean communityBean : joinedCommunityBeanList) {
|
||||
if (TextUtils.equals(communityBean.getGroupId(), groupID)) {
|
||||
onCommunityRemoved(communityBean);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onNewCommunity(CommunityBean communityBean) {
|
||||
List<CommunityBean> communityBeans = new ArrayList<>();
|
||||
communityBeans.add(communityBean);
|
||||
onNewCommunity(communityBeans);
|
||||
}
|
||||
|
||||
public void onNewCommunity(List<CommunityBean> communityBeanList) {
|
||||
TUICommunityLog.i(TAG, "onNewCommunity Communities:" + communityBeanList);
|
||||
|
||||
ArrayList<CommunityBean> beans = new ArrayList<>();
|
||||
for (CommunityBean communityBean : communityBeanList) {
|
||||
TUICommunityLog.i(TAG, "onNewCommunity Communities " + communityBean);
|
||||
beans.add(communityBean);
|
||||
}
|
||||
if (beans.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<CommunityBean> exists = new ArrayList<>();
|
||||
Iterator<CommunityBean> iterator = beans.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CommunityBean update = iterator.next();
|
||||
for (int i = 0; i < joinedCommunityBeanList.size(); i++) {
|
||||
CommunityBean cacheInfo = joinedCommunityBeanList.get(i);
|
||||
if (cacheInfo.getGroupId().equals(update.getGroupId())) {
|
||||
joinedCommunityBeanList.set(i, update);
|
||||
iterator.remove();
|
||||
exists.add(update);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(beans);
|
||||
joinedCommunityBeanList.addAll(beans);
|
||||
Collections.sort(joinedCommunityBeanList);
|
||||
onDataSourceChanged(joinedCommunityBeanList);
|
||||
for (CommunityBean bean : beans) {
|
||||
int index = joinedCommunityBeanList.indexOf(bean);
|
||||
if (index != -1) {
|
||||
onItemInserted(index);
|
||||
}
|
||||
}
|
||||
|
||||
for (CommunityBean bean : exists) {
|
||||
int index = joinedCommunityBeanList.indexOf(bean);
|
||||
if (index != -1) {
|
||||
onItemChanged(index);
|
||||
}
|
||||
judgeCurrentCommunityBeanChanged(bean);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommunityChanged(CommunityBean communityBean) {
|
||||
List<CommunityBean> communityBeans = new ArrayList<>();
|
||||
communityBeans.add(communityBean);
|
||||
onCommunityChanged(communityBeans);
|
||||
}
|
||||
|
||||
public void onCommunityChanged(List<CommunityBean> communityBeanList) {
|
||||
TUICommunityLog.i(TAG, "onCommunityChanged CommunityBeans:" + communityBeanList);
|
||||
|
||||
ArrayList<CommunityBean> addInfoList = new ArrayList<>();
|
||||
ArrayList<CommunityBean> changedInfoList = new ArrayList<>();
|
||||
|
||||
for (CommunityBean communityBean : communityBeanList) {
|
||||
boolean exists = false;
|
||||
for (CommunityBean loadedBean : joinedCommunityBeanList) {
|
||||
if (TextUtils.equals(communityBean.getGroupId(), loadedBean.getGroupId())) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
TUICommunityLog.i(TAG, "onCommunityChanged communityBean " + communityBean);
|
||||
changedInfoList.add(communityBean);
|
||||
} else {
|
||||
addInfoList.add(communityBean);
|
||||
}
|
||||
judgeCurrentCommunityBeanChanged(communityBean);
|
||||
}
|
||||
if (!addInfoList.isEmpty()) {
|
||||
onNewCommunity(addInfoList);
|
||||
}
|
||||
|
||||
if (changedInfoList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(changedInfoList);
|
||||
HashMap<CommunityBean, Integer> indexMap = new HashMap<>();
|
||||
for (int j = 0; j < changedInfoList.size(); j++) {
|
||||
CommunityBean update = changedInfoList.get(j);
|
||||
for (int i = 0; i < joinedCommunityBeanList.size(); i++) {
|
||||
CommunityBean cacheInfo = joinedCommunityBeanList.get(i);
|
||||
if (cacheInfo.getGroupId().equals(update.getGroupId())) {
|
||||
joinedCommunityBeanList.set(i, update);
|
||||
indexMap.put(update, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(joinedCommunityBeanList);
|
||||
onDataSourceChanged(joinedCommunityBeanList);
|
||||
int minRefreshIndex = Integer.MAX_VALUE;
|
||||
int maxRefreshIndex = Integer.MIN_VALUE;
|
||||
for (CommunityBean communityBean : changedInfoList) {
|
||||
Integer oldIndexObj = indexMap.get(communityBean);
|
||||
if (oldIndexObj == null) {
|
||||
continue;
|
||||
}
|
||||
int oldIndex = oldIndexObj;
|
||||
int newIndex = joinedCommunityBeanList.indexOf(communityBean);
|
||||
if (newIndex != -1) {
|
||||
minRefreshIndex = Math.min(minRefreshIndex, Math.min(oldIndex, newIndex));
|
||||
maxRefreshIndex = Math.max(maxRefreshIndex, Math.max(oldIndex, newIndex));
|
||||
}
|
||||
}
|
||||
int count;
|
||||
if (minRefreshIndex == maxRefreshIndex) {
|
||||
count = 1;
|
||||
} else {
|
||||
count = maxRefreshIndex - minRefreshIndex + 1;
|
||||
}
|
||||
if (count > 0 && maxRefreshIndex >= minRefreshIndex) {
|
||||
onItemRangeChanged(minRefreshIndex, count);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCommunityRemoved(CommunityBean communityBean) {
|
||||
int index = joinedCommunityBeanList.indexOf(communityBean);
|
||||
boolean isRemove = joinedCommunityBeanList.remove(communityBean);
|
||||
if (isRemove && index != -1) {
|
||||
onItemRemoved(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void judgeCurrentCommunityBeanChanged(CommunityBean communityBean) {
|
||||
if (currentCommunityBean != null && TextUtils.equals(currentCommunityBean.getGroupId(), communityBean.getGroupId())) {
|
||||
currentCommunityBean = communityBean;
|
||||
if (createTopicActivity != null) {
|
||||
createTopicActivity.onCommunityChanged(currentCommunityBean);
|
||||
}
|
||||
if (settingsActivity != null) {
|
||||
settingsActivity.onCommunityChanged(currentCommunityBean);
|
||||
}
|
||||
if (communityDetailView != null) {
|
||||
communityDetailView.onCommunityChanged(currentCommunityBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onDataSourceChanged(List<CommunityBean> communityBeanList) {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onJoinedCommunityChanged(joinedCommunityBeanList);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onJoinedCommunityChanged(joinedCommunityBeanList);
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemRangeChanged(int index, int count) {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onItemRangeChanged(index, count);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onItemRangeChanged(index, count);
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemInserted(int index) {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onItemInserted(index);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onItemInserted(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemChanged(int index) {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onItemChanged(index);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onItemChanged(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemRemoved(int index) {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onItemRemoved(index);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onItemRemoved(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void createCommunityGroup(String communityName, String introduction, String coverUrl, String faceUrl) {
|
||||
CommunityBean communityBean = new CommunityBean();
|
||||
communityBean.setCommunityName(communityName);
|
||||
communityBean.setIntroduction(introduction);
|
||||
communityBean.setCoverUrl(coverUrl);
|
||||
communityBean.setGroupFaceUrl(faceUrl);
|
||||
List<String> topicCategories = new ArrayList<>();
|
||||
topicCategories.add(TUICommunityService.getAppContext().getString(R.string.community_default_category_announcement));
|
||||
topicCategories.add(TUICommunityService.getAppContext().getString(R.string.community_default_category_communication));
|
||||
communityBean.setTopicCategories(topicCategories);
|
||||
provider.createCommunityGroup(communityBean, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
switchCommunityID = data;
|
||||
ToastUtil.toastLongMessage(TUICommunityService.getAppContext().getString(R.string.community_create_community_success));
|
||||
TUICore.notifyEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_COMMUNITY, null);
|
||||
createDefaultTopic(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(TUICommunityService.getAppContext().getString(R.string.community_create_community_failed));
|
||||
TUICommunityLog.e(TAG, "create community error, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createDefaultTopic(String groupID) {
|
||||
TopicBean topicBean = new TopicBean();
|
||||
String topicNameNotice = TUICommunityService.getAppContext().getString(R.string.community_topic_important_notice);
|
||||
topicBean.setTopicName(topicNameNotice);
|
||||
String topicCategoryAnnouncement = TUICommunityService.getAppContext().getString(R.string.community_default_category_announcement);
|
||||
topicBean.setCategory(topicCategoryAnnouncement);
|
||||
provider.createTopic(groupID, topicBean, null);
|
||||
String topicNameNewbie = TUICommunityService.getAppContext().getString(R.string.community_topic_newbie_report);
|
||||
topicBean.setTopicName(topicNameNewbie);
|
||||
String topicCategoryCommunication = TUICommunityService.getAppContext().getString(R.string.community_default_category_communication);
|
||||
topicBean.setCategory(topicCategoryCommunication);
|
||||
provider.createTopic(groupID, topicBean, null);
|
||||
String topicNameChat = TUICommunityService.getAppContext().getString(R.string.community_topic_chat_hall);
|
||||
topicBean.setTopicName(topicNameChat);
|
||||
topicBean.setCategory(topicCategoryCommunication);
|
||||
provider.createTopic(groupID, topicBean, null);
|
||||
}
|
||||
|
||||
private void onCommunityListChanged() {
|
||||
if (groupIconList != null) {
|
||||
groupIconList.onJoinedCommunityChanged(joinedCommunityBeanList);
|
||||
}
|
||||
if (communityFragment != null) {
|
||||
communityFragment.onJoinedCommunityChanged(joinedCommunityBeanList);
|
||||
}
|
||||
}
|
||||
|
||||
public void searchCommunity(String groupID, IUIKitCallback<CommunityBean> callback) {
|
||||
provider.getCommunityBean(groupID, callback);
|
||||
}
|
||||
|
||||
public void joinCommunity(String groupID, IUIKitCallback<Void> callback) {
|
||||
provider.joinCommunity(groupID, null, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
switchCommunityID = groupID;
|
||||
CommunityUtil.callbackOnSuccess(callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
CommunityUtil.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createCategory(String groupID, String category) {
|
||||
provider.createCategory(groupID, category, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
ToastUtil.toastShortMessage(TUICommunityService.getAppContext().getString(R.string.community_create_topic_category_success));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(
|
||||
TUICommunityService.getAppContext().getString(R.string.community_create_topic_category_failed) + " code=" + errCode + " errMsg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteCategory(String groupID, String category) {
|
||||
provider.deleteCategory(groupID, category, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
TUICommunityLog.i(TAG, "delete category success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.i(TAG, "delete category failed, code=" + errCode + " errMsg=" + errMsg);
|
||||
ToastUtil.toastShortMessage("delete category failed, code=" + errCode + " errMsg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void quitCommunity(String groupID, IUIKitCallback<Void> callback) {
|
||||
provider.quitCommunity(groupID, callback);
|
||||
}
|
||||
|
||||
public void disbandCommunity(String groupID, IUIKitCallback<Void> callback) {
|
||||
provider.disbandCommunity(groupID, callback);
|
||||
}
|
||||
|
||||
public void removeGroupMembers(String groupID, List<String> memberIDList, IUIKitCallback<List<String>> callBack) {
|
||||
provider.removeGroupMembers(groupID, memberIDList, new IUIKitCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> data) {
|
||||
CommunityUtil.callbackOnSuccess(callBack, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
CommunityUtil.callbackOnError(callBack, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadCommunityMembers(String groupID, long nextSeq) {
|
||||
provider.loadCommunityMembers(groupID, 0, nextSeq, new IUIKitCallback<Pair<List<CommunityMemberBean>, Long>>() {
|
||||
@Override
|
||||
public void onSuccess(Pair<List<CommunityMemberBean>, Long> data) {
|
||||
loadedCommunityMemberBeanList.addAll(data.first);
|
||||
LinkedHashMap<String, CommunityMemberBean> distinctMap = new LinkedHashMap<>();
|
||||
for (CommunityMemberBean communityMemberBean : loadedCommunityMemberBeanList) {
|
||||
if (!TextUtils.isEmpty(communityMemberBean.getAccount())) {
|
||||
distinctMap.put(communityMemberBean.getAccount(), communityMemberBean);
|
||||
}
|
||||
}
|
||||
loadedCommunityMemberBeanList.clear();
|
||||
loadedCommunityMemberBeanList.addAll(distinctMap.values());
|
||||
long seq = data.second;
|
||||
onCommunityMemberListChanged(loadedCommunityMemberBeanList, seq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
super.onError(module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void inviteGroupMembers(String groupID, List<String> addMembers) {
|
||||
provider.inviteGroupMembers(groupID, addMembers, new IUIKitCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> data) {
|
||||
TUICommunityLog.i(TAG, " inviteGroupMembers success");
|
||||
loadCommunityMembers(groupID, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e(TAG, "inviteGroupMembers failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onCommunityMemberListChanged(List<CommunityMemberBean> communityMemberBeanList, long seq) {
|
||||
if (communityMemberListView != null) {
|
||||
communityMemberListView.onMemberListChanged(communityMemberBeanList, seq);
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyCommunityCover(String groupID, String groupCoverUrl, IUIKitCallback<Void> callback) {
|
||||
provider.modifyCommunityCover(groupID, groupCoverUrl, callback);
|
||||
}
|
||||
|
||||
public void modifyCommunityAvatar(String groupID, String groupFaceUrl, IUIKitCallback<Void> callback) {
|
||||
provider.modifyCommunityAvatar(groupID, groupFaceUrl, callback);
|
||||
}
|
||||
|
||||
public void transferCommunityOwner(String groupID, String newOwnerID, IUIKitCallback<Void> callback) {
|
||||
provider.transferGroupOwner(groupID, newOwnerID, callback);
|
||||
}
|
||||
|
||||
public void modifyCommunityName(String groupID, String name, IUIKitCallback<Void> callback) {
|
||||
provider.modifyCommunityName(groupID, name, callback);
|
||||
}
|
||||
|
||||
public void modifyCommunityIntroduction(String groupID, String introduction, IUIKitCallback<Void> callback) {
|
||||
provider.modifyCommunityIntroduction(groupID, introduction, callback);
|
||||
}
|
||||
|
||||
public void modifyCommunitySelfNameCard(String groupID, String nameCard, IUIKitCallback<Void> callback) {
|
||||
provider.modifyCommunitySelfNameCard(groupID, nameCard, callback);
|
||||
}
|
||||
|
||||
public void loadCommunityBean(String groupID, IUIKitCallback<CommunityBean> callback) {
|
||||
provider.getCommunityBean(groupID, callback);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.TUICommunityService;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicFoldBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TreeNode;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.CommunityEventListener;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.model.CommunityProvider;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityDetailView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityTopicList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ITopicInfoActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TopicPresenter {
|
||||
private static final String TAG = "TopicPresenter";
|
||||
|
||||
private final CommunityProvider provider;
|
||||
private final List<TopicBean> loadedTopicBeanList = new ArrayList<>();
|
||||
|
||||
private ICommunityTopicList communityTopicList;
|
||||
private ICommunityDetailView communityDetailFragment;
|
||||
private ITopicInfoActivity topicInfoActivity;
|
||||
private CommunityBean communityBean;
|
||||
|
||||
private final TreeNode<ITopicBean> topicBeanTreeNode = new TreeNode<>();
|
||||
private Map<String, Map<String, Boolean>> collapseMap;
|
||||
private Map<String, Boolean> currentCollapseMap;
|
||||
private final CommunityEventListener communityEventListener;
|
||||
|
||||
public TopicPresenter() {
|
||||
provider = new CommunityProvider();
|
||||
communityEventListener = new CommunityEventListener() {
|
||||
@Override
|
||||
public void onTopicCreated(String groupID, String topicID) {
|
||||
if (communityBean != null && TextUtils.equals(groupID, communityBean.getGroupId())) {
|
||||
TopicPresenter.this.onTopicCreated(topicID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicDeleted(String groupID, List<String> topicIDs) {
|
||||
if (communityBean != null && TextUtils.equals(groupID, communityBean.getGroupId())) {
|
||||
TopicPresenter.this.onTopicDeleted(topicIDs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicChanged(String groupID, TopicBean topicBean) {
|
||||
if (communityBean != null && TextUtils.equals(groupID, communityBean.getGroupId())) {
|
||||
TopicPresenter.this.onTopicChanged(topicBean);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setTopicInfoActivity(ITopicInfoActivity topicInfoActivity) {
|
||||
this.topicInfoActivity = topicInfoActivity;
|
||||
}
|
||||
|
||||
public void deleteCategory(TreeNode<ITopicBean> node) {
|
||||
if (node.hasChild()) {
|
||||
for (TreeNode<ITopicBean> topicNode : node.getChildList()) {
|
||||
if (topicNode.getData() instanceof TopicBean) {
|
||||
deleteCategory((TopicBean) topicNode.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
topicBeanTreeNode.delete(node);
|
||||
}
|
||||
|
||||
private void deleteCategory(TopicBean topicBean) {
|
||||
provider.deleteTopicCategory(topicBean, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
TUICommunityLog.e(TAG, "deleteCategory success");
|
||||
// do nothing, you can receive onTopicInfoChanged callback in TUICommunityService.java
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e(TAG, "deleteCategory failed, code=" + errCode + " ,msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCommunityEventListener() {
|
||||
TUICommunityService.getInstance().addCommunityEventListener(communityEventListener);
|
||||
}
|
||||
|
||||
private void onTopicCreated(String topicID) {
|
||||
getTopicBean(topicID, new IUIKitCallback<TopicBean>() {
|
||||
@Override
|
||||
public void onSuccess(TopicBean data) {
|
||||
addTopic(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e(TAG, "onTopicCreated getTopicBean error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onTopicDeleted(List<String> topicIDs) {
|
||||
boolean changed = false;
|
||||
for (String topicID : topicIDs) {
|
||||
Iterator<TopicBean> iterator = loadedTopicBeanList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TopicBean topicBean = iterator.next();
|
||||
if (TextUtils.equals(topicBean.getID(), topicID)) {
|
||||
iterator.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
processLoadedData();
|
||||
}
|
||||
}
|
||||
|
||||
private void onTopicChanged(TopicBean topicBean) {
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < loadedTopicBeanList.size(); i++) {
|
||||
if (TextUtils.equals(topicBean.getID(), (loadedTopicBeanList.get(i)).getID())) {
|
||||
loadedTopicBeanList.set(i, topicBean);
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
processLoadedData();
|
||||
}
|
||||
notifyTopicChanged(topicBean);
|
||||
}
|
||||
|
||||
private void notifyTopicChanged(TopicBean topicBean) {
|
||||
if (topicInfoActivity != null) {
|
||||
topicInfoActivity.onTopicChanged(topicBean);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTopicCategory() {
|
||||
List<String> categories = communityBean.getTopicCategories();
|
||||
if (categories == null || categories.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (String category : categories) {
|
||||
TopicFoldBean topicFoldBean = new TopicFoldBean();
|
||||
topicFoldBean.setFoldName(category);
|
||||
TreeNode<ITopicBean> treeNode = new TreeNode<>();
|
||||
Boolean isCollapse = currentCollapseMap.get(category);
|
||||
if (isCollapse == null) {
|
||||
treeNode.setCollapse(false);
|
||||
} else {
|
||||
treeNode.setCollapse(isCollapse);
|
||||
}
|
||||
treeNode.setData(topicFoldBean);
|
||||
treeNode.setNodeName(topicFoldBean.getFoldName());
|
||||
topicBeanTreeNode.getRoot().addNode(treeNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTopic() {
|
||||
List<TreeNode<ITopicBean>> dataList = topicBeanTreeNode.toList();
|
||||
for (TopicBean topicBean : loadedTopicBeanList) {
|
||||
addTopicToTree(dataList, topicBean);
|
||||
}
|
||||
}
|
||||
|
||||
private void addTopic(TopicBean topicBean) {
|
||||
for (TopicBean loadedTopicBean : loadedTopicBeanList) {
|
||||
if (TextUtils.equals(topicBean.getID(), loadedTopicBean.getID())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
loadedTopicBeanList.add(topicBean);
|
||||
List<TreeNode<ITopicBean>> dataList = topicBeanTreeNode.toList();
|
||||
addTopicToTree(dataList, topicBean);
|
||||
}
|
||||
|
||||
private void addTopicToTree(List<TreeNode<ITopicBean>> dataList, TopicBean topicBean) {
|
||||
for (TreeNode<ITopicBean> loadedTopicBean : dataList) {
|
||||
if (loadedTopicBean.getData() instanceof TopicBean) {
|
||||
if (TextUtils.equals(topicBean.getID(), ((TopicBean) loadedTopicBean.getData()).getID())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
String category = topicBean.getCategory();
|
||||
boolean isExistsCategory = false;
|
||||
for (TreeNode<ITopicBean> loadedTopicBean : dataList) {
|
||||
if (loadedTopicBean.getData() instanceof TopicFoldBean) {
|
||||
if (TextUtils.equals(((TopicFoldBean) loadedTopicBean.getData()).getFoldName(), category)) {
|
||||
TreeNode<ITopicBean> treeNode = new TreeNode<>();
|
||||
treeNode.setData(topicBean);
|
||||
treeNode.setNodeName(topicBean.getID());
|
||||
loadedTopicBean.addNode(treeNode);
|
||||
isExistsCategory = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isExistsCategory) {
|
||||
TreeNode<ITopicBean> topicNode = new TreeNode<>();
|
||||
topicNode.setData(topicBean);
|
||||
topicNode.setNodeName(topicBean.getID());
|
||||
topicBeanTreeNode.addNode(topicNode);
|
||||
}
|
||||
onTopicListChanged();
|
||||
}
|
||||
|
||||
public void deleteTopic(String topicID, IUIKitCallback<Void> callback) {
|
||||
String groupID = CommunityUtil.getGroupIDFromTopicID(topicID);
|
||||
provider.deleteTopic(groupID, topicID, callback);
|
||||
}
|
||||
|
||||
private void deleteTopic(TopicBean topicBean) {
|
||||
List<TopicBean> topicBeanList = new ArrayList<>();
|
||||
topicBeanList.add(topicBean);
|
||||
deleteTopicList(topicBeanList);
|
||||
}
|
||||
|
||||
private void deleteTopicList(List<TopicBean> topicBeanList) {
|
||||
List<String> topicIDs = new ArrayList<>();
|
||||
for (TopicBean topicBean : topicBeanList) {
|
||||
topicIDs.add(topicBean.getID());
|
||||
}
|
||||
onTopicDeleted(topicIDs);
|
||||
}
|
||||
|
||||
public void setCommunityDetailFragment(ICommunityDetailView communityDetailFragment) {
|
||||
this.communityDetailFragment = communityDetailFragment;
|
||||
}
|
||||
|
||||
public void setCommunityTopicList(ICommunityTopicList communityTopicList) {
|
||||
this.communityTopicList = communityTopicList;
|
||||
}
|
||||
|
||||
public void setCommunityBean(CommunityBean communityBean) {
|
||||
TUICommunityLog.i(TAG, "setCommunityBean " + communityBean);
|
||||
this.communityBean = communityBean;
|
||||
topicBeanTreeNode.clear();
|
||||
Gson gson = new Gson();
|
||||
String collapseStr = SPUtils.getInstance(CommunityConstants.COMMUNITY_SP_NAME).getString(CommunityConstants.COMMUNITY_COLLAPSE_SP_KEY);
|
||||
collapseMap = gson.fromJson(collapseStr,
|
||||
TypeToken.getParameterized(Map.class, String.class, TypeToken.getParameterized(Map.class, String.class, Boolean.class).getType()).getType());
|
||||
if (collapseMap != null) {
|
||||
currentCollapseMap = collapseMap.get(communityBean.getGroupId());
|
||||
} else {
|
||||
collapseMap = new HashMap<>();
|
||||
}
|
||||
if (currentCollapseMap == null) {
|
||||
currentCollapseMap = new HashMap<>();
|
||||
collapseMap.put(communityBean.getGroupId(), currentCollapseMap);
|
||||
}
|
||||
if (communityTopicList != null) {
|
||||
processLoadedData();
|
||||
}
|
||||
}
|
||||
|
||||
public void getTopicList(String groupID) {
|
||||
topicBeanTreeNode.clear();
|
||||
loadedTopicBeanList.clear();
|
||||
onTopicListChanged();
|
||||
TUICommunityLog.i(TAG, "getTopicList groupID = " + groupID);
|
||||
provider.getTopicList(groupID, null, new IUIKitCallback<List<TopicBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<TopicBean> data) {
|
||||
TUICommunityLog.i(TAG, "getTopicList success size=" + data.size());
|
||||
loadedTopicBeanList.addAll(data);
|
||||
processLoadedData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e(TAG, "getTopicList failed, code=" + errCode + ", msg=" + errMsg);
|
||||
onTopicListChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processLoadedData() {
|
||||
topicBeanTreeNode.clear();
|
||||
setTopicCategory();
|
||||
setTopic();
|
||||
onTopicListChanged();
|
||||
}
|
||||
|
||||
public void changeTreeNodeCollapseStatus(TreeNode<ITopicBean> node) {
|
||||
node.setCollapse(!node.isCollapse());
|
||||
currentCollapseMap.put(node.getNodeName(), node.isCollapse());
|
||||
Gson gson = new Gson();
|
||||
SPUtils.getInstance(CommunityConstants.COMMUNITY_SP_NAME).put(CommunityConstants.COMMUNITY_COLLAPSE_SP_KEY, gson.toJson(collapseMap));
|
||||
onTopicListChanged();
|
||||
}
|
||||
|
||||
public void createTopic(String groupID, String topicName, String topicCategory, int type, IUIKitCallback<String> callback) {
|
||||
TopicBean topicBean = new TopicBean();
|
||||
topicBean.setTopicName(topicName);
|
||||
topicBean.setCategory(topicCategory);
|
||||
topicBean.setType(type);
|
||||
provider.createTopic(groupID, topicBean, callback);
|
||||
}
|
||||
|
||||
private void onTopicListChanged() {
|
||||
List<TreeNode<ITopicBean>> dataList = topicBeanTreeNode.toList();
|
||||
if (communityTopicList != null) {
|
||||
communityTopicList.onTopicListChanged(dataList, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void getTopicBeanList(String groupID, List<String> topicIDs, IUIKitCallback<List<TopicBean>> callback) {
|
||||
provider.getTopicList(groupID, topicIDs, new IUIKitCallback<List<TopicBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<TopicBean> data) {
|
||||
CommunityUtil.callbackOnSuccess(callback, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
CommunityUtil.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTopicBean(String topicID, IUIKitCallback<TopicBean> callback) {
|
||||
String groupID = CommunityUtil.getGroupIDFromTopicID(topicID);
|
||||
List<String> topicIDs = new ArrayList<>();
|
||||
topicIDs.add(topicID);
|
||||
provider.getTopicList(groupID, topicIDs, new IUIKitCallback<List<TopicBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<TopicBean> data) {
|
||||
CommunityUtil.callbackOnSuccess(callback, data.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
CommunityUtil.callbackOnError(callback, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getCommunityBean(String topicID, IUIKitCallback<CommunityBean> callback) {
|
||||
String groupID = CommunityUtil.getGroupIDFromTopicID(topicID);
|
||||
provider.getCommunityBean(groupID, callback);
|
||||
}
|
||||
|
||||
public void modifyTopicName(String topicID, String name, IUIKitCallback<Void> callback) {
|
||||
provider.modifyTopicName(topicID, name, callback);
|
||||
}
|
||||
|
||||
public void modifyTopicCategory(TopicBean topicBean, String category, IUIKitCallback<Void> callback) {
|
||||
provider.modifyTopicCategory(topicBean, category, callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
|
||||
public interface ICommunityDetailView {
|
||||
void onCommunityChanged(CommunityBean communityBean);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICommunityFragment {
|
||||
void onJoinedCommunityChanged(List<CommunityBean> communityBeanList);
|
||||
|
||||
void onItemRangeChanged(int index, int count);
|
||||
|
||||
void onItemInserted(int index);
|
||||
|
||||
void onItemChanged(int index);
|
||||
|
||||
void onItemRemoved(int index);
|
||||
|
||||
void onNetworkStateChanged(int state);
|
||||
|
||||
void onCommunitySelected(CommunityBean communityBean);
|
||||
|
||||
void onSelfFaceChanged(String newFaceUrl);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICommunityGroupIconList {
|
||||
void onJoinedCommunityChanged(List<CommunityBean> communityBeanList);
|
||||
|
||||
void onItemRangeChanged(int index, int count);
|
||||
|
||||
void onItemInserted(int index);
|
||||
|
||||
void onItemChanged(int index);
|
||||
|
||||
void onItemRemoved(int index);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
public interface ICommunityMemberActivity {
|
||||
void onAddCommunityMember();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICommunityMemberList {
|
||||
void onMemberListChanged(List<CommunityMemberBean> memberBeanList, long seq);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
public interface ICommunitySelfView {
|
||||
void setExperience();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
|
||||
public interface ICommunitySettingsActivity {
|
||||
void onCommunityChanged(CommunityBean communityBean);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TreeNode;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICommunityTopicList {
|
||||
void onTopicListChanged(List<TreeNode<ITopicBean>> newData, List<TreeNode<ITopicBean>> oldData);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
|
||||
public interface ICreateTopicActivity {
|
||||
void onCommunityChanged(CommunityBean communityBean);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
|
||||
public interface ITopicInfoActivity {
|
||||
void onTopicChanged(TopicBean topicBean);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityMemberActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.CommunityMemberList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityMemberActivity extends BaseLightActivity implements ICommunityMemberActivity {
|
||||
private static final int REQUEST_CODE_INVITE_MEMBER = 1;
|
||||
|
||||
private CommunityMemberList memberListLayout;
|
||||
private CommunityBean communityBean;
|
||||
private CommunityPresenter presenter;
|
||||
|
||||
private boolean isSelectMode = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_members_list);
|
||||
memberListLayout = findViewById(R.id.member_list_layout);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
presenter = new CommunityPresenter();
|
||||
memberListLayout.setPresenter(presenter);
|
||||
memberListLayout.setCommunityMemberListener(this);
|
||||
Intent intent = getIntent();
|
||||
communityBean = (CommunityBean) intent.getSerializableExtra(CommunityConstants.COMMUNITY_BEAN);
|
||||
memberListLayout.setCommunityBean(communityBean);
|
||||
presenter.setCommunityMemberListView(memberListLayout);
|
||||
memberListLayout.loadMemberList();
|
||||
|
||||
isSelectMode = intent.getBooleanExtra(CommunityConstants.IS_SELECT_MODE, false);
|
||||
|
||||
String title = intent.getStringExtra(CommunityConstants.TITLE);
|
||||
|
||||
// int filter = intent.getIntExtra(CommunityConstants.FILTER, CommunityBean.GROUP_MEMBER_FILTER_ALL);
|
||||
memberListLayout.setSelectMode(isSelectMode);
|
||||
memberListLayout.setTitle(title);
|
||||
|
||||
memberListLayout.getTitleBar().setOnLeftClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
int limit = getIntent().getIntExtra(CommunityConstants.LIMIT, Integer.MAX_VALUE);
|
||||
memberListLayout.setGroupMemberListener(new CommunityMemberList.MemberListListener() {
|
||||
@Override
|
||||
public void setSelectedMember(ArrayList<String> members) {
|
||||
if (members == null || members.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (members.size() > limit) {
|
||||
String overLimitTip = getString(R.string.community_over_limit_tip, limit);
|
||||
ToastUtil.toastShortMessage(overLimitTip);
|
||||
return;
|
||||
}
|
||||
Intent result = new Intent();
|
||||
result.putStringArrayListExtra(CommunityConstants.LIST, members);
|
||||
setResult(RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void inviteGroupMembers(List<String> friends) {
|
||||
if (friends != null && friends.size() > 0) {
|
||||
if (presenter != null) {
|
||||
presenter.inviteGroupMembers(communityBean.getGroupId(), friends);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCommunityMember() {
|
||||
Bundle param = new Bundle();
|
||||
param.putString(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.GROUP_ID, communityBean.getGroupId());
|
||||
param.putBoolean(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.SELECT_FRIENDS, true);
|
||||
if (memberListLayout.getCommunityMemberBeans() != null) {
|
||||
ArrayList<String> selectedList = new ArrayList<>();
|
||||
for (CommunityMemberBean memberBean : memberListLayout.getCommunityMemberBeans()) {
|
||||
selectedList.add(memberBean.getAccount());
|
||||
}
|
||||
param.putStringArrayList(TUIConstants.TUIContact.StartActivity.GroupMemberSelect.SELECTED_LIST, selectedList);
|
||||
}
|
||||
TUICore.startActivity(this, "StartGroupMemberSelectActivity", param, REQUEST_CODE_INVITE_MEMBER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (data != null) {
|
||||
List<String> friends = (List<String>) data.getSerializableExtra(CommunityConstants.LIST);
|
||||
if (requestCode == REQUEST_CODE_INVITE_MEMBER) {
|
||||
inviteGroupMembers(friends);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.PopupInputCard;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.RoundCornerImageView;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.ImageSelectMinimalistActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SettingsLinearView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunitySettingsActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunitySettingsActivity extends BaseLightActivity implements ICommunitySettingsActivity {
|
||||
private static final int REQUEST_FOR_CHANGE_OWNER = 1;
|
||||
private static final int REQUEST_FOR_CHANGE_AVATAR = 2;
|
||||
private static final int REQUEST_FOR_CHANGE_COVER = 3;
|
||||
|
||||
private SettingsLinearView communityNameLv;
|
||||
private SettingsLinearView communityAvatarLv;
|
||||
private SettingsLinearView communityCoverLv;
|
||||
private SettingsLinearView communityIntroductionLv;
|
||||
private SettingsLinearView communityIDLv;
|
||||
private View communitySettingsLabel;
|
||||
private SettingsLinearView createTopicCategoryLv;
|
||||
private SettingsLinearView createTopicLv;
|
||||
private SettingsLinearView groupNickNameLv;
|
||||
private View disbandButton;
|
||||
private View transferButton;
|
||||
private TUIKitDialog disbandDialog;
|
||||
private CommunityBean communityBean;
|
||||
private String communityID;
|
||||
private CommunityPresenter presenter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_settings_activity_layout);
|
||||
Intent intent = getIntent();
|
||||
communityID = intent.getStringExtra(CommunityConstants.COMMUNITY_ID);
|
||||
presenter = new CommunityPresenter();
|
||||
presenter.setCommunityEventListener();
|
||||
presenter.setSettingsActivity(this);
|
||||
|
||||
communityNameLv = findViewById(R.id.community_name_lv);
|
||||
communityAvatarLv = findViewById(R.id.community_face_lv);
|
||||
communityCoverLv = findViewById(R.id.community_cover_lv);
|
||||
communityIntroductionLv = findViewById(R.id.community_introduction_lv);
|
||||
communityIDLv = findViewById(R.id.community_id_lv);
|
||||
createTopicCategoryLv = findViewById(R.id.create_topic_category_lv);
|
||||
communitySettingsLabel = findViewById(R.id.community_settings_label);
|
||||
createTopicLv = findViewById(R.id.create_topic_lv);
|
||||
groupNickNameLv = findViewById(R.id.self_nick_name);
|
||||
transferButton = findViewById(R.id.transfer_group_button);
|
||||
disbandButton = findViewById(R.id.disband_group_button);
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
presenter.loadCommunityBean(communityID, new IUIKitCallback<CommunityBean>() {
|
||||
@Override
|
||||
public void onSuccess(CommunityBean data) {
|
||||
communityBean = data;
|
||||
presenter.setCurrentCommunityBean(data);
|
||||
setupView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
super.onError(module, errCode, errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
if (communityBean == null) {
|
||||
return;
|
||||
}
|
||||
setNameView();
|
||||
setAvatarView();
|
||||
setCoverView();
|
||||
setIntroductionView();
|
||||
setIDView();
|
||||
setGroupNickNameView();
|
||||
setDisbandButton();
|
||||
setTransferButton();
|
||||
if (communityBean.isOwner()) {
|
||||
communitySettingsLabel.setVisibility(View.VISIBLE);
|
||||
createTopicLv.setVisibility(View.VISIBLE);
|
||||
createTopicCategoryLv.setVisibility(View.VISIBLE);
|
||||
setCreateCategoryView();
|
||||
setCreateTopicView();
|
||||
} else {
|
||||
communitySettingsLabel.setVisibility(View.GONE);
|
||||
createTopicLv.setVisibility(View.GONE);
|
||||
createTopicCategoryLv.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setNameView() {
|
||||
if (communityBean.isOwner()) {
|
||||
communityNameLv.setShowArrow(true);
|
||||
communityNameLv.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(CommunitySettingsActivity.this);
|
||||
popupInputCard.setTitle(getString(R.string.community_community_name));
|
||||
popupInputCard.setContent(communityBean.getCommunityName());
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
presenter.modifyCommunityName(communityBean.getGroupId(), result, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify community name failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
popupInputCard.show(communityNameLv, Gravity.BOTTOM);
|
||||
}
|
||||
});
|
||||
}
|
||||
communityNameLv.setContent(communityBean.getCommunityName());
|
||||
}
|
||||
|
||||
private void setAvatarView() {
|
||||
RoundCornerImageView cornerImageView = communityAvatarLv.getContentImage();
|
||||
GlideEngine.loadImageSetDefault(cornerImageView, communityBean.getGroupFaceUrl(),
|
||||
TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuikit.timcommon.R.attr.core_default_group_icon_community));
|
||||
if (communityBean.isOwner()) {
|
||||
communityAvatarLv.setShowArrow(true);
|
||||
communityAvatarLv.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
for (int i = 0; i < CommunityConstants.GROUP_FACE_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(CommunityConstants.GROUP_FACE_URL, (i + 1) + ""));
|
||||
imageBean.setImageUri(String.format(CommunityConstants.GROUP_FACE_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CommunitySettingsActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getResources().getString(R.string.community_choose_avatar));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 4);
|
||||
intent.putExtra(ImageSelectActivity.PLACEHOLDER, com.tencent.qcloud.tuikit.timcommon.R.drawable.core_default_user_icon_light);
|
||||
int itemWidth = (int) (ScreenUtil.getScreenWidth(CommunitySettingsActivity.this) * 0.2f);
|
||||
intent.putExtra(ImageSelectMinimalistActivity.ITEM_WIDTH, itemWidth);
|
||||
intent.putExtra(ImageSelectMinimalistActivity.ITEM_HEIGHT, itemWidth);
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
intent.putExtra(ImageSelectActivity.SELECTED,
|
||||
new ImageSelectActivity.ImageBean(communityBean.getGroupFaceUrl(), communityBean.getGroupFaceUrl(), false));
|
||||
startActivityForResult(intent, REQUEST_FOR_CHANGE_AVATAR);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setCoverView() {
|
||||
RoundCornerImageView cornerImageView = communityCoverLv.getContentImage();
|
||||
GlideEngine.loadImageSetDefault(cornerImageView, communityBean.getCoverUrl(), R.drawable.community_cover_default);
|
||||
if (communityBean.isOwner()) {
|
||||
communityCoverLv.setShowArrow(true);
|
||||
communityCoverLv.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> coverList = new ArrayList<>();
|
||||
for (int i = 0; i < CommunityConstants.COVER_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(CommunityConstants.COVER_URL, (i + 1) + ""));
|
||||
imageBean.setImageUri(String.format(CommunityConstants.COVER_URL, (i + 1) + ""));
|
||||
coverList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CommunitySettingsActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getString(R.string.community_select_cover));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 2);
|
||||
intent.putExtra(ImageSelectActivity.PLACEHOLDER, R.drawable.community_cover_default);
|
||||
int itemWidth = (int) (ScreenUtil.getScreenWidth(CommunitySettingsActivity.this) * 0.42f);
|
||||
int itemHeight = (int) (itemWidth / 2.0f);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, itemWidth);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, itemHeight);
|
||||
intent.putExtra(ImageSelectActivity.DATA, coverList);
|
||||
intent.putExtra(
|
||||
ImageSelectActivity.SELECTED, new ImageSelectActivity.ImageBean(communityBean.getCoverUrl(), communityBean.getCoverUrl(), false));
|
||||
startActivityForResult(intent, REQUEST_FOR_CHANGE_COVER);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setIntroductionView() {
|
||||
if (communityBean.isOwner()) {
|
||||
communityIntroductionLv.setShowArrow(true);
|
||||
communityIntroductionLv.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(CommunitySettingsActivity.this);
|
||||
popupInputCard.setTitle(getString(R.string.community_community_introduction));
|
||||
popupInputCard.setContent(communityBean.getIntroduction());
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
presenter.modifyCommunityIntroduction(communityBean.getGroupId(), result, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify community introduction failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
popupInputCard.show(communityIntroductionLv, Gravity.BOTTOM);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (TextUtils.isEmpty(communityBean.getIntroduction())) {
|
||||
communityIntroductionLv.setContent(getString(R.string.community_settings_not_set));
|
||||
communityIntroductionLv.getContentText().setTextColor(getResources().getColor(R.color.community_setting_linear_content_disable_color));
|
||||
} else {
|
||||
communityIntroductionLv.setContent(communityBean.getIntroduction());
|
||||
communityIntroductionLv.getContentText().setTextColor(getResources().getColor(R.color.community_setting_linear_content_default_color));
|
||||
}
|
||||
}
|
||||
|
||||
private void setIDView() {
|
||||
communityIDLv.setContent(communityBean.getGroupId());
|
||||
}
|
||||
|
||||
private void setCreateCategoryView() {
|
||||
createTopicCategoryLv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupInputCard inputCard = new PopupInputCard(CommunitySettingsActivity.this);
|
||||
inputCard.setTitle(getString(R.string.community_create_topic_category));
|
||||
inputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
presenter.createCategory(communityBean.getGroupId(), result);
|
||||
}
|
||||
});
|
||||
inputCard.show(createTopicCategoryLv, Gravity.BOTTOM);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setCreateTopicView() {
|
||||
createTopicLv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(CommunitySettingsActivity.this, CreateTopicActivity.class);
|
||||
intent.putExtra(CommunityConstants.COMMUNITY_BEAN, communityBean);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setGroupNickNameView() {
|
||||
presenter.getGroupNameCard(communityBean.getGroupId(), new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
groupNickNameLv.setContent(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {}
|
||||
});
|
||||
groupNickNameLv.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupInputCard popupInputCard = new PopupInputCard(CommunitySettingsActivity.this);
|
||||
popupInputCard.setTitle(getString(R.string.community_self_nick_name));
|
||||
popupInputCard.setContent(groupNickNameLv.getContent());
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
presenter.modifyCommunitySelfNameCard(communityBean.getGroupId(), result, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
setGroupNickNameView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify name card failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
popupInputCard.show(groupNickNameLv, Gravity.BOTTOM);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDisbandButton() {
|
||||
if (communityBean.isOwner()) {
|
||||
disbandButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
disbandButton.setVisibility(View.GONE);
|
||||
}
|
||||
disbandButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (disbandDialog == null) {
|
||||
disbandDialog = new TUIKitDialog(CommunitySettingsActivity.this)
|
||||
.builder()
|
||||
.setTitle(getString(R.string.community_disband_group))
|
||||
.setCancelOutside(true)
|
||||
.setPositiveButton(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
disbandCommunity();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {}
|
||||
});
|
||||
}
|
||||
disbandDialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disbandCommunity() {
|
||||
presenter.disbandCommunity(communityBean.getGroupId(), new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("dismiss community failed, code=" + errCode + " errMsg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setTransferButton() {
|
||||
if (communityBean.isOwner()) {
|
||||
transferButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
transferButton.setVisibility(View.GONE);
|
||||
}
|
||||
transferButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(CommunityConstants.COMMUNITY_BEAN, communityBean);
|
||||
bundle.putSerializable(CommunityConstants.IS_SELECT_MODE, true);
|
||||
bundle.putSerializable(CommunityConstants.LIMIT, 1);
|
||||
TUICore.startActivity(CommunitySettingsActivity.this, "CommunityMemberActivity", bundle, REQUEST_FOR_CHANGE_OWNER);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunityChanged(CommunityBean communityBean) {
|
||||
if (TextUtils.equals(communityBean.getGroupId(), this.communityBean.getGroupId())) {
|
||||
this.communityBean = communityBean;
|
||||
setupView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (data != null) {
|
||||
if (requestCode == REQUEST_FOR_CHANGE_AVATAR) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String avatarUrl = imageBean.getImageUri();
|
||||
presenter.modifyCommunityAvatar(communityBean.getGroupId(), avatarUrl, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify group avatar failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
} else if (requestCode == REQUEST_FOR_CHANGE_COVER) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String coverUrl = imageBean.getImageUri();
|
||||
presenter.modifyCommunityCover(communityBean.getGroupId(), coverUrl, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify group avatar failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
} else if (requestCode == REQUEST_FOR_CHANGE_OWNER) {
|
||||
List<String> userIDs = data.getStringArrayListExtra(CommunityConstants.LIST);
|
||||
if (!userIDs.isEmpty()) {
|
||||
String newOwnerID = userIDs.get(0);
|
||||
presenter.transferCommunityOwner(communityBean.getGroupId(), newOwnerID, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("transfer group owner failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.ImageSelectActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.ImageSelectMinimalistActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SelectTextButton;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateCommunityActivity extends BaseLightActivity {
|
||||
private static final int COVER_REQUEST_CODE = 1;
|
||||
private static final int FACE_REQUEST_CODE = 2;
|
||||
|
||||
private ImageView coverImage;
|
||||
private ImageView faceImage;
|
||||
private View faceSelectArea;
|
||||
private View selectFaceLayout;
|
||||
private TextView nameCount;
|
||||
private TextView introductionCount;
|
||||
private EditText nameEdit;
|
||||
private EditText introductionEdit;
|
||||
private SelectTextButton selectTextButton;
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private CommunityPresenter communityPresenter;
|
||||
|
||||
private String coverUrl = CommunityConstants.DEFAULT_COVER_URL;
|
||||
private String faceUrl = CommunityConstants.DEFAULT_GROUP_FACE_URL;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_create_community_activity_layout);
|
||||
coverImage = findViewById(R.id.cover_iv);
|
||||
titleBarLayout = findViewById(R.id.create_community_title);
|
||||
nameCount = findViewById(R.id.name_count);
|
||||
introductionCount = findViewById(R.id.introduction_count);
|
||||
nameEdit = findViewById(R.id.name_edit_text);
|
||||
introductionEdit = findViewById(R.id.introduction_edit_text);
|
||||
selectTextButton = findViewById(R.id.select_cover_button);
|
||||
faceSelectArea = findViewById(R.id.face_select_fl);
|
||||
selectFaceLayout = findViewById(R.id.select_face_ll);
|
||||
faceImage = findViewById(R.id.face_iv);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
communityPresenter = new CommunityPresenter();
|
||||
|
||||
titleBarLayout.setTitle(getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String name = nameEdit.getText().toString();
|
||||
String introduction = introductionEdit.getText().toString();
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
communityPresenter.createCommunityGroup(name, introduction, coverUrl, faceUrl);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
selectTextButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> coverList = new ArrayList<>();
|
||||
for (int i = 0; i < CommunityConstants.COVER_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(CommunityConstants.COVER_URL, (i + 1) + ""));
|
||||
imageBean.setImageUri(String.format(CommunityConstants.COVER_URL, (i + 1) + ""));
|
||||
coverList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CreateCommunityActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getString(R.string.community_select_cover));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 2);
|
||||
int itemWidth = (int) (ScreenUtil.getScreenWidth(CreateCommunityActivity.this) * 0.42f);
|
||||
int itemHeight = (int) (itemWidth / 2.0f);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_WIDTH, itemWidth);
|
||||
intent.putExtra(ImageSelectActivity.ITEM_HEIGHT, itemHeight);
|
||||
intent.putExtra(ImageSelectActivity.DATA, coverList);
|
||||
startActivityForResult(intent, COVER_REQUEST_CODE);
|
||||
}
|
||||
});
|
||||
faceSelectArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ArrayList<ImageSelectActivity.ImageBean> faceList = new ArrayList<>();
|
||||
for (int i = 0; i < CommunityConstants.GROUP_FACE_COUNT; i++) {
|
||||
ImageSelectActivity.ImageBean imageBean = new ImageSelectActivity.ImageBean();
|
||||
imageBean.setThumbnailUri(String.format(CommunityConstants.GROUP_FACE_URL, (i + 1) + ""));
|
||||
imageBean.setImageUri(String.format(CommunityConstants.GROUP_FACE_URL, (i + 1) + ""));
|
||||
faceList.add(imageBean);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CreateCommunityActivity.this, ImageSelectActivity.class);
|
||||
intent.putExtra(ImageSelectActivity.TITLE, getString(R.string.community_select_face));
|
||||
intent.putExtra(ImageSelectActivity.SPAN_COUNT, 4);
|
||||
int itemWidth = (int) (ScreenUtil.getScreenWidth(CreateCommunityActivity.this) * 0.2f);
|
||||
intent.putExtra(ImageSelectMinimalistActivity.ITEM_WIDTH, itemWidth);
|
||||
intent.putExtra(ImageSelectMinimalistActivity.ITEM_HEIGHT, itemWidth);
|
||||
intent.putExtra(ImageSelectActivity.DATA, faceList);
|
||||
startActivityForResult(intent, FACE_REQUEST_CODE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (data != null) {
|
||||
if (resultCode == ImageSelectActivity.RESULT_CODE_SUCCESS) {
|
||||
if (requestCode == COVER_REQUEST_CODE) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
coverUrl = imageBean.getImageUri();
|
||||
coverImage.setBackground(null);
|
||||
Glide.with(this).load(coverUrl).into(coverImage);
|
||||
} else if (requestCode == FACE_REQUEST_CODE) {
|
||||
ImageSelectActivity.ImageBean imageBean = (ImageSelectActivity.ImageBean) data.getSerializableExtra(ImageSelectActivity.DATA);
|
||||
if (imageBean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
faceUrl = imageBean.getImageUri();
|
||||
selectFaceLayout.setVisibility(View.GONE);
|
||||
Glide.with(this).load(faceUrl).into(faceImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ThreadUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.TUICommunityService;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SelectListPopupView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SettingsLinearView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.BottomPopupCard;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.TopicPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICreateTopicActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateTopicActivity extends BaseLightActivity implements ICreateTopicActivity {
|
||||
private TitleBarLayout titleBarLayout;
|
||||
private EditText topicNameEdit;
|
||||
|
||||
private View videoTypeArea;
|
||||
private View liveTypeArea;
|
||||
private SettingsLinearView topicCategoryView;
|
||||
private SelectListPopupView selectListPopupView;
|
||||
|
||||
private CommunityBean communityBean;
|
||||
private TopicPresenter presenter;
|
||||
private CommunityPresenter communityPresenter;
|
||||
private String category;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_activity_create_topic);
|
||||
Intent intent = getIntent();
|
||||
communityBean = (CommunityBean) intent.getSerializableExtra(CommunityConstants.COMMUNITY_BEAN);
|
||||
|
||||
presenter = new TopicPresenter();
|
||||
communityPresenter = new CommunityPresenter();
|
||||
communityPresenter.setCreateTopicActivity(this);
|
||||
communityPresenter.setCommunityEventListener();
|
||||
communityPresenter.setCurrentCommunityBean(communityBean);
|
||||
|
||||
titleBarLayout = findViewById(R.id.create_topic_title);
|
||||
topicNameEdit = findViewById(R.id.topic_name_edit);
|
||||
videoTypeArea = findViewById(R.id.video_type_area);
|
||||
liveTypeArea = findViewById(R.id.live_type_area);
|
||||
topicCategoryView = findViewById(R.id.topic_category_linear);
|
||||
titleBarLayout.setTitle(getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
titleBarLayout.getRightIcon().setVisibility(View.GONE);
|
||||
titleBarLayout.setOnRightClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hideSoftInput();
|
||||
createTopic();
|
||||
}
|
||||
});
|
||||
|
||||
videoTypeArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToastUtil.toastShortMessage(getString(R.string.community_coming_soon));
|
||||
}
|
||||
});
|
||||
|
||||
liveTypeArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToastUtil.toastShortMessage(getString(R.string.community_coming_soon));
|
||||
}
|
||||
});
|
||||
|
||||
topicCategoryView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hideSoftInput();
|
||||
ThreadUtils.postOnUiThreadDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showTopicCategoryView();
|
||||
}
|
||||
}, 120);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunityChanged(CommunityBean communityBean) {
|
||||
if (TextUtils.equals(this.communityBean.getGroupId(), communityBean.getGroupId())) {
|
||||
this.communityBean = communityBean;
|
||||
}
|
||||
}
|
||||
|
||||
private void setCategory() {
|
||||
topicCategoryView.setName(category);
|
||||
}
|
||||
|
||||
private void showTopicCategoryView() {
|
||||
if (selectListPopupView != null && selectListPopupView.isShown()) {
|
||||
return;
|
||||
}
|
||||
selectListPopupView = new SelectListPopupView(this);
|
||||
List<String> selectData = new ArrayList<>();
|
||||
String noCategory = getString(R.string.community_no_category);
|
||||
selectData.add(noCategory);
|
||||
if (communityBean.getTopicCategories() != null) {
|
||||
selectData.addAll(communityBean.getTopicCategories());
|
||||
}
|
||||
|
||||
selectListPopupView.setData(selectData);
|
||||
selectListPopupView.setTitle(getString(R.string.community_select_category));
|
||||
selectListPopupView.setMaxHeightPx(ScreenUtil.dip2px(360));
|
||||
selectListPopupView.setOnSelectListener(new SelectListPopupView.OnSelectListener() {
|
||||
@Override
|
||||
public void onSelected(String data) {
|
||||
if (!TextUtils.equals(noCategory, data)) {
|
||||
category = data;
|
||||
setCategory();
|
||||
} else {
|
||||
category = null;
|
||||
topicCategoryView.setName(noCategory);
|
||||
}
|
||||
}
|
||||
});
|
||||
BottomPopupCard bottomPopupCard = new BottomPopupCard(this, selectListPopupView);
|
||||
bottomPopupCard.show(titleBarLayout);
|
||||
}
|
||||
|
||||
private void createTopic() {
|
||||
String topicName = topicNameEdit.getText().toString();
|
||||
if (!TextUtils.isEmpty(topicName)) {
|
||||
presenter.createTopic(communityBean.getGroupId(), topicName, category, TopicBean.TOPIC_TYPE_TEXT, new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
TUICore.notifyEvent(TUIConstants.TUICommunity.EVENT_KEY_COMMUNITY_EXPERIENCE, TUIConstants.TUICommunity.EVENT_SUB_KEY_CREATE_TOPIC, null);
|
||||
ToastUtil.toastShortMessage(TUICommunityService.getAppContext().getString(R.string.community_create_topic_success));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage(
|
||||
TUICommunityService.getAppContext().getString(R.string.community_create_topic_failed) + ", code=" + errCode + " message=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SelectTextButton;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
|
||||
public class JoinCommunityActivity extends BaseLightActivity {
|
||||
private ImageView searchIcon;
|
||||
private TextView cancelButton;
|
||||
private View communityItemArea;
|
||||
private View notFoundArea;
|
||||
private SelectTextButton joinButton;
|
||||
private ImageView avatar;
|
||||
private TextView name;
|
||||
private TextView owner;
|
||||
private EditText idEditText;
|
||||
|
||||
private CommunityPresenter presenter;
|
||||
private CommunityBean communityBean;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_activity_join_community);
|
||||
searchIcon = findViewById(R.id.search_icon);
|
||||
cancelButton = findViewById(R.id.cancel_button);
|
||||
communityItemArea = findViewById(R.id.community_item_rl);
|
||||
notFoundArea = findViewById(R.id.not_found_ll);
|
||||
joinButton = findViewById(R.id.join_community_button);
|
||||
avatar = findViewById(R.id.community_avatar);
|
||||
name = findViewById(R.id.community_name);
|
||||
owner = findViewById(R.id.community_owner);
|
||||
idEditText = findViewById(R.id.community_id_input);
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
presenter = new CommunityPresenter();
|
||||
idEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
cancelButton.setVisibility(View.GONE);
|
||||
searchIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cancelButton.setVisibility(View.VISIBLE);
|
||||
searchIcon.setVisibility(View.GONE);
|
||||
}
|
||||
searchCommunity(s.toString());
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
idEditText.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setCommunityArea(CommunityBean data) {
|
||||
communityBean = data;
|
||||
GlideEngine.loadImageSetDefault(
|
||||
avatar, data.getGroupFaceUrl(), TUIThemeManager.getAttrResId(this, com.tencent.qcloud.tuikit.timcommon.R.attr.core_default_group_icon_community));
|
||||
name.setText(data.getCommunityName());
|
||||
owner.setText(getString(R.string.community_owner) + ": " + data.getOwner());
|
||||
setJoinButton(data.getRole() != CommunityBean.ROLE_UNDEFINED);
|
||||
}
|
||||
|
||||
private void setJoinButton(boolean isJoined) {
|
||||
if (isJoined) {
|
||||
joinButton.setText(getString(R.string.community_joined));
|
||||
joinButton.setTextColor(0xFF999999);
|
||||
joinButton.setColor(0xFF999999);
|
||||
} else {
|
||||
joinButton.setText(getString(R.string.community_join));
|
||||
joinButton.setTextColor(0xFF006EFF);
|
||||
joinButton.setColor(0xFF006EFF);
|
||||
}
|
||||
}
|
||||
|
||||
private void searchCommunity(String groupID) {
|
||||
if (TextUtils.isEmpty(groupID)) {
|
||||
notFoundArea.setVisibility(View.GONE);
|
||||
communityItemArea.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
presenter.searchCommunity(groupID, new IUIKitCallback<CommunityBean>() {
|
||||
@Override
|
||||
public void onSuccess(CommunityBean data) {
|
||||
setCommunityArea(data);
|
||||
notFoundArea.setVisibility(View.GONE);
|
||||
communityItemArea.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
communityBean = null;
|
||||
TUICommunityLog.e("JoinCommunityActivity", "not found the community, code=" + errCode + " errMsg=" + errMsg);
|
||||
notFoundArea.setVisibility(View.VISIBLE);
|
||||
communityItemArea.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
joinButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (communityBean != null && communityBean.getRole() == CommunityBean.ROLE_UNDEFINED) {
|
||||
presenter.joinCommunity(communityBean.getGroupId(), new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
setJoinButton(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("join community failed, code=" + errCode + " desc=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.gatherimage.ShadeImageView;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityFragment;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.AddCommunityView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.CommunityDetailView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.CommunityGroupList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.CommunitySelfView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TUICommunityFragment extends Fragment implements ICommunityFragment {
|
||||
private static final String TAG = TUICommunityFragment.class.getSimpleName();
|
||||
private View baseView;
|
||||
private ViewPager2 communityContentViewPager;
|
||||
private CommunityFragmentAdapter communityFragmentAdapter;
|
||||
private ShadeImageView selfFace;
|
||||
private ShadeImageView selfFaceSelectBorder;
|
||||
private ShadeImageView addGroup;
|
||||
private ShadeImageView addGroupSelectBorder;
|
||||
|
||||
private View connectFailed;
|
||||
private View connecting;
|
||||
private ImageView homeView;
|
||||
private CommunityGroupList groupIconList;
|
||||
private CommunityPresenter presenter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
baseView = inflater.inflate(R.layout.community_main_fragment_layout, container, false);
|
||||
initView();
|
||||
initData();
|
||||
return baseView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
communityContentViewPager = baseView.findViewById(R.id.community_content_view_pager);
|
||||
// forbidden smooth scroll
|
||||
communityContentViewPager.setUserInputEnabled(false);
|
||||
|
||||
communityFragmentAdapter = new CommunityFragmentAdapter();
|
||||
communityContentViewPager.setAdapter(communityFragmentAdapter);
|
||||
selfFace = baseView.findViewById(R.id.self_face);
|
||||
selfFaceSelectBorder = baseView.findViewById(R.id.self_face_select_border);
|
||||
addGroup = baseView.findViewById(R.id.add_community);
|
||||
addGroupSelectBorder = baseView.findViewById(R.id.add_community_select_border);
|
||||
selfFace.setRadius(ScreenUtil.dip2px(24));
|
||||
selfFaceSelectBorder.setRadius(ScreenUtil.dip2px(24));
|
||||
selfFace.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchCommunity(0);
|
||||
}
|
||||
});
|
||||
addGroup.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchCommunity(communityFragmentAdapter.getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
groupIconList = baseView.findViewById(R.id.community_group_list);
|
||||
communityContentViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
clearSelected();
|
||||
if (position == 0) {
|
||||
selfFaceSelectBorder.setVisibility(View.VISIBLE);
|
||||
} else if (position == communityFragmentAdapter.getItemCount() - 1) {
|
||||
addGroupSelectBorder.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
groupIconList.setSelectedPosition(position - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connectFailed = baseView.findViewById(R.id.network_connect_failed);
|
||||
connecting = baseView.findViewById(R.id.network_connecting);
|
||||
homeView = baseView.findViewById(R.id.home_view);
|
||||
if (TUIConfig.getTUIHostType() != TUIConfig.TUI_HOST_TYPE_RTCUBE) {
|
||||
homeView.setVisibility(View.GONE);
|
||||
} else {
|
||||
homeView.setVisibility(View.VISIBLE);
|
||||
homeView.setBackgroundResource(com.tencent.qcloud.tuikit.timcommon.R.drawable.common_title_bar_home_icon);
|
||||
int iconwidth = ScreenUtil.dip2px(TUIConstants.TIMAppKit.BACK_RTCUBE_HOME_ICON_WIDTH);
|
||||
int iconHeight = ScreenUtil.dip2px(TUIConstants.TIMAppKit.BACK_RTCUBE_HOME_ICON_HEIGHT);
|
||||
ViewGroup.LayoutParams iconParams = homeView.getLayoutParams();
|
||||
iconParams.width = iconwidth;
|
||||
iconParams.height = iconHeight;
|
||||
homeView.setLayoutParams(iconParams);
|
||||
homeView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TIMAppKit.BACK_TO_RTCUBE_DEMO_TYPE_KEY, TUIConstants.TIMAppKit.BACK_TO_RTCUBE_DEMO_TYPE_IM);
|
||||
TUICore.startActivity("TRTCMainActivity", bundle);
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelfFaceChanged(String newFaceUrl) {
|
||||
GlideEngine.loadUserIcon(selfFace, newFaceUrl);
|
||||
}
|
||||
|
||||
private void clearSelected() {
|
||||
selfFaceSelectBorder.setVisibility(View.GONE);
|
||||
addGroupSelectBorder.setVisibility(View.GONE);
|
||||
groupIconList.clearSelected();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
presenter = new CommunityPresenter();
|
||||
groupIconList.setPresenter(presenter);
|
||||
presenter.setCommunityFragment(this);
|
||||
presenter.setCommunityEventListener();
|
||||
groupIconList.setOnCommunityClickListener(new OnCommunityClickListener() {
|
||||
@Override
|
||||
public void onClick(CommunityBean communityBean) {
|
||||
int index = communityFragmentAdapter.getIndexInAdapter(communityBean);
|
||||
if (index != -1) {
|
||||
switchCommunity(index);
|
||||
} else {
|
||||
ToastUtil.toastShortMessage("can't find community");
|
||||
}
|
||||
}
|
||||
});
|
||||
presenter.loadJoinedCommunityList();
|
||||
presenter.getSelfFaceUrl(new IUIKitCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
GlideEngine.loadUserIcon(selfFace, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.i(TAG, "getSelfFaceUrl error:" + errCode + ", errMsg:" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
if (presenter != null) {
|
||||
presenter.loadJoinedCommunityList();
|
||||
}
|
||||
}
|
||||
|
||||
private void switchCommunity(int index) {
|
||||
communityContentViewPager.setCurrentItem(index, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinedCommunityChanged(List<CommunityBean> communityBeanList) {
|
||||
communityFragmentAdapter.setData(communityBeanList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeChanged(int index, int count) {
|
||||
communityFragmentAdapter.notifyItemRangeChanged(index + 1, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemInserted(int index) {
|
||||
communityFragmentAdapter.notifyItemInserted(index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChanged(int index) {
|
||||
communityFragmentAdapter.notifyItemChanged(index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRemoved(int index) {
|
||||
int currentItem = communityContentViewPager.getCurrentItem();
|
||||
if (currentItem == index + 1) {
|
||||
communityContentViewPager.setCurrentItem(index);
|
||||
}
|
||||
communityFragmentAdapter.notifyItemRemoved(index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworkStateChanged(int state) {
|
||||
if (state == CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECTED) {
|
||||
connectFailed.setVisibility(View.GONE);
|
||||
connecting.setVisibility(View.GONE);
|
||||
} else if (state == CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECT_FAILED) {
|
||||
connecting.setVisibility(View.GONE);
|
||||
connectFailed.setVisibility(View.VISIBLE);
|
||||
} else if (state == CommunityConstants.COMMUNITY_NETWORK_STATE_CONNECTING) {
|
||||
connecting.setVisibility(View.VISIBLE);
|
||||
connectFailed.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunitySelected(CommunityBean communityBean) {
|
||||
int index = communityFragmentAdapter.getIndexInAdapter(communityBean);
|
||||
if (index != -1) {
|
||||
switchCommunity(index);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CommunityFragmentAdapter extends RecyclerView.Adapter<CommunityFragmentAdapter.FragmentContentViewHolder> {
|
||||
private static final int SELF_PAGE_TYPE = 1;
|
||||
private static final int ADD_PAGE_TYPE = 2;
|
||||
private static final int COMMUNITY_PAGE_TYPE = 3;
|
||||
|
||||
private List<CommunityBean> data;
|
||||
|
||||
public void setData(List<CommunityBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FragmentContentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view;
|
||||
if (viewType == SELF_PAGE_TYPE) {
|
||||
view = new CommunitySelfView(parent.getContext());
|
||||
} else if (viewType == ADD_PAGE_TYPE) {
|
||||
view = new AddCommunityView(parent.getContext());
|
||||
} else {
|
||||
view = new CommunityDetailView(parent.getContext());
|
||||
}
|
||||
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
view.setLayoutParams(layoutParams);
|
||||
return new FragmentContentViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull FragmentContentViewHolder holder, int position) {
|
||||
if (holder.itemView instanceof CommunityDetailView) {
|
||||
CommunityBean communityBean = data.get(position - 1);
|
||||
((CommunityDetailView) holder.itemView).setCommunityBean(communityBean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return SELF_PAGE_TYPE;
|
||||
} else if (position == getItemCount() - 1) {
|
||||
return ADD_PAGE_TYPE;
|
||||
} else {
|
||||
return COMMUNITY_PAGE_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return 2;
|
||||
}
|
||||
return data.size() + 2;
|
||||
}
|
||||
|
||||
public int getIndexInAdapter(CommunityBean communityBean) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
return data.indexOf(communityBean) + 1;
|
||||
}
|
||||
|
||||
static class FragmentContentViewHolder extends RecyclerView.ViewHolder {
|
||||
public FragmentContentViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class OnCommunityClickListener {
|
||||
public void onClick(CommunityBean communityBean) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.page;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.PopupInputCard;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SelectListPopupView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.SettingsLinearView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.BottomPopupCard;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.TopicPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ITopicInfoActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TopicInfoActivity extends BaseLightActivity implements ITopicInfoActivity {
|
||||
private TopicPresenter presenter;
|
||||
|
||||
private TextView deleteTopicButton;
|
||||
private TextView clearTopicMessageButton;
|
||||
private SettingsLinearView nameSetting;
|
||||
private SettingsLinearView categorySetting;
|
||||
private TopicBean topicBean;
|
||||
private CommunityBean communityBean;
|
||||
private TUIKitDialog deleteTopicDialog;
|
||||
private SelectListPopupView selectListPopupView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.community_activity_topic_info);
|
||||
nameSetting = findViewById(R.id.topic_name_setting);
|
||||
deleteTopicButton = findViewById(R.id.delete_topic_button);
|
||||
clearTopicMessageButton = findViewById(R.id.clear_topic_message_button);
|
||||
categorySetting = findViewById(R.id.topic_category_setting);
|
||||
Intent intent = getIntent();
|
||||
String topicID = intent.getStringExtra(TUIConstants.TUICommunity.TOPIC_ID);
|
||||
if (TextUtils.isEmpty(topicID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
presenter = new TopicPresenter();
|
||||
presenter.setCommunityEventListener();
|
||||
presenter.setTopicInfoActivity(this);
|
||||
loadTopicBean(topicID);
|
||||
}
|
||||
|
||||
private void loadTopicBean(String topicID) {
|
||||
presenter.getCommunityBean(topicID, new IUIKitCallback<CommunityBean>() {
|
||||
@Override
|
||||
public void onSuccess(CommunityBean data) {
|
||||
communityBean = data;
|
||||
presenter.setCommunityBean(data);
|
||||
if (data.isOwner()) {
|
||||
setOwnerView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {}
|
||||
});
|
||||
|
||||
presenter.getTopicBean(topicID, new IUIKitCallback<TopicBean>() {
|
||||
@Override
|
||||
public void onSuccess(TopicBean data) {
|
||||
topicBean = data;
|
||||
nameSetting.setContent(topicBean.getTopicName());
|
||||
if (TextUtils.isEmpty(topicBean.getCategory())) {
|
||||
categorySetting.setContent(getString(R.string.community_no_category));
|
||||
} else {
|
||||
categorySetting.setContent(topicBean.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
TUICommunityLog.e("TopicInfoActivity", "getTopicBean failed, code=" + errCode + ", msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
clearTopicMessageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new TUIKitDialog(TopicInfoActivity.this)
|
||||
.builder()
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(TopicInfoActivity.this.getString(R.string.clear_message_tip))
|
||||
.setDialogWidth(0.75f)
|
||||
.setPositiveButton(TopicInfoActivity.this.getString(com.tencent.qcloud.tuicore.R.string.sure),
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put(TUIConstants.TUIContact.GROUP_ID, topicID);
|
||||
TUICore.notifyEvent(TUIConstants.TUIContact.EVENT_GROUP, TUIConstants.TUIContact.EVENT_SUB_KEY_CLEAR_GROUP_MESSAGE, hashMap);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(TopicInfoActivity.this.getString(com.tencent.qcloud.tuicore.R.string.cancel),
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setOwnerView() {
|
||||
deleteTopicButton.setVisibility(View.VISIBLE);
|
||||
deleteTopicButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteTopic();
|
||||
}
|
||||
});
|
||||
nameSetting.setShowArrow(true);
|
||||
nameSetting.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (topicBean == null) {
|
||||
return;
|
||||
}
|
||||
PopupInputCard popupInputCard = new PopupInputCard(TopicInfoActivity.this);
|
||||
popupInputCard.setTitle(getString(R.string.community_topic_name));
|
||||
popupInputCard.setContent(topicBean.getTopicName());
|
||||
popupInputCard.setOnPositive(new PopupInputCard.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(String result) {
|
||||
presenter.modifyTopicName(topicBean.getID(), result, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing, you can receive onTopicInfoChanged callback in TUICommunityService.java
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify name failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
popupInputCard.show(nameSetting, Gravity.BOTTOM);
|
||||
}
|
||||
});
|
||||
categorySetting.setShowArrow(true);
|
||||
categorySetting.setOnContentClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (topicBean == null || communityBean == null) {
|
||||
return;
|
||||
}
|
||||
if (selectListPopupView != null && selectListPopupView.isShown()) {
|
||||
return;
|
||||
}
|
||||
selectListPopupView = new SelectListPopupView(TopicInfoActivity.this);
|
||||
List<String> selectData = new ArrayList<>();
|
||||
String noCategory = getString(R.string.community_no_category);
|
||||
selectData.add(noCategory);
|
||||
if (communityBean.getTopicCategories() != null) {
|
||||
selectData.addAll(communityBean.getTopicCategories());
|
||||
}
|
||||
|
||||
selectListPopupView.setData(selectData);
|
||||
selectListPopupView.setTitle(getString(R.string.community_select_category));
|
||||
selectListPopupView.setMaxHeightPx(ScreenUtil.dip2px(360));
|
||||
selectListPopupView.setOnSelectListener(new SelectListPopupView.OnSelectListener() {
|
||||
@Override
|
||||
public void onSelected(String data) {
|
||||
if (!TextUtils.equals(data, topicBean.getCategory())) {
|
||||
if (TextUtils.equals(noCategory, data)) {
|
||||
data = "";
|
||||
}
|
||||
presenter.modifyTopicCategory(topicBean, data, new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
// do nothing, you can receive onTopicInfoChanged callback in TUICommunityService.java
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("modify category failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
BottomPopupCard bottomPopupCard = new BottomPopupCard(TopicInfoActivity.this, selectListPopupView);
|
||||
bottomPopupCard.show(categorySetting);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteTopic() {
|
||||
if (deleteTopicDialog == null || !deleteTopicDialog.isShowing()) {
|
||||
deleteTopicDialog = new TUIKitDialog(this)
|
||||
.builder()
|
||||
.setCancelable(true)
|
||||
.setCancelOutside(true)
|
||||
.setTitle(getString(R.string.community_delete_topic_tip))
|
||||
.setDialogWidth(0.75f)
|
||||
.setPositiveButton(getString(com.tencent.qcloud.tuicore.R.string.sure), new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
presenter.deleteTopic(topicBean.getID(), new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("delete topic failed, code=" + errCode + " msg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
deleteTopicDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicChanged(TopicBean topicBean) {
|
||||
if (TextUtils.equals(this.topicBean.getID(), topicBean.getID())) {
|
||||
this.topicBean = topicBean;
|
||||
nameSetting.setContent(topicBean.getTopicName());
|
||||
if (TextUtils.isEmpty(topicBean.getCategory())) {
|
||||
categorySetting.setContent(getString(R.string.community_no_category));
|
||||
} else {
|
||||
categorySetting.setContent(topicBean.getCategory());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.banner.BannerView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.CreateCommunityActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.JoinCommunityActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddCommunityView extends FrameLayout {
|
||||
private static final int CREATE_CODE = 1;
|
||||
private View createBtn;
|
||||
private View joinBtn;
|
||||
private BannerView bannerView;
|
||||
|
||||
public AddCommunityView(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public AddCommunityView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public AddCommunityView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public AddCommunityView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.community_add_community_layout, this);
|
||||
createBtn = view.findViewById(R.id.create_community);
|
||||
joinBtn = view.findViewById(R.id.join_community);
|
||||
bannerView = view.findViewById(R.id.banner_view);
|
||||
initEvent();
|
||||
if (!TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), TUIThemeManager.LANGUAGE_ZH_CN)) {
|
||||
bannerView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
createBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getContext(), CreateCommunityActivity.class);
|
||||
Activity activity = (Activity) getContext();
|
||||
activity.startActivityForResult(intent, CREATE_CODE);
|
||||
}
|
||||
});
|
||||
|
||||
joinBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getContext(), JoinCommunityActivity.class);
|
||||
Activity activity = (Activity) getContext();
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
List<BannerView.BannerItem> bannerItems = new ArrayList<>();
|
||||
BannerView.BannerItem communityIntroduction = new BannerView.BannerItem();
|
||||
communityIntroduction.setImageUri(R.drawable.community_introduction);
|
||||
communityIntroduction.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), CommunityConstants.COMMUNITY_INTRODUCTION);
|
||||
}
|
||||
});
|
||||
bannerItems.add(communityIntroduction);
|
||||
BannerView.BannerItem imNew = new BannerView.BannerItem();
|
||||
imNew.setImageUri(R.drawable.community_im_new);
|
||||
imNew.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), CommunityConstants.IM_NEW_BUYING);
|
||||
}
|
||||
});
|
||||
bannerItems.add(imNew);
|
||||
bannerView.setBannerData(bannerItems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TreeNode;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.BottomPopupCard;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.TopicPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityDetailView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.widget.popupview.CommunityMorePopupView;
|
||||
|
||||
public class CommunityDetailView extends FrameLayout implements ICommunityDetailView {
|
||||
private CommunityBean communityBean;
|
||||
private CommunityTopicList communityTopicList;
|
||||
private ImageView coverImage;
|
||||
private TextView communityNameTv;
|
||||
private ImageView shareIcon;
|
||||
private ImageView moreIcon;
|
||||
|
||||
private TopicPresenter topicPresenter;
|
||||
private CommunityPresenter communityPresenter;
|
||||
private CommunityMorePopupView communityMorePopupView;
|
||||
|
||||
public CommunityDetailView(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityDetailView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityDetailView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public CommunityDetailView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
topicPresenter = new TopicPresenter();
|
||||
communityPresenter = new CommunityPresenter();
|
||||
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.community_detail_layout, this);
|
||||
coverImage = view.findViewById(R.id.cover_image);
|
||||
communityNameTv = view.findViewById(R.id.community_name);
|
||||
communityTopicList = view.findViewById(R.id.community_topic_list);
|
||||
communityTopicList.setPresenter(topicPresenter);
|
||||
shareIcon = view.findViewById(R.id.share_icon);
|
||||
moreIcon = view.findViewById(R.id.more_icon);
|
||||
|
||||
topicPresenter.setCommunityTopicList(communityTopicList);
|
||||
communityPresenter.setCommunityDetailView(this);
|
||||
communityPresenter.setCommunityEventListener();
|
||||
topicPresenter.setCommunityEventListener();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
communityTopicList.setOnTopicClickListener(new OnTopicClickListener() {
|
||||
@Override
|
||||
public void onClick(TopicBean topicBean) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_ID, topicBean.getID());
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_NAME, topicBean.getTopicName());
|
||||
bundle.putInt(TUIConstants.TUIChat.CHAT_TYPE, TopicBean.CHAT_TYPE_GROUP);
|
||||
bundle.putString(TUIConstants.TUIChat.DRAFT_TEXT, topicBean.getDraftText());
|
||||
TUICore.startActivity(TUIConstants.TUIChat.GROUP_CHAT_ACTIVITY_NAME, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCategoryLongClick(View view, TreeNode<ITopicBean> node) {
|
||||
if (communityBean.isOwner()) {
|
||||
showCategoryConfigPopup(view, node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
GlideEngine.loadImageSetDefault(coverImage, communityBean.getCoverUrl(), R.drawable.community_cover_default);
|
||||
communityNameTv.setText(communityBean.getCommunityName());
|
||||
|
||||
shareIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showSharePopup();
|
||||
}
|
||||
});
|
||||
|
||||
moreIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showMorePopup();
|
||||
}
|
||||
});
|
||||
|
||||
coverImage.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showMorePopup();
|
||||
}
|
||||
});
|
||||
|
||||
topicPresenter.getTopicList(communityBean.getGroupId());
|
||||
}
|
||||
|
||||
private void showCategoryConfigPopup(View view, TreeNode<ITopicBean> node) {
|
||||
Drawable drawable = view.getBackground();
|
||||
if (drawable != null) {
|
||||
drawable.setColorFilter(0xd9d9d9, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
View itemPop = LayoutInflater.from(getContext()).inflate(R.layout.community_member_list_delete_popup_layout, null);
|
||||
PopupWindow popupWindow = new PopupWindow(itemPop, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
if (drawable != null) {
|
||||
drawable.clearColorFilter();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TextView popText = itemPop.findViewById(R.id.pop_text);
|
||||
popText.setText(R.string.community_delete_topic_category);
|
||||
popText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new TUIKitDialog(getContext())
|
||||
.builder()
|
||||
.setTitle(getResources().getString(R.string.community_delete_topic_category))
|
||||
.setPositiveButton(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
communityPresenter.deleteCategory(communityBean.getGroupId(), node.getNodeName());
|
||||
topicPresenter.deleteCategory(node);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {}
|
||||
})
|
||||
.show();
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
int x = view.getWidth() / 2;
|
||||
int y = -view.getHeight() / 2;
|
||||
int popHeight = ScreenUtil.dip2px(45) * 3;
|
||||
if (y + popHeight + view.getY() + view.getHeight() > communityTopicList.getBottom()) {
|
||||
y = y - popHeight;
|
||||
}
|
||||
popupWindow.showAsDropDown(view, x, y, Gravity.CENTER);
|
||||
}
|
||||
|
||||
public void hideTopicList() {
|
||||
communityTopicList.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void setCommunityBean(CommunityBean communityBean) {
|
||||
if (this.communityBean == communityBean) {
|
||||
communityTopicList.setVisibility(VISIBLE);
|
||||
return;
|
||||
}
|
||||
this.communityBean = communityBean;
|
||||
topicPresenter.setCommunityBean(communityBean);
|
||||
communityPresenter.setCurrentCommunityBean(communityBean);
|
||||
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void showMorePopup() {
|
||||
if (communityMorePopupView != null && communityMorePopupView.isShown()) {
|
||||
return;
|
||||
}
|
||||
communityMorePopupView = new CommunityMorePopupView(getContext());
|
||||
communityMorePopupView.setCommunityBean(communityBean);
|
||||
BottomPopupCard bottomPopupCard = new BottomPopupCard((Activity) getContext(), communityMorePopupView);
|
||||
bottomPopupCard.show(this);
|
||||
}
|
||||
|
||||
private void showSharePopup() {
|
||||
ToastUtil.toastShortMessage(getResources().getString(R.string.community_coming_soon));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommunityChanged(CommunityBean communityBean) {
|
||||
this.communityBean = communityBean;
|
||||
topicPresenter.setCommunityBean(communityBean);
|
||||
communityPresenter.setCurrentCommunityBean(communityBean);
|
||||
communityNameTv.setText(communityBean.getCommunityName());
|
||||
GlideEngine.loadImageSetDefault(coverImage, communityBean.getCoverUrl(), R.drawable.community_cover_default);
|
||||
}
|
||||
|
||||
public interface OnTopicClickListener {
|
||||
void onClick(TopicBean topicBean);
|
||||
|
||||
void onCategoryLongClick(View view, TreeNode<ITopicBean> node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
|
||||
public class CommunityExperienceView extends FrameLayout {
|
||||
private TextView experienceName;
|
||||
private TextView experienceState;
|
||||
|
||||
public CommunityExperienceView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public CommunityExperienceView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public CommunityExperienceView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public CommunityExperienceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.community_experience_layout, this);
|
||||
experienceName = view.findViewById(R.id.experience_name);
|
||||
experienceState = view.findViewById(R.id.experience_state);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommunityExperienceView);
|
||||
String contentText = typedArray.getString(R.styleable.CommunityExperienceView_content_text);
|
||||
experienceName.setText(contentText);
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
public void setExperience(String experience) {
|
||||
experienceName.setText(experience);
|
||||
}
|
||||
|
||||
public void setState(boolean isExperienced) {
|
||||
if (isExperienced) {
|
||||
experienceState.setText(R.string.community_completed);
|
||||
experienceState.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityGroupIconList;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.TUICommunityFragment;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityGroupList extends RecyclerView implements ICommunityGroupIconList {
|
||||
private CommunityGroupIconListAdapter adapter;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private CommunityPresenter presenter;
|
||||
private TUICommunityFragment.OnCommunityClickListener onCommunityClickListener;
|
||||
|
||||
public CommunityGroupList(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityGroupList(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityGroupList(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
adapter = new CommunityGroupIconListAdapter();
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
addItemDecoration(new SpacingDecorate());
|
||||
setLayoutManager(layoutManager);
|
||||
setAdapter(adapter);
|
||||
}
|
||||
|
||||
public void setPresenter(CommunityPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
this.presenter.setGroupIconList(this);
|
||||
}
|
||||
|
||||
public void setOnCommunityClickListener(TUICommunityFragment.OnCommunityClickListener onCommunityClickListener) {
|
||||
this.onCommunityClickListener = onCommunityClickListener;
|
||||
adapter.setOnCommunityClickListener(onCommunityClickListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinedCommunityChanged(List<CommunityBean> communityBeanList) {
|
||||
adapter.setData(communityBeanList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeChanged(int index, int count) {
|
||||
adapter.notifyItemRangeChanged(index, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemInserted(int index) {
|
||||
adapter.notifyItemInserted(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChanged(int index) {
|
||||
adapter.notifyItemChanged(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRemoved(int index) {
|
||||
adapter.notifyItemRemoved(index);
|
||||
}
|
||||
|
||||
public void setSelectedPosition(int position) {
|
||||
if (adapter != null) {
|
||||
adapter.setSelectedPosition(position);
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSelected() {
|
||||
if (adapter != null) {
|
||||
int position = adapter.getSelectedPosition();
|
||||
adapter.setSelectedPosition(-1);
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
static class SpacingDecorate extends ItemDecoration {
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull State state) {
|
||||
outRect.top = ScreenUtil.dip2px(20);
|
||||
}
|
||||
}
|
||||
|
||||
static class CommunityGroupIconListAdapter extends Adapter<CommunityGroupIconListAdapter.CommunityGroupIconViewHolder> {
|
||||
private List<CommunityBean> data;
|
||||
private TUICommunityFragment.OnCommunityClickListener onCommunityClickListener;
|
||||
private int selectedPosition = -1;
|
||||
|
||||
public void setData(List<CommunityBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setOnCommunityClickListener(TUICommunityFragment.OnCommunityClickListener onCommunityClickListener) {
|
||||
this.onCommunityClickListener = onCommunityClickListener;
|
||||
}
|
||||
|
||||
public void setSelectedPosition(int selectedPosition) {
|
||||
this.selectedPosition = selectedPosition;
|
||||
}
|
||||
|
||||
public int getSelectedPosition() {
|
||||
return selectedPosition;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CommunityGroupIconViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_group_icon_item_layout, parent, false);
|
||||
return new CommunityGroupIconViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CommunityGroupIconViewHolder holder, int position) {
|
||||
CommunityBean communityBean = data.get(position);
|
||||
GlideEngine.loadImageSetDefault(holder.imageView, communityBean.getGroupFaceUrl(),
|
||||
TUIThemeManager.getAttrResId(holder.itemView.getContext(), com.tencent.qcloud.tuikit.timcommon.R.attr.core_default_group_icon_community));
|
||||
if (position == selectedPosition) {
|
||||
holder.selectedBorder.setVisibility(VISIBLE);
|
||||
} else {
|
||||
holder.selectedBorder.setVisibility(GONE);
|
||||
}
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onCommunityClickListener != null) {
|
||||
onCommunityClickListener.onClick(communityBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return data.size();
|
||||
}
|
||||
|
||||
static class CommunityGroupIconViewHolder extends ViewHolder {
|
||||
private final ImageView imageView;
|
||||
private final View selectedBorder;
|
||||
|
||||
public CommunityGroupIconViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.face_url);
|
||||
selectedBorder = itemView.findViewById(R.id.selected_border_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
|
||||
public class CommunityIndexLinkView extends FrameLayout {
|
||||
private TextView indexTv;
|
||||
private TextView linkTv;
|
||||
|
||||
public CommunityIndexLinkView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public CommunityIndexLinkView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public CommunityIndexLinkView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public CommunityIndexLinkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.community_index_link_layout, this);
|
||||
indexTv = view.findViewById(R.id.index_tv);
|
||||
linkTv = view.findViewById(R.id.link_tv);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommunityIndexLinkView);
|
||||
String contentText = typedArray.getString(R.styleable.CommunityIndexLinkView_content_link_text);
|
||||
int index = typedArray.getInteger(R.styleable.CommunityIndexLinkView_content_index, 0);
|
||||
String link = typedArray.getString(R.styleable.CommunityIndexLinkView_content_link);
|
||||
indexTv.setText(index + "");
|
||||
linkTv.setText(contentText);
|
||||
linkTv.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), link);
|
||||
}
|
||||
});
|
||||
linkTv.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
typedArray.recycle();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.CustomLinearLayoutManager;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.util.ThreadUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityMemberActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityMemberList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityMemberList extends LinearLayout implements ICommunityMemberList {
|
||||
private TitleBarLayout titleBar;
|
||||
private GroupMemberAdapter adapter;
|
||||
private CommunityBean communityBean;
|
||||
private RecyclerView recyclerView;
|
||||
private boolean isSelectMode;
|
||||
private String title;
|
||||
private List<CommunityMemberBean> communityMemberBeans;
|
||||
|
||||
private CommunityPresenter presenter;
|
||||
private long nextSeq = 0;
|
||||
|
||||
private ICommunityMemberActivity communityMemberActivity;
|
||||
|
||||
private MemberListListener memberListListener;
|
||||
|
||||
public CommunityMemberList(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityMemberList(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityMemberList(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.community_member_layout, this);
|
||||
titleBar = findViewById(R.id.group_member_title_bar);
|
||||
titleBar.setTitle(getContext().getString(R.string.community_invite), ITitleBarLayout.Position.RIGHT);
|
||||
titleBar.getRightIcon().setVisibility(GONE);
|
||||
titleBar.setOnRightClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startInviteGroup();
|
||||
}
|
||||
});
|
||||
adapter = new GroupMemberAdapter();
|
||||
recyclerView = findViewById(R.id.group_all_members);
|
||||
recyclerView.setLayoutManager(new CustomLinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
if (layoutManager == null) {
|
||||
return;
|
||||
}
|
||||
int lastPosition = layoutManager.findLastCompletelyVisibleItemPosition();
|
||||
if (adapter != null && nextSeq != 0) {
|
||||
if (lastPosition == adapter.getItemCount() - 1) {
|
||||
if (communityBean != null) {
|
||||
presenter.loadCommunityMembers(communityBean.getGroupId(), nextSeq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMemberList() {
|
||||
presenter.loadCommunityMembers(communityBean.getGroupId(), 0);
|
||||
}
|
||||
|
||||
public void setCommunityBean(CommunityBean communityBean) {
|
||||
this.communityBean = communityBean;
|
||||
}
|
||||
|
||||
public List<CommunityMemberBean> getCommunityMemberBeans() {
|
||||
return communityMemberBeans;
|
||||
}
|
||||
|
||||
public TitleBarLayout getTitleBar() {
|
||||
return titleBar;
|
||||
}
|
||||
|
||||
public void setSelectMode(boolean selectMode) {
|
||||
isSelectMode = selectMode;
|
||||
if (isSelectMode) {
|
||||
titleBar.setTitle(getContext().getString(com.tencent.qcloud.tuicore.R.string.sure), ITitleBarLayout.Position.RIGHT);
|
||||
titleBar.getRightGroup().setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (memberListListener != null) {
|
||||
memberListListener.setSelectedMember(adapter.getSelectedMember());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
adapter.setSelectMode(isSelectMode);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
titleBar.setTitle(title, ITitleBarLayout.Position.MIDDLE);
|
||||
}
|
||||
|
||||
public void onGroupInfoChanged(CommunityBean communityBean) {
|
||||
this.communityBean = communityBean;
|
||||
presenter.setCurrentCommunityBean(communityBean);
|
||||
adapter.setCommunityBean(communityBean);
|
||||
}
|
||||
|
||||
private void startInviteGroup() {
|
||||
if (communityBean == null) {
|
||||
return;
|
||||
}
|
||||
if (communityMemberActivity != null) {
|
||||
communityMemberActivity.onAddCommunityMember();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCommunityMemberListener(ICommunityMemberActivity listener) {
|
||||
this.communityMemberActivity = listener;
|
||||
}
|
||||
|
||||
public void setPresenter(CommunityPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
adapter.setPresenter(presenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberListChanged(List<CommunityMemberBean> memberBeanList, long nextSeq) {
|
||||
this.communityMemberBeans = memberBeanList;
|
||||
this.nextSeq = nextSeq;
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setGroupMemberListener(MemberListListener listener) {
|
||||
this.memberListListener = listener;
|
||||
}
|
||||
|
||||
public interface MemberListListener {
|
||||
void setSelectedMember(ArrayList<String> members);
|
||||
}
|
||||
|
||||
public class GroupMemberAdapter extends RecyclerView.Adapter<GroupMemberAdapter.GroupMemberViewHolder> {
|
||||
private CommunityPresenter presenter;
|
||||
private boolean isSelectMode;
|
||||
|
||||
private ArrayList<String> selectedMember = new ArrayList<>();
|
||||
|
||||
public void setSelectMode(boolean selectMode) {
|
||||
isSelectMode = selectMode;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSelectedMember() {
|
||||
return selectedMember;
|
||||
}
|
||||
|
||||
public void setPresenter(CommunityPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GroupMemberViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_member_list_item, parent, false);
|
||||
return new GroupMemberViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GroupMemberViewHolder holder, int position) {
|
||||
final CommunityMemberBean memberBean = communityMemberBeans.get(position);
|
||||
GlideEngine.loadImage(holder.memberIcon, memberBean.getAvatar());
|
||||
holder.memberName.setText(memberBean.getDisplayName());
|
||||
if (isSelectMode) {
|
||||
holder.checkBox.setVisibility(View.VISIBLE);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
holder.checkBox.setChecked(!holder.checkBox.isChecked());
|
||||
if (holder.checkBox.isChecked()) {
|
||||
selectedMember.add(memberBean.getAccount());
|
||||
} else {
|
||||
selectedMember.remove(memberBean.getAccount());
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (!communityBean.isOwner()) {
|
||||
return true;
|
||||
}
|
||||
Drawable drawable = view.getBackground();
|
||||
if (drawable != null) {
|
||||
drawable.setColorFilter(0xd9d9d9, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
View itemPop = LayoutInflater.from(getContext()).inflate(R.layout.community_member_list_delete_popup_layout, null);
|
||||
PopupWindow popupWindow = new PopupWindow(itemPop, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
if (drawable != null) {
|
||||
drawable.clearColorFilter();
|
||||
}
|
||||
}
|
||||
});
|
||||
TextView popText = itemPop.findViewById(R.id.pop_text);
|
||||
popText.setText(R.string.community_remove_member);
|
||||
popText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
List<String> dels = new ArrayList<>();
|
||||
dels.add(memberBean.getAccount());
|
||||
if (presenter == null) {
|
||||
return;
|
||||
}
|
||||
presenter.removeGroupMembers(communityBean.getGroupId(), dels, new IUIKitCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> data) {
|
||||
communityMemberBeans.remove(memberBean);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastLongMessage(getResources().getString(R.string.community_remove_fail_tip) + ":errCode=" + errCode);
|
||||
}
|
||||
});
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
int x = view.getWidth() / 2;
|
||||
int y = -view.getHeight() / 2;
|
||||
int popHeight = ScreenUtil.dip2px(45) * 3;
|
||||
if (y + popHeight + view.getY() + view.getHeight() > CommunityMemberList.this.getBottom()) {
|
||||
y = y - popHeight;
|
||||
}
|
||||
popupWindow.showAsDropDown(view, x, y, Gravity.CENTER);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TUIConstants.TUIChat.CHAT_ID, memberBean.getAccount());
|
||||
TUICore.startActivity("FriendProfileActivity", bundle);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (communityMemberBeans == null) {
|
||||
return 0;
|
||||
}
|
||||
return communityMemberBeans.size();
|
||||
}
|
||||
|
||||
public void setCommunityBean(CommunityBean communityBean) {
|
||||
if (communityBean != null) {
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected class GroupMemberViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView memberIcon;
|
||||
private final TextView memberName;
|
||||
private final CheckBox checkBox;
|
||||
|
||||
public GroupMemberViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
checkBox = itemView.findViewById(R.id.group_member_check_box);
|
||||
memberIcon = itemView.findViewById(R.id.group_member_icon);
|
||||
memberName = itemView.findViewById(R.id.group_member_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.util.SPUtils;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.banner.BannerView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityExperiencePresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunitySelfView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityUtil;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.TUICommunityLog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunitySelfView extends FrameLayout implements ICommunitySelfView {
|
||||
private BannerView bannerView;
|
||||
private CommunityExperienceView createCommunityExperience;
|
||||
private CommunityExperienceView addCommunityExperience;
|
||||
private CommunityExperienceView sendMessageInTopic;
|
||||
private CommunityExperienceView replyMessageInTopic;
|
||||
private CommunityExperienceView disbandCommunityExperience;
|
||||
private CommunityExperienceView createTopicExperience;
|
||||
private CommunityExperienceView deleteTopicExperience;
|
||||
private TextView experienceMoreButton;
|
||||
private CommunityExperiencePresenter presenter;
|
||||
|
||||
public CommunitySelfView(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunitySelfView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunitySelfView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public CommunitySelfView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
presenter = new CommunityExperiencePresenter();
|
||||
presenter.setCommunitySelfView(this);
|
||||
View view = LayoutInflater.from(getContext()).inflate(R.layout.community_self_frame, this);
|
||||
bannerView = view.findViewById(R.id.banner_view);
|
||||
List<BannerView.BannerItem> bannerItems = new ArrayList<>();
|
||||
BannerView.BannerItem communityIntroduction = new BannerView.BannerItem();
|
||||
communityIntroduction.setImageUri(R.drawable.community_introduction);
|
||||
communityIntroduction.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), CommunityConstants.COMMUNITY_INTRODUCTION);
|
||||
}
|
||||
});
|
||||
bannerItems.add(communityIntroduction);
|
||||
BannerView.BannerItem imNew = new BannerView.BannerItem();
|
||||
imNew.setImageUri(R.drawable.community_im_new);
|
||||
imNew.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), CommunityConstants.IM_NEW_BUYING);
|
||||
}
|
||||
});
|
||||
bannerItems.add(imNew);
|
||||
bannerView.setBannerData(bannerItems);
|
||||
if (!TextUtils.equals(TUIThemeManager.getInstance().getCurrentLanguage(), TUIThemeManager.LANGUAGE_ZH_CN)) {
|
||||
bannerView.setVisibility(GONE);
|
||||
}
|
||||
createCommunityExperience = view.findViewById(R.id.create_community_experience);
|
||||
addCommunityExperience = view.findViewById(R.id.add_community_experience);
|
||||
sendMessageInTopic = view.findViewById(R.id.send_message_experience);
|
||||
replyMessageInTopic = view.findViewById(R.id.reply_message_experience);
|
||||
disbandCommunityExperience = view.findViewById(R.id.disband_community_experience);
|
||||
createTopicExperience = view.findViewById(R.id.create_topic_experience);
|
||||
deleteTopicExperience = view.findViewById(R.id.delete_topic_experience);
|
||||
experienceMoreButton = view.findViewById(R.id.experience_more_button);
|
||||
|
||||
experienceMoreButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CommunityUtil.openWebUrl(getContext(), CommunityConstants.EXPERIENCE_MORE_DEMOS);
|
||||
}
|
||||
});
|
||||
|
||||
setExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience() {
|
||||
Gson gson = new Gson();
|
||||
String experience = SPUtils.getInstance(CommunityConstants.COMMUNITY_SP_NAME).getString(CommunityConstants.COMMUNITY_EXPERIENCE_SP_KEY);
|
||||
Map<String, Boolean> experienceMap = null;
|
||||
try {
|
||||
experienceMap = gson.fromJson(experience, TypeToken.getParameterized(Map.class, String.class, Boolean.class).getType());
|
||||
} catch (JsonParseException e) {
|
||||
TUICommunityLog.e("CommunitySelfView", "setExperience " + e.getMessage());
|
||||
}
|
||||
if (experienceMap != null) {
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_CREATE_COMMUNITY_KEY))) {
|
||||
createCommunityExperience.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_ADD_COMMUNITY_KEY))) {
|
||||
addCommunityExperience.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_SEND_MESSAGE_IN_TOPIC_KEY))) {
|
||||
sendMessageInTopic.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_REPLY_MESSAGE_IN_TOPIC_KEY))) {
|
||||
replyMessageInTopic.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_DISBAND_COMMUNITY_KEY))) {
|
||||
disbandCommunityExperience.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_CREATE_TOPIC_KEY))) {
|
||||
createTopicExperience.setState(true);
|
||||
}
|
||||
if (Boolean.TRUE.equals(experienceMap.get(CommunityConstants.COMMUNITY_EXPERIENCE_DELETE_TOPIC_KEY))) {
|
||||
deleteTopicExperience.setState(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.imsdk.v2.V2TIMGroupAtInfo;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.UnreadCountTextView;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicFoldBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TreeNode;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.interfaces.ITopicBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.TopicPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.interfaces.ICommunityTopicList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommunityTopicList extends RecyclerView implements ICommunityTopicList {
|
||||
private LinearLayoutManager layoutManager;
|
||||
private TopicAdapter topicAdapter;
|
||||
private TopicPresenter presenter;
|
||||
private CommunityDetailView.OnTopicClickListener onTopicClickListener;
|
||||
|
||||
public CommunityTopicList(@NonNull Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityTopicList(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CommunityTopicList(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
topicAdapter = new TopicAdapter();
|
||||
setLayoutManager(layoutManager);
|
||||
setAdapter(topicAdapter);
|
||||
}
|
||||
|
||||
public void setPresenter(TopicPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
topicAdapter.setPresenter(presenter);
|
||||
}
|
||||
|
||||
public void setOnTopicClickListener(CommunityDetailView.OnTopicClickListener onTopicClickListener) {
|
||||
this.onTopicClickListener = onTopicClickListener;
|
||||
topicAdapter.setOnTopicClickListener(onTopicClickListener);
|
||||
}
|
||||
|
||||
public static class TopicAdapter extends RecyclerView.Adapter {
|
||||
private static final int VIEW_TYPE_TITLE = 1;
|
||||
private static final int VIEW_TYPE_TOPIC = 2;
|
||||
|
||||
private TopicPresenter presenter;
|
||||
|
||||
private List<TreeNode<ITopicBean>> data;
|
||||
private CommunityDetailView.OnTopicClickListener onTopicClickListener;
|
||||
|
||||
public void setData(List<TreeNode<ITopicBean>> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setPresenter(TopicPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
}
|
||||
|
||||
public void setOnTopicClickListener(CommunityDetailView.OnTopicClickListener onTopicClickListener) {
|
||||
this.onTopicClickListener = onTopicClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == VIEW_TYPE_TITLE) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_topic_list_title_layout, parent, false);
|
||||
return new TopicCategoryViewHolder(view);
|
||||
} else {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.community_topic_list_item_layout, parent, false);
|
||||
return new TopicViewHolder(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
|
||||
if (viewHolder instanceof TopicViewHolder) {
|
||||
TopicViewHolder holder = (TopicViewHolder) viewHolder;
|
||||
TreeNode<ITopicBean> node = data.get(position);
|
||||
TopicBean topicBean = (TopicBean) node.getData();
|
||||
if (node.isCollapse()) {
|
||||
holder.itemView.setVisibility(GONE);
|
||||
ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
|
||||
layoutParams.height = 0;
|
||||
holder.itemView.setLayoutParams(layoutParams);
|
||||
} else {
|
||||
ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
|
||||
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
holder.itemView.setLayoutParams(layoutParams);
|
||||
holder.itemView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (topicBean.getType() == TopicBean.TOPIC_TYPE_TEXT) {
|
||||
GlideEngine.loadImage(holder.topicFace, R.drawable.community_text_topic_icon);
|
||||
} else {
|
||||
GlideEngine.loadImageSetDefault(holder.topicFace, topicBean.getFaceUrl(), R.drawable.community_text_topic_icon);
|
||||
}
|
||||
|
||||
holder.topicTitle.setText(topicBean.getTopicName());
|
||||
holder.lastMsgAbstract.setText(topicBean.getLastMsgAbstract());
|
||||
if (topicBean.getUnreadCount() != 0) {
|
||||
holder.topicUnread.setVisibility(VISIBLE);
|
||||
holder.topicUnread.setText(topicBean.getUnreadCount() + "");
|
||||
} else {
|
||||
holder.topicUnread.setVisibility(GONE);
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onTopicClickListener != null) {
|
||||
onTopicClickListener.onClick(topicBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (topicBean.getAtType() == V2TIMGroupAtInfo.TIM_AT_ME) {
|
||||
holder.atMeTv.setVisibility(View.VISIBLE);
|
||||
} else if (topicBean.getAtType() == V2TIMGroupAtInfo.TIM_AT_ALL) {
|
||||
holder.atAllTv.setVisibility(View.VISIBLE);
|
||||
} else if (topicBean.getAtType() == V2TIMGroupAtInfo.TIM_AT_ALL_AT_ME) {
|
||||
holder.atAllTv.setVisibility(View.VISIBLE);
|
||||
holder.atMeTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.atAllTv.setVisibility(View.GONE);
|
||||
holder.atMeTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.draftTv.setVisibility(View.GONE);
|
||||
if (!TextUtils.isEmpty(topicBean.getDraftText())) {
|
||||
holder.draftTv.setVisibility(View.VISIBLE);
|
||||
holder.lastMsgAbstract.setText(topicBean.getDraftText());
|
||||
}
|
||||
} else if (viewHolder instanceof TopicCategoryViewHolder) {
|
||||
TopicCategoryViewHolder holder = (TopicCategoryViewHolder) viewHolder;
|
||||
TreeNode<ITopicBean> node = data.get(position);
|
||||
TopicFoldBean foldBean = (TopicFoldBean) node.getData();
|
||||
if (node.isCollapse()) {
|
||||
holder.indicatorImage.setImageResource(R.drawable.community_list_collapse_icon);
|
||||
} else {
|
||||
holder.indicatorImage.setImageResource(R.drawable.community_list_expand_icon);
|
||||
}
|
||||
if (TextUtils.isEmpty(foldBean.getFoldName())) {
|
||||
holder.topicCategory.setText(R.string.community_no_category);
|
||||
} else {
|
||||
holder.topicCategory.setText(foldBean.getFoldName());
|
||||
}
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
changeCollapseStatus(node);
|
||||
}
|
||||
});
|
||||
holder.itemView.setOnLongClickListener(new OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (onTopicClickListener != null) {
|
||||
onTopicClickListener.onCategoryLongClick(v, node);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void changeCollapseStatus(TreeNode<ITopicBean> node) {
|
||||
presenter.changeTreeNodeCollapseStatus(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (data == null) {
|
||||
return 0;
|
||||
}
|
||||
return data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
ITopicBean topicBean = data.get(position).getData();
|
||||
if (topicBean instanceof TopicFoldBean) {
|
||||
return VIEW_TYPE_TITLE;
|
||||
} else {
|
||||
return VIEW_TYPE_TOPIC;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TopicViewHolder extends RecyclerView.ViewHolder {
|
||||
private final UnreadCountTextView topicUnread;
|
||||
private final TextView topicTitle;
|
||||
private final TextView lastMsgAbstract;
|
||||
private final ImageView topicFace;
|
||||
private final TextView atAllTv;
|
||||
private final TextView atMeTv;
|
||||
private final TextView draftTv;
|
||||
|
||||
public TopicViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
topicFace = itemView.findViewById(R.id.topic_face);
|
||||
topicTitle = itemView.findViewById(R.id.topic_title);
|
||||
lastMsgAbstract = itemView.findViewById(R.id.topic_last_msg);
|
||||
topicUnread = itemView.findViewById(R.id.topic_unread);
|
||||
atAllTv = itemView.findViewById(R.id.topic_at_all);
|
||||
atMeTv = itemView.findViewById(R.id.topic_at_me);
|
||||
draftTv = itemView.findViewById(R.id.topic_draft);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TopicCategoryViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView indicatorImage;
|
||||
private final TextView topicCategory;
|
||||
|
||||
public TopicCategoryViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
indicatorImage = itemView.findViewById(R.id.indicator_image);
|
||||
topicCategory = itemView.findViewById(R.id.topic_category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTopicListChanged(List<TreeNode<ITopicBean>> newData, List<TreeNode<ITopicBean>> oldData) {
|
||||
topicAdapter.setData(newData);
|
||||
topicAdapter.notifyDataSetChanged();
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.ui.widget.popupview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
||||
import com.tencent.qcloud.tuicore.util.ToastUtil;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.dialog.TUIKitDialog;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.R;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.IPopupCard;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.component.bottompopupcard.IPopupView;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.presenter.CommunityPresenter;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.CommunityMemberActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.ui.page.CommunitySettingsActivity;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants;
|
||||
|
||||
public class CommunityMorePopupView extends FrameLayout implements IPopupView {
|
||||
private View contentView;
|
||||
private CommunityBean communityBean;
|
||||
|
||||
private ImageView groupFace;
|
||||
private TextView communityName;
|
||||
private TextView communityID;
|
||||
private TextView communityIntroduction;
|
||||
private View userList;
|
||||
private View shareCommunity;
|
||||
private View settings;
|
||||
private TextView exitButton;
|
||||
private TUIKitDialog exitDialog;
|
||||
|
||||
private IPopupCard popupCard;
|
||||
private CommunityPresenter communityPresenter;
|
||||
|
||||
public CommunityMorePopupView(Context context) {
|
||||
super(context);
|
||||
init(context, null);
|
||||
}
|
||||
|
||||
public CommunityMorePopupView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
public CommunityMorePopupView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public CommunityMorePopupView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attributeSet) {
|
||||
communityPresenter = new CommunityPresenter();
|
||||
contentView = LayoutInflater.from(context).inflate(R.layout.community_more_popup_layout, this);
|
||||
groupFace = contentView.findViewById(R.id.community_group_face);
|
||||
communityName = contentView.findViewById(R.id.community_name_tv);
|
||||
communityID = contentView.findViewById(R.id.community_group_id_tv);
|
||||
communityIntroduction = contentView.findViewById(R.id.community_introduction);
|
||||
userList = contentView.findViewById(R.id.user_list);
|
||||
shareCommunity = contentView.findViewById(R.id.share_community);
|
||||
settings = contentView.findViewById(R.id.settings);
|
||||
exitButton = contentView.findViewById(R.id.exit_community_button);
|
||||
}
|
||||
|
||||
public void setCommunityBean(CommunityBean communityBean) {
|
||||
this.communityBean = communityBean;
|
||||
GlideEngine.loadImageSetDefault(groupFace, communityBean.getGroupFaceUrl(),
|
||||
TUIThemeManager.getAttrResId(getContext(), com.tencent.qcloud.tuikit.timcommon.R.attr.core_default_group_icon_community));
|
||||
communityName.setText(communityBean.getCommunityName());
|
||||
communityID.setText(communityBean.getGroupId());
|
||||
|
||||
if (TextUtils.isEmpty(communityBean.getIntroduction())) {
|
||||
communityIntroduction.setText(R.string.community_settings_not_set);
|
||||
communityIntroduction.setTextColor(getResources().getColor(R.color.community_setting_linear_content_disable_color));
|
||||
} else {
|
||||
communityIntroduction.setText(communityBean.getIntroduction());
|
||||
communityIntroduction.setTextColor(getResources().getColor(R.color.community_more_introduction_disable_color));
|
||||
}
|
||||
|
||||
userList.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getContext(), CommunityMemberActivity.class);
|
||||
intent.putExtra(CommunityConstants.COMMUNITY_BEAN, communityBean);
|
||||
intent.putExtra(CommunityConstants.TITLE, getResources().getString(R.string.community_user_list));
|
||||
getContext().startActivity(intent);
|
||||
dismissPopup();
|
||||
}
|
||||
});
|
||||
|
||||
shareCommunity.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToastUtil.toastShortMessage(getResources().getString(R.string.community_coming_soon));
|
||||
}
|
||||
});
|
||||
|
||||
settings.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getContext(), CommunitySettingsActivity.class);
|
||||
intent.putExtra(CommunityConstants.COMMUNITY_ID, communityBean.getGroupId());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
dismissPopup();
|
||||
}
|
||||
});
|
||||
|
||||
if (communityBean.isOwner()) {
|
||||
exitButton.setVisibility(GONE);
|
||||
}
|
||||
exitButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (exitDialog == null) {
|
||||
exitDialog = new TUIKitDialog(getContext())
|
||||
.builder()
|
||||
.setTitle(getResources().getString(R.string.community_exit_community))
|
||||
.setCancelOutside(true)
|
||||
.setPositiveButton(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
exitCommunity();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {}
|
||||
});
|
||||
}
|
||||
exitDialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void exitCommunity() {
|
||||
communityPresenter.quitCommunity(communityBean.getGroupId(), new IUIKitCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void data) {
|
||||
dismissPopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String module, int errCode, String errMsg) {
|
||||
ToastUtil.toastShortMessage("quit group error, code=" + errCode + " errMsg=" + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void dismissPopup() {
|
||||
if (popupCard != null) {
|
||||
popupCard.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPopupCard(IPopupCard popupCard) {
|
||||
this.popupCard = popupCard;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.utils;
|
||||
|
||||
public class CommunityConstants {
|
||||
public static final String COVER_URL = "https://im.sdk.qcloud.com/download/tuikit-resource/community-cover/community_cover_%s.png";
|
||||
public static final String DEFAULT_COVER_URL = "https://im.sdk.qcloud.com/download/tuikit-resource/community-cover/community_cover_default.png";
|
||||
public static final String GROUP_FACE_URL = "https://im.sdk.qcloud.com/download/tuikit-resource/group-avatar/group_avatar_%s.png";
|
||||
public static final String DEFAULT_GROUP_FACE_URL = "https://im.sdk.qcloud.com/download/tuikit-resource/group-avatar/group_avatar_default.png";
|
||||
|
||||
public static final String COMMUNITY_INTRODUCTION = "https://cloud.tencent.com/document/product/269/75979";
|
||||
public static final String IM_NEW_BUYING = "https://cloud.tencent.com/act/pro/imnew?from=17971";
|
||||
public static final String EXPERIENCE_MORE_DEMOS = "https://cloud.tencent.com/document/product/269/36852";
|
||||
|
||||
public static final int COVER_COUNT = 12;
|
||||
public static final int GROUP_FACE_COUNT = 24;
|
||||
|
||||
public static final String TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY = "type";
|
||||
public static final String TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY = "category";
|
||||
|
||||
// Go to the [console](https://console.cloud.tencent.com/im) (Feature Configuration -> Custom Group Field) to set the key value of the custom group field..
|
||||
public static final String COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY = "topic_category";
|
||||
public static final String COMMUNITY_CUSTOM_INFO_COVER_KEY = "group_cover_url";
|
||||
|
||||
public static final String COMMUNITY_BEAN = "communityBean";
|
||||
public static final String COMMUNITY_ID = "communityID";
|
||||
public static final String IS_SELECT_MODE = "isSelectMode";
|
||||
|
||||
public static final String TITLE = "title";
|
||||
public static final String LIST = "list";
|
||||
public static final String LIMIT = "limit";
|
||||
|
||||
public static final String COMMUNITY_EXPERIENCE_SP_KEY = "communityExperience";
|
||||
public static final String COMMUNITY_COLLAPSE_SP_KEY = "communityCollapse";
|
||||
public static final String COMMUNITY_SP_NAME = "TUICommunity_Settings";
|
||||
|
||||
public static final String COMMUNITY_EXPERIENCE_CREATE_COMMUNITY_KEY = "createCommunityExperience";
|
||||
public static final String COMMUNITY_EXPERIENCE_ADD_COMMUNITY_KEY = "addCommunityExperience";
|
||||
public static final String COMMUNITY_EXPERIENCE_SEND_MESSAGE_IN_TOPIC_KEY = "sendMessageInTopic";
|
||||
public static final String COMMUNITY_EXPERIENCE_REPLY_MESSAGE_IN_TOPIC_KEY = "replyMessageInTopic";
|
||||
public static final String COMMUNITY_EXPERIENCE_DISBAND_COMMUNITY_KEY = "disbandCommunityExperience";
|
||||
public static final String COMMUNITY_EXPERIENCE_CREATE_TOPIC_KEY = "createTopicExperience";
|
||||
public static final String COMMUNITY_EXPERIENCE_DELETE_TOPIC_KEY = "deleteTopicExperience";
|
||||
|
||||
public static final int COMMUNITY_NETWORK_STATE_CONNECTED = 1;
|
||||
public static final int COMMUNITY_NETWORK_STATE_CONNECT_FAILED = 2;
|
||||
public static final int COMMUNITY_NETWORK_STATE_CONNECTING = 3;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.utils;
|
||||
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.COMMUNITY_CUSTOM_INFO_COVER_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY;
|
||||
import static com.tencent.qcloud.tuikit.tuicommunity.utils.CommunityConstants.TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberFullInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMTopicInfo;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.CommunityMemberBean;
|
||||
import com.tencent.qcloud.tuikit.tuicommunity.bean.TopicBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommunityParser {
|
||||
private static final String TAG = "CommunityParser";
|
||||
|
||||
public static CommunityBean parseCommunityGroup(V2TIMGroupInfo v2TIMGroupInfo) {
|
||||
if (v2TIMGroupInfo == null) {
|
||||
return null;
|
||||
}
|
||||
CommunityBean communityBean = new CommunityBean();
|
||||
|
||||
communityBean.setGroupId(v2TIMGroupInfo.getGroupID());
|
||||
communityBean.setGroupFaceUrl(v2TIMGroupInfo.getFaceUrl());
|
||||
communityBean.setCommunityName(v2TIMGroupInfo.getGroupName());
|
||||
communityBean.setIntroduction(v2TIMGroupInfo.getIntroduction());
|
||||
communityBean.setRole(v2TIMGroupInfo.getRole());
|
||||
communityBean.setOwner(v2TIMGroupInfo.getOwner());
|
||||
communityBean.setLastMessageTime(v2TIMGroupInfo.getLastMessageTime());
|
||||
communityBean.setCreateTime(v2TIMGroupInfo.getCreateTime());
|
||||
communityBean.setJoinTime(v2TIMGroupInfo.getJoinTime());
|
||||
communityBean.setLastInfoTime(v2TIMGroupInfo.getLastInfoTime());
|
||||
|
||||
Map<String, byte[]> customInfo = v2TIMGroupInfo.getCustomInfo();
|
||||
byte[] coverUrlBytes = customInfo.get(COMMUNITY_CUSTOM_INFO_COVER_KEY);
|
||||
byte[] topicCategoryBytes = customInfo.get(COMMUNITY_CUSTOM_INFO_TOPIC_CATEGORY_KEY);
|
||||
String coverUrlStr = null;
|
||||
if (coverUrlBytes != null) {
|
||||
coverUrlStr = new String(coverUrlBytes);
|
||||
}
|
||||
List<String> topicCategories = null;
|
||||
if (topicCategoryBytes != null) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
topicCategories = gson.fromJson(new String(topicCategoryBytes), List.class);
|
||||
} catch (JsonParseException e) {
|
||||
TUICommunityLog.e(TAG, "parseCommunityGroup " + e.getMessage());
|
||||
}
|
||||
}
|
||||
communityBean.setTopicCategories(topicCategories);
|
||||
communityBean.setCoverUrl(coverUrlStr);
|
||||
return communityBean;
|
||||
}
|
||||
|
||||
public static List<CommunityBean> parseCommunityGroup(List<V2TIMGroupInfo> v2TIMGroupInfoList) {
|
||||
List<CommunityBean> communityBeanList = new ArrayList<>();
|
||||
if (v2TIMGroupInfoList == null || v2TIMGroupInfoList.isEmpty()) {
|
||||
return communityBeanList;
|
||||
}
|
||||
|
||||
for (V2TIMGroupInfo v2TIMGroupInfo : v2TIMGroupInfoList) {
|
||||
CommunityBean communityBean = parseCommunityGroup(v2TIMGroupInfo);
|
||||
if (communityBean != null) {
|
||||
communityBeanList.add(communityBean);
|
||||
}
|
||||
}
|
||||
return communityBeanList;
|
||||
}
|
||||
|
||||
public static TopicBean parseTopicBean(V2TIMTopicInfo v2TIMTopicInfo) {
|
||||
if (v2TIMTopicInfo == null) {
|
||||
return null;
|
||||
}
|
||||
TopicBean topicBean = new TopicBean();
|
||||
topicBean.setID(v2TIMTopicInfo.getTopicID());
|
||||
topicBean.setFaceUrl(v2TIMTopicInfo.getTopicFaceUrl());
|
||||
topicBean.setTopicName(v2TIMTopicInfo.getTopicName());
|
||||
topicBean.setDraftText(v2TIMTopicInfo.getDraftText());
|
||||
topicBean.setLastMessage(v2TIMTopicInfo.getLastMessage());
|
||||
topicBean.setUnreadCount(v2TIMTopicInfo.getUnreadCount());
|
||||
topicBean.setV2TIMTopicInfo(v2TIMTopicInfo);
|
||||
topicBean.setAllMute(v2TIMTopicInfo.isAllMute());
|
||||
|
||||
String customString = v2TIMTopicInfo.getCustomString();
|
||||
if (!TextUtils.isEmpty(customString)) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
Map<String, Object> map = gson.fromJson(customString, TypeToken.getParameterized(Map.class, String.class, Object.class).getType());
|
||||
if (map != null) {
|
||||
Object category = map.get(TOPIC_CUSTOM_STRING_TOPIC_CATEGORY_KEY);
|
||||
if (category instanceof String) {
|
||||
topicBean.setCategory((String) category);
|
||||
}
|
||||
Object type = map.get(TOPIC_CUSTOM_STRING_TOPIC_TYPE_KEY);
|
||||
if (type instanceof Double) {
|
||||
topicBean.setType(((Double) type).intValue());
|
||||
}
|
||||
}
|
||||
} catch (JsonParseException e) {
|
||||
TUICommunityLog.e(TAG, "parseTopicBean json exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return topicBean;
|
||||
}
|
||||
|
||||
public static List<TopicBean> parseTopicBeanList(List<V2TIMTopicInfo> v2TIMTopicInfos) {
|
||||
List<TopicBean> topicBeanList = new ArrayList<>();
|
||||
if (v2TIMTopicInfos == null || v2TIMTopicInfos.isEmpty()) {
|
||||
return topicBeanList;
|
||||
}
|
||||
|
||||
for (V2TIMTopicInfo v2TIMTopicInfo : v2TIMTopicInfos) {
|
||||
TopicBean topicBean = parseTopicBean(v2TIMTopicInfo);
|
||||
if (topicBean != null) {
|
||||
topicBeanList.add(topicBean);
|
||||
}
|
||||
}
|
||||
return topicBeanList;
|
||||
}
|
||||
|
||||
public static CommunityMemberBean parseCommunityMemberBean(V2TIMGroupMemberInfo v2TIMGroupMemberInfo) {
|
||||
if (v2TIMGroupMemberInfo == null) {
|
||||
return null;
|
||||
}
|
||||
CommunityMemberBean communityMemberBean = new CommunityMemberBean();
|
||||
communityMemberBean.setAccount(v2TIMGroupMemberInfo.getUserID());
|
||||
communityMemberBean.setAvatar(v2TIMGroupMemberInfo.getFaceUrl());
|
||||
communityMemberBean.setNameCard(v2TIMGroupMemberInfo.getNameCard());
|
||||
communityMemberBean.setNickName(v2TIMGroupMemberInfo.getNickName());
|
||||
communityMemberBean.setFriendRemark(v2TIMGroupMemberInfo.getFriendRemark());
|
||||
|
||||
return communityMemberBean;
|
||||
}
|
||||
|
||||
public static List<CommunityMemberBean> parseCommunityMemberBeanList(List<V2TIMGroupMemberFullInfo> v2TIMGroupMemberInfos) {
|
||||
List<CommunityMemberBean> communityMemberBeans = new ArrayList<>();
|
||||
if (v2TIMGroupMemberInfos == null || v2TIMGroupMemberInfos.isEmpty()) {
|
||||
return communityMemberBeans;
|
||||
}
|
||||
|
||||
for (V2TIMGroupMemberFullInfo v2TIMGroupMemberInfo : v2TIMGroupMemberInfos) {
|
||||
CommunityMemberBean communityMemberBean = parseCommunityMemberBean(v2TIMGroupMemberInfo);
|
||||
if (communityMemberBean != null) {
|
||||
communityMemberBeans.add(communityMemberBean);
|
||||
}
|
||||
}
|
||||
return communityMemberBeans;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
||||
|
||||
public class CommunityUtil {
|
||||
public static <T> void callbackOnSuccess(IUIKitCallback<T> callback, T data) {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void callbackOnError(IUIKitCallback<T> callback, int errorCode, String errorMessage) {
|
||||
if (callback != null) {
|
||||
callback.onError(null, errorCode, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCommunityGroup(String groupId) {
|
||||
return !TextUtils.isEmpty(groupId) && groupId.startsWith("@TGS#_");
|
||||
}
|
||||
|
||||
public static boolean isTopicGroup(String groupID) {
|
||||
|
||||
if (!isCommunityGroup(groupID)) {
|
||||
return false;
|
||||
}
|
||||
return groupID.contains("@TOPIC#_");
|
||||
}
|
||||
|
||||
public static String getGroupIDFromTopicID(String topicID) {
|
||||
|
||||
int index = topicID.indexOf("@TOPIC#_");
|
||||
return topicID.substring(0, index);
|
||||
}
|
||||
|
||||
public static void openWebUrl(Context context, String url) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Uri contentUrl = Uri.parse(url);
|
||||
intent.setData(contentUrl);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.tencent.qcloud.tuikit.tuicommunity.utils;
|
||||
|
||||
import com.tencent.imsdk.common.IMLog;
|
||||
|
||||
public class TUICommunityLog extends IMLog {
|
||||
private static final String PRE = "TUICommunity-";
|
||||
|
||||
private static String mixTag(String tag) {
|
||||
return PRE + tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print INFO level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void v(String strTag, String strInfo) {
|
||||
IMLog.v(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print DEBUG level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void d(String strTag, String strInfo) {
|
||||
IMLog.d(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print INFO level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void i(String strTag, String strInfo) {
|
||||
IMLog.i(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print WARN level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void w(String strTag, String strInfo) {
|
||||
IMLog.w(mixTag(strTag), strInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print WARN level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void w(String strTag, String strInfo, Throwable e) {
|
||||
IMLog.w(mixTag(strTag), strInfo + e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Print ERROR level log
|
||||
*
|
||||
* @param strTag TAG
|
||||
* @param strInfo
|
||||
*/
|
||||
public static void e(String strTag, String strInfo) {
|
||||
IMLog.e(mixTag(strTag), strInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromXDelta="0"
|
||||
android:fromYDelta="100%"
|
||||
android:toXDelta="0"
|
||||
android:toYDelta="0"
|
||||
android:duration="150">
|
||||
</translate>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromXDelta="0"
|
||||
android:fromYDelta="0"
|
||||
android:toXDelta="0"
|
||||
android:toYDelta="100"
|
||||
android:duration="150">
|
||||
</translate>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="200"
|
||||
android:fromYDelta="100%"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:toYDelta="0"/>
|
||||
</set>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="200"
|
||||
android:fromYDelta="0"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:toYDelta="100%"/>
|
||||
</set>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:color="@color/community_btn_negative_hover">
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<corners android:radius="2.5dp" />
|
||||
<solid android:color="@color/community_btn_negative_hover" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:color="@color/community_btn_negative">
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<corners android:radius="2.5dp" />
|
||||
<solid android:color="@color/community_btn_negative" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:color="@color/community_btn_positive_hover" >
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<corners android:radius="5dp" />
|
||||
<solid android:color="@color/community_btn_positive_hover" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:color="@color/community_btn_positive" >
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
<corners android:radius="5dp" />
|
||||
<solid android:color="@color/community_btn_positive" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 598 B |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient android:endColor="#F3F6FF" android:startColor="#47E3EAFD"/>
|
||||
|
||||
<corners android:radius="8dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#ffffff" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 345 B |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/common_check_box_selected" android:state_checked="true" />
|
||||
<item android:drawable="@drawable/common_check_box_unselected" android:state_checked="false" />
|
||||
<item android:drawable="@drawable/common_check_box_unselected" />
|
||||
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 426 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#70C160" />
|
||||
<size android:width="1dp" />
|
||||
</shape>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#EEEEEE"/>
|
||||
<size android:height="1dp"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="#F5F5F7"/>
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#FFCFD7E0"/>
|
||||
<corners android:radius="10dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#006EFF"/>
|
||||
<corners android:radius="10dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 218 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<stroke android:width="1dp" android:color="#FFDBDFE5"/>
|
||||
<solid android:color="#FFF4F5F9"/>
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 337 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 239 B |
|
After Width: | Height: | Size: 227 B |
|
After Width: | Height: | Size: 205 B |
|
After Width: | Height: | Size: 581 B |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape>
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<gradient android:endColor="#FDE7DF" android:startColor="#47FEE9E2"/>
|
||||
|
||||
<corners android:radius="8dp"/>
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromDegrees="0"
|
||||
android:toDegrees="360"
|
||||
android:repeatMode="restart"
|
||||
android:interpolator="@android:interpolator/linear"
|
||||
android:drawable="@drawable/community_progress_bar_ring"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%">
|
||||
|
||||
</rotate>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="4dp"/>
|
||||
<solid android:color="#F4F5F9"/>
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 805 B |
|
After Width: | Height: | Size: 840 B |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="8dp"/>
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:color="#DDDDDD" android:width="1dp"/>
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="ring"
|
||||
android:innerRadius="22.5dp"
|
||||
android:thickness="1.5dp"
|
||||
android:useLevel="false">
|
||||
|
||||
<solid android:color="?attr/core_primary_color"/>
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 391 B |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#FF999999" />
|
||||
<solid android:color="#fff" />
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#FFEBF0F6"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FFFFFFFF"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |