Skip to content

Commit f868801

Browse files
committed
去掉头像缓存,fix:team空
1 parent f7e9315 commit f868801

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

android/src/main/java/com/netease/im/ReactCache.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ public static ReactContext getReactContext() {
9393
}
9494

9595
public static void emit(String eventName, Object date) {
96-
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, date);
96+
try {
97+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, date);
98+
} catch (Exception e) {
99+
e.printStackTrace();
100+
}
97101
}
98102

99103
public static Object createRecentList(List<RecentContact> recents, int unreadNum) {
@@ -114,6 +118,7 @@ public static Object createRecentList(List<RecentContact> recents, int unreadNum
114118
String name = "";
115119
SessionTypeEnum sessionType = contact.getSessionType();
116120
String imagePath = "";
121+
Team team = null;
117122
if (sessionType == SessionTypeEnum.P2P) {
118123
map.putString("teamType", "-1");
119124
NimUserInfoCache nimUserInfoCache = NimUserInfoCache.getInstance();
@@ -122,7 +127,7 @@ public static Object createRecentList(List<RecentContact> recents, int unreadNum
122127
map.putString("mute", boolean2String(NIMClient.getService(FriendService.class).isNeedMessageNotify(contactId)));
123128
name = nimUserInfoCache.getUserDisplayName(contactId);
124129
} else if (sessionType == SessionTypeEnum.Team) {
125-
Team team = TeamDataCache.getInstance().getTeamById(contactId);
130+
team = TeamDataCache.getInstance().getTeamById(contactId);
126131
if (team != null) {
127132
name = team.getName();
128133
map.putString("teamType", Integer.toString(team.getType().getValue()));
@@ -168,7 +173,7 @@ public static Object createRecentList(List<RecentContact> recents, int unreadNum
168173
}
169174
break;
170175
case notification:
171-
if (sessionType == SessionTypeEnum.Team) {
176+
if (sessionType == SessionTypeEnum.Team && team != null) {
172177
content = TeamNotificationHelper.getTeamNotificationText(contact.getContactId(),
173178
contact.getFromAccount(),
174179
(NotificationAttachment) contact.getAttachment());
@@ -724,7 +729,12 @@ public static WritableMap createMessage(IMMessage item) {
724729

725730
WritableMap user = Arguments.createMap();
726731
String fromAccount = item.getFromAccount();
727-
String fromNick = item.getFromNick();
732+
String fromNick = null;
733+
try {
734+
fromNick = item.getFromNick();
735+
} catch (Exception e) {
736+
e.printStackTrace();
737+
}
728738
user.putString("_id", fromAccount);
729739

730740
if (item.getSessionType() == SessionTypeEnum.Team && !TextUtils.equals(LoginService.getInstance().getAccount(), fromAccount)) {

android/src/main/java/com/netease/im/common/ImageLoaderKit.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
2424
import com.nostra13.universalimageloader.core.download.ImageDownloader;
2525
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
26-
import com.nostra13.universalimageloader.utils.DiskCacheUtils;
2726
import com.nostra13.universalimageloader.utils.MemoryCacheUtils;
2827
import com.nostra13.universalimageloader.utils.StorageUtils;
2928

@@ -196,17 +195,18 @@ private static Bitmap getMemoryCachedAvatarBitmap(String url) {
196195
return null;
197196
}
198197

199-
public static String getMemoryCachedAvatar(String url) {
200-
if (url == null || !isImageUriValid(url)) {
201-
return "";
202-
}
203-
String key = getAvatarCacheKey(url);
204-
205-
File file = DiskCacheUtils.findInCache(key, ImageLoader.getInstance().getDiskCache());// 查询磁盘缓存示例
206-
if (file == null) {
207-
// asyncLoadAvatarBitmapToCache(url);
208-
}
209-
return file == null ? "" : file.getAbsolutePath();
198+
public static String getMemoryCachedAvatar(String url) {//TODO
199+
return "";
200+
// if (url == null || !isImageUriValid(url)) {
201+
// return "";
202+
// }
203+
// String key = getAvatarCacheKey(url);
204+
//
205+
// File file = DiskCacheUtils.findInCache(key, ImageLoader.getInstance().getDiskCache());// 查询磁盘缓存示例
206+
// if (file == null) {
207+
//// asyncLoadAvatarBitmapToCache(url);
208+
// }
209+
// return file == null ? "" : file.getAbsolutePath();
210210
}
211211

212212
private static Set<String> cacheLoad = new HashSet<>();

android/src/main/java/com/netease/im/contact/BlackListObserver.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ public void startBlackList() {
2525
items.clear();
2626
final List<String> accounts = NIMClient.getService(FriendService.class).getBlackList();
2727
List<String> unknownAccounts = new ArrayList<>();
28-
for (String contactId : accounts) {
29-
if (!NimUserInfoCache.getInstance().hasUser(contactId)) {
30-
unknownAccounts.add(contactId);
31-
} else {
32-
items.add(NimUserInfoCache.getInstance().getUserInfo(contactId));
28+
if (accounts != null) {
29+
for (String contactId : accounts) {
30+
if (!NimUserInfoCache.getInstance().hasUser(contactId)) {
31+
unknownAccounts.add(contactId);
32+
} else {
33+
items.add(NimUserInfoCache.getInstance().getUserInfo(contactId));
34+
}
3335
}
3436
}
3537

@@ -53,33 +55,36 @@ public void removeFromBlackList(final String contactId, final RequestCallbackWra
5355
.setCallback(new RequestCallbackWrapper<Void>() {
5456
@Override
5557
public void onResult(int code, Void aVoid, Throwable throwable) {
56-
if(callbackWrapper!=null){
57-
callbackWrapper.onResult(code,aVoid,throwable);
58+
if (callbackWrapper != null) {
59+
callbackWrapper.onResult(code, aVoid, throwable);
5860
}
5961
if (code == ResponseCode.RES_SUCCESS) {
6062
removeBlackList(contactId);
6163
}
6264
}
6365
});
6466
}
67+
6568
public void addToBlackList(final String contactId, final RequestCallbackWrapper<Void> callbackWrapper) {
6669
NIMClient.getService(FriendService.class).addToBlackList(contactId)
6770
.setCallback(new RequestCallbackWrapper<Void>() {
6871
@Override
6972
public void onResult(int code, Void aVoid, Throwable throwable) {
70-
if(callbackWrapper!=null){
71-
callbackWrapper.onResult(code,aVoid,throwable);
73+
if (callbackWrapper != null) {
74+
callbackWrapper.onResult(code, aVoid, throwable);
7275
}
7376
if (code == ResponseCode.RES_SUCCESS) {
7477
addBlackList(contactId);
7578
}
7679
}
7780
});
7881
}
79-
void addBlackList(String contactId){
82+
83+
void addBlackList(String contactId) {
8084
items.add(NimUserInfoCache.getInstance().getUserInfo(contactId));
8185
refresh();
8286
}
87+
8388
private void removeBlackList(String contactId) {
8489

8590
int index = -1;
@@ -98,6 +103,7 @@ private void removeBlackList(String contactId) {
98103

99104
refresh();
100105
}
106+
101107
void refresh() {
102108
ReactCache.emit(ReactCache.observeBlackList, ReactCache.createBlackList(items));
103109
}

0 commit comments

Comments
 (0)