提交 352a6c39 authored 作者: 汪显鹏's avatar 汪显鹏

瞩目SDK 第二次提交

上级 47b14e56
流水线 #229 已失败 于阶段
......@@ -29,250 +29,250 @@ import us.zoom.sdk.MeetingStatus;
public class MainActivity extends Activity implements Constants, ZHUMUMeetingServiceListener, ZHUMUSdkInitializeListener {
private final static String TAG = MainActivity.class.getName();
Logs log = new Logs(TAG);
public final static String ACTION_RETURN_FROM_MEETING = "com.android.sdkexample2.action.ReturnFromMeeting";
public final static String EXTRA_TAB_ID = "tabId";
public final static int TAB_WELCOME = 1;
public final static int TAB_MEETING = 2;
public final static int TAB_PAGE_2 = 3;
private final static int STYPE = ZHUMUMeetingService.USER_TYPE_API_USER;
private final static String DISPLAY_NAME = "ZHUMU SDK";
private View viewTabWelcome;
private View viewTabMeeting;
private View viewTabPage2;
private Button btnTabWelcome;
private Button btnTabMeeting;
private Button btnTabPage2;
public static String user_id = "";
public static String token = "";
public static String user_name = "";
public static String meet_num = "";
Meeting mMeeting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setupTabs();
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
private final static String TAG = MainActivity.class.getName();
Logs log = new Logs(TAG);
public final static String ACTION_RETURN_FROM_MEETING = "com.android.sdkexample2.action.ReturnFromMeeting";
public final static String EXTRA_TAB_ID = "tabId";
public final static int TAB_WELCOME = 1;
public final static int TAB_MEETING = 2;
public final static int TAB_PAGE_2 = 3;
private final static int STYPE = ZHUMUMeetingService.USER_TYPE_API_USER;
private final static String DISPLAY_NAME = "ZHUMU SDK";
private View viewTabWelcome;
private View viewTabMeeting;
private View viewTabPage2;
private Button btnTabWelcome;
private Button btnTabMeeting;
private Button btnTabPage2;
public static String user_id = "";
public static String token = "";
public static String user_name = "";
public static String meet_num = "";
Meeting mMeeting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setupTabs();
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
// if(savedInstanceState == null) {
sdk.initSDK(this, APP_KEY, APP_SECRET, WEB_DOMAIN, this);
sdk.initSDK(this, APP_KEY, APP_SECRET, WEB_DOMAIN, this);
// }
if(sdk.isInitialized()) {
registerMeetingServiceListener();
}
}
private void setupTabs() {
viewTabWelcome = findViewById(R.id.viewTabWelcome);
viewTabMeeting = findViewById(R.id.viewTabMeeting);
viewTabPage2 = findViewById(R.id.viewTabPage2);
btnTabWelcome = (Button)findViewById(R.id.btnTabWelcome);
btnTabMeeting = (Button)findViewById(R.id.btnTabMeeting);
btnTabPage2 = (Button)findViewById(R.id.btnTabPage2);
selectTab(TAB_WELCOME);
btnTabMeeting.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_MEETING);
}
});
btnTabWelcome.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_WELCOME);
}
});
btnTabPage2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_PAGE_2);
}
});
}
private void selectTab(int tabId) {
if(tabId == TAB_WELCOME) {
viewTabWelcome.setVisibility(View.VISIBLE);
viewTabMeeting.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.GONE);
btnTabWelcome.setSelected(true);
btnTabMeeting.setSelected(false);
btnTabPage2.setSelected(false);
} else if(tabId == TAB_PAGE_2) {
viewTabWelcome.setVisibility(View.GONE);
viewTabMeeting.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.VISIBLE);
btnTabWelcome.setSelected(false);
btnTabMeeting.setSelected(false);
btnTabPage2.setSelected(true);
} else if(tabId == TAB_MEETING) {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if(!sdk.isInitialized()) {
Toast.makeText(this, "ZHUMUSDK has not been initialized successfully", Toast.LENGTH_LONG).show();
return;
}
ZHUMUMeetingService meetingService = sdk.getMeetingService();
if(meetingService == null)
return;
if(meetingService.getMeetingStatus() .equals(ZHUMUMeetingStatus.MEETING_STATUS_IDLE) ){
viewTabWelcome.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.GONE);
viewTabMeeting.setVisibility(View.VISIBLE);
btnTabWelcome.setSelected(false);
btnTabPage2.setSelected(false);
btnTabMeeting.setSelected(true);
startMeeting();
} else {
meetingService.returnToMeeting(this);
}
overridePendingTransition(0, 0);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// disable animation
overridePendingTransition(0,0);
String action = intent.getAction();
if(ACTION_RETURN_FROM_MEETING.equals(action)) {
int tabId = intent.getIntExtra(EXTRA_TAB_ID, TAB_WELCOME);
selectTab(tabId);
}
}
@Override
public void onZHUMUSdkInitializeResult(int errorCode, int internalErrorCode) {
Log.i(TAG, "onZHUMUSdkInitializeResult, errorCode=" + errorCode + ", internalErrorCode=" + internalErrorCode);
if(errorCode != ZHUMUError.ERROR_SUCCESS) {
Toast.makeText(this, "Failed to initialize ZHUMUSDK. Error: " + errorCode + ", internalErrorCode=" + internalErrorCode, Toast.LENGTH_LONG);
} else {
Toast.makeText(this, "Initialize ZHUMUSDK successfully.", Toast.LENGTH_LONG).show();
registerMeetingServiceListener();
}
}
private void registerMeetingServiceListener() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
ZHUMUMeetingService meetingService = sdk.getMeetingService();
if(meetingService != null) {
meetingService.addListener(this);
}
}
@Override
protected void onDestroy() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if(sdk.isInitialized()) {
ZHUMUMeetingService meetingService = sdk.getMeetingService();
meetingService.removeListener(this);
}
super.onDestroy();
}
public void startMeeting() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if(!sdk.isInitialized()) {
Toast.makeText(this, "ZHUMUSDK has not been initialized successfully", Toast.LENGTH_LONG).show();
return;
}
if(meet_num == null) {
Toast.makeText(this, "MEETING_ID in Constants can not be NULL", Toast.LENGTH_LONG).show();
return;
}
ZHUMUMeetingService meetingService = sdk.getMeetingService();
ZHUMUStartMeetingOptions opts = new ZHUMUStartMeetingOptions();
if (sdk.isInitialized()) {
registerMeetingServiceListener();
}
}
private void setupTabs() {
viewTabWelcome = findViewById(R.id.viewTabWelcome);
viewTabMeeting = findViewById(R.id.viewTabMeeting);
viewTabPage2 = findViewById(R.id.viewTabPage2);
btnTabWelcome = (Button) findViewById(R.id.btnTabWelcome);
btnTabMeeting = (Button) findViewById(R.id.btnTabMeeting);
btnTabPage2 = (Button) findViewById(R.id.btnTabPage2);
selectTab(TAB_WELCOME);
btnTabMeeting.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_MEETING);
}
});
btnTabWelcome.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_WELCOME);
}
});
btnTabPage2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectTab(TAB_PAGE_2);
}
});
}
private void selectTab(int tabId) {
if (tabId == TAB_WELCOME) {
viewTabWelcome.setVisibility(View.VISIBLE);
viewTabMeeting.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.GONE);
btnTabWelcome.setSelected(true);
btnTabMeeting.setSelected(false);
btnTabPage2.setSelected(false);
} else if (tabId == TAB_PAGE_2) {
viewTabWelcome.setVisibility(View.GONE);
viewTabMeeting.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.VISIBLE);
btnTabWelcome.setSelected(false);
btnTabMeeting.setSelected(false);
btnTabPage2.setSelected(true);
} else if (tabId == TAB_MEETING) {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if (!sdk.isInitialized()) {
Toast.makeText(this, "ZHUMUSDK has not been initialized successfully", Toast.LENGTH_LONG).show();
return;
}
ZHUMUMeetingService meetingService = sdk.getMeetingService();
if (meetingService == null)
return;
if (meetingService.getMeetingStatus().equals(ZHUMUMeetingStatus.MEETING_STATUS_IDLE)) {
viewTabWelcome.setVisibility(View.GONE);
viewTabPage2.setVisibility(View.GONE);
viewTabMeeting.setVisibility(View.VISIBLE);
btnTabWelcome.setSelected(false);
btnTabPage2.setSelected(false);
btnTabMeeting.setSelected(true);
startMeeting();
} else {
meetingService.returnToMeeting(this);
}
overridePendingTransition(0, 0);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// disable animation
overridePendingTransition(0, 0);
String action = intent.getAction();
if (ACTION_RETURN_FROM_MEETING.equals(action)) {
int tabId = intent.getIntExtra(EXTRA_TAB_ID, TAB_WELCOME);
selectTab(tabId);
}
}
@Override
public void onZHUMUSdkInitializeResult(int errorCode, int internalErrorCode) {
Log.i(TAG, "onZHUMUSdkInitializeResult, errorCode=" + errorCode + ", internalErrorCode=" + internalErrorCode);
if (errorCode != ZHUMUError.ERROR_SUCCESS) {
Toast.makeText(this, "Failed to initialize ZHUMUSDK. Error: " + errorCode + ", internalErrorCode=" + internalErrorCode, Toast.LENGTH_LONG);
} else {
Toast.makeText(this, "Initialize ZHUMUSDK successfully.", Toast.LENGTH_LONG).show();
registerMeetingServiceListener();
}
}
private void registerMeetingServiceListener() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
ZHUMUMeetingService meetingService = sdk.getMeetingService();
if (meetingService != null) {
meetingService.addListener(this);
}
}
@Override
protected void onDestroy() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if (sdk.isInitialized()) {
ZHUMUMeetingService meetingService = sdk.getMeetingService();
meetingService.removeListener(this);
}
super.onDestroy();
}
public void startMeeting() {
ZHUMUSdk sdk = ZHUMUSdk.getInstance();
if (!sdk.isInitialized()) {
Toast.makeText(this, "ZHUMUSDK has not been initialized successfully", Toast.LENGTH_LONG).show();
return;
}
if (meet_num == null) {
Toast.makeText(this, "MEETING_ID in Constants can not be NULL", Toast.LENGTH_LONG).show();
return;
}
ZHUMUMeetingService meetingService = sdk.getMeetingService();
ZHUMUStartMeetingOptions opts = new ZHUMUStartMeetingOptions();
// opts.no_meeting_end_message = true;
// opts.no_titlebar = true;
opts.no_bottom_toolbar = true;
opts.no_invite = true;
int ret = meetingService.startMeeting(this, user_id, token, STYPE, meet_num, DISPLAY_NAME, opts);
Log.i(TAG, "onClickBtnStartMeeting, ret=" + ret);
}
private Meeting getMeeting(String strResult){
try{
JSONObject jsonObject = new JSONObject(strResult.toString());
int code = jsonObject.getInt("code");
int zcode = jsonObject.getInt("zcode");
String id = jsonObject.getString("id");// User_id
String username = jsonObject.getString("username");
String mobile = jsonObject.getString("mobile");
int usertype = jsonObject.getInt("usertype");
String det = jsonObject.getString("det");
String createtime = jsonObject.getString("createtime");
String createby = jsonObject.getString("createby");
String pmi = jsonObject.getString("pmi");
int role = jsonObject.getInt("role");
String email = jsonObject.getString("email");
int isowner = jsonObject.getInt("isowner");
int accounttype = jsonObject.getInt("accounttype");
String token = jsonObject.getString("token");
Meeting meet = new Meeting();
meet.setCode(code);
meet.setZcode(zcode);
meet.setId(id);
meet.setUsername(username);
meet.setMobile(mobile);
meet.setUsertype(usertype);
meet.setDet(det);
meet.setCreatetime(createtime);
meet.setCreateby(createby);
meet.setPmi(pmi);
meet.setRole(role);
meet.setEmail(email);
meet.setIsowner(isowner);
meet.setAccounttype(accounttype);
meet.setToken(token);
return meet;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
@Override
public void onMeetingStatusChanged(MeetingStatus meetingStatus, int i, int i1) {
}
opts.no_bottom_toolbar = true;
opts.no_invite = true;
int ret = meetingService.startMeeting(this, user_id, token, STYPE, meet_num, DISPLAY_NAME, opts);
Log.i(TAG, "onClickBtnStartMeeting, ret=" + ret);
}
private Meeting getMeeting(String strResult) {
try {
JSONObject jsonObject = new JSONObject(strResult.toString());
int code = jsonObject.getInt("code");
int zcode = jsonObject.getInt("zcode");
String id = jsonObject.getString("id");// User_id
String username = jsonObject.getString("username");
String mobile = jsonObject.getString("mobile");
int usertype = jsonObject.getInt("usertype");
String det = jsonObject.getString("det");
String createtime = jsonObject.getString("createtime");
String createby = jsonObject.getString("createby");
String pmi = jsonObject.getString("pmi");
int role = jsonObject.getInt("role");
String email = jsonObject.getString("email");
int isowner = jsonObject.getInt("isowner");
int accounttype = jsonObject.getInt("accounttype");
String token = jsonObject.getString("token");
Meeting meet = new Meeting();
meet.setCode(code);
meet.setZcode(zcode);
meet.setId(id);
meet.setUsername(username);
meet.setMobile(mobile);
meet.setUsertype(usertype);
meet.setDet(det);
meet.setCreatetime(createtime);
meet.setCreateby(createby);
meet.setPmi(pmi);
meet.setRole(role);
meet.setEmail(email);
meet.setIsowner(isowner);
meet.setAccounttype(accounttype);
meet.setToken(token);
return meet;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void onMeetingStatusChanged(MeetingStatus meetingStatus, int i, int i1) {
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论