Android融雲判斷是否使用者已經加入黑名單和加入&移除黑名單
阿新 • • 發佈:2019-02-16
disturb_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if(isChecked){//加入黑名單
RongIM.getInstance().addToBlacklist(otherUserId, new RongIMClient.OperationCallback() {
@Override
public void onSuccess() {
disturb_switch.setChecked(true);
Log.d(TAG,"加入黑名單成功");
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
disturb_switch.setChecked(false);
Log.d(TAG,"加入黑名單失敗");
}
});
}else{//移除黑名單
RongIM.getInstance().removeFromBlacklist(otherUserId, new RongIMClient.OperationCallback() {
@Override
public void onSuccess() {
disturb_switch.setChecked(false);
Log.d(TAG,"移除黑名單成功");
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
disturb_switch.setChecked(true);
Log.d(TAG,"移除黑名單失敗");
}
});
}
}
});
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if(isChecked){//加入黑名單
RongIM.getInstance().addToBlacklist(otherUserId, new RongIMClient.OperationCallback() {
@Override
public void onSuccess() {
disturb_switch.setChecked(true);
Log.d(TAG,"加入黑名單成功");
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
disturb_switch.setChecked(false);
Log.d(TAG,"加入黑名單失敗");
}
});
}else{//移除黑名單
RongIM.getInstance().removeFromBlacklist(otherUserId, new RongIMClient.OperationCallback() {
@Override
public void onSuccess() {
disturb_switch.setChecked(false);
Log.d(TAG,"移除黑名單成功");
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
disturb_switch.setChecked(true);
Log.d(TAG,"移除黑名單失敗");
}
});
}
}
});