@@ -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