Created
November 14, 2018 17:30
-
-
Save samyak-jain/68bc065897f0342e28cc620e10f8defd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void addCallback() { | |
AGApplication.the().getmAgoraAPI().callbackSet(new AgoraAPI.CallBack() { | |
@Override | |
public void onLoginSuccess(int i, int i1) { | |
Log.i(TAG, "onLoginSuccess " + i + " " + i1); | |
initUI(); | |
} | |
@Override | |
public void onLoginFailed(final int i) { | |
Log.i(TAG, "onLoginFailed " + i); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
if (i == IAgoraAPI.ECODE_LOGIN_E_NET) { | |
enableLoginBtnClick = true; | |
ToastUtils.show(new WeakReference<Context>(LoginActivity.this), getString(R.string.str_msg_net_bad)); | |
} | |
} | |
}); | |
} | |
@Override | |
public void onError(String s, int i, String s1) { | |
Log.i(TAG, "onError s:" + s + " s1:" + s1); | |
} | |
@Override | |
public void onChannelJoined(String channelID) { | |
super.onChannelJoined(channelID); | |
} | |
@Override | |
public void onChannelJoinFailed(String channelID, int ecode) { | |
super.onChannelJoinFailed(channelID, ecode); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
enableChannelBtnClick = true; | |
ToastUtils.show(new WeakReference<Context>(LoginActivity.this), getString(R.string.str_join_channe_failed)); | |
} | |
}); | |
} | |
@Override | |
public void onChannelUserList(String[] accounts, final int[] uids) { | |
super.onChannelUserList(accounts, uids); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
Intent intent = new Intent(LoginActivity.this, MessageActivity.class); | |
intent.putExtra("name", channelName); | |
intent.putExtra("selfname", account); | |
intent.putExtra("usercount", uids.length); | |
startActivity(intent); | |
} | |
}); | |
} | |
@Override | |
public void onLogout(final int i) { | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
if (i == IAgoraAPI.ECODE_LOGOUT_E_KICKED) { //other login the account | |
ToastUtils.show(new WeakReference<Context>(LoginActivity.this), "Other login account ,you are logout."); | |
} else if (i == IAgoraAPI.ECODE_LOGOUT_E_NET) { //net | |
ToastUtils.show(new WeakReference<Context>(LoginActivity.this), "Logout for Network can not be."); | |
} | |
finish(); | |
} | |
}); | |
} | |
@Override | |
public void onMessageInstantReceive(final String account, int uid, final String msg) { | |
Log.i(TAG, "onMessageInstantReceive account = " + account + " uid = " + uid + " msg = " + msg); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
Constant.addMessageBean(account, msg); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment