Back to project page demo-app-android.
The source code is released under:
MIT License
If you think the Android project demo-app-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package io.rong.imkit.demo; //www . jav a2 s .co m import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import io.rong.imkit.RongIM; import io.rong.imkit.view.ActionBar; import io.rong.imlib.RongIMClient; public class UserInfoActivity extends BaseActivity implements OnClickListener { private String TAG = "UserInfoActivity"; ActionBar mActionBar; private Button mAddBlack; private TextView mUserInfo; String title = null; String userId = null; private Button mRemoveBlack; private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what){ case 1: mAddBlack.setVisibility(View.GONE); mRemoveBlack.setVisibility(View.VISIBLE); mUserInfo.setText(title+"???????????????????????" ); break; case 2: mAddBlack.setVisibility(View.VISIBLE); mRemoveBlack.setVisibility(View.GONE); mUserInfo.setText(title ); break; } } }; @Override protected int setContentViewResId() { return R.layout.user_info; } @Override protected void initView() { mActionBar = (ActionBar) findViewById(android.R.id.custom); mUserInfo = (TextView) findViewById(R.id.user_name_tv); mAddBlack = (Button) findViewById(R.id.add_black); mRemoveBlack = (Button) findViewById(R.id.remove_black); mActionBar.setOnBackClick(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); if (getIntent().getExtras() != null) { title = getIntent().getExtras().getString("user_name"); userId = getIntent().getExtras().getString("user_id"); mActionBar.getTitleTextView().setText(title + "????"); } else { mActionBar.getTitleTextView().setText("????"); } } @Override protected void initData() { mAddBlack.setOnClickListener(this); mRemoveBlack.setOnClickListener(this); if (RongIM.getInstance() != null) { if(userId.equals(LoginActivity.mUserID) ){ mUserInfo.setVisibility(View.GONE); }else { RongIM.getInstance().getBlacklistStatus(userId, new RongIM.GetUserBlacklistCallback() { @Override public void onError(ErrorCode errorCode) { Log.e(TAG, "-------getBlacklistStatus onError---------:" + errorCode.getMessage() + ",:" + errorCode.getValue()); mUserInfo.setText(errorCode + ""); } @Override public void onSuccess(RongIMClient.BlacklistStatus status) { Log.e(TAG, "-------getBlacklistStatus onSuccess---------:" + status); if (status == RongIMClient.BlacklistStatus.NOT_EXIT_BLACK_LIST) { mUserInfo.setText(title ); mAddBlack.setVisibility(View.VISIBLE); } else if (status == RongIMClient.BlacklistStatus.EXIT_BLACK_LIST) { mUserInfo.setText(title + "???????????????????????"); mRemoveBlack.setVisibility(View.VISIBLE); } } }); } } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.add_black: if (RongIM.getInstance() != null) { RongIM.getInstance().addToBlacklist(userId, new RongIM.OperationCallback() { @Override public void onError(ErrorCode errorCode) { Log.e(TAG, "-------addToBlacklist onError----------:" + errorCode.getMessage()); Log.e(TAG, "-------addToBlacklist onError---------:" + errorCode.getValue()); } @Override public void onSuccess() { Log.e(TAG, "-------??????????--------:"); Message msg = Message.obtain(); msg.what = 1; mHandler.sendMessage(msg); } }); } break; case R.id.remove_black: if (RongIM.getInstance() != null) { RongIM.getInstance().removeFromBlacklist(userId, new RongIM.OperationCallback() { @Override public void onError(ErrorCode errorCode) { Log.e(TAG, "------- removeFromBlacklist onError-------:" + errorCode); } @Override public void onSuccess() { Log.e(TAG, "-------??????????-------:"); Message msg = Message.obtain(); msg.what = 2; mHandler.sendMessage(msg); } }); } break; default: break; } } }