Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiruili committed Jul 16, 2017
1 parent 9fbc61f commit e1a577e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
24 changes: 18 additions & 6 deletions app/src/main/java/com/example/zhiruili/videoconf/CallActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.Window;
import android.view.WindowManager;

import com.example.zhiruili.videoconf.call.constants.CallResultCode;
import com.tencent.av.sdk.AVView;
import com.tencent.callsdk.ILVCallConstants;
import com.tencent.callsdk.ILVCallListener;
Expand All @@ -27,6 +28,7 @@ public final class CallActivity

private static final String TAG = CallActivity.class.getSimpleName();
private AVRootView mAvRootView;
private int mCallId;

public static final class IntentExtras {
public static final class Request {
Expand All @@ -35,6 +37,7 @@ public static final class Request {
public static final String SPONSOR = "sponsor";
public static final String MEMBERS = "members";
}

public static final class Result {
public static final String MESSAGE = "message";
}
Expand Down Expand Up @@ -63,22 +66,22 @@ protected void onCreate(Bundle savedInstanceState) {
}

Intent intent = getIntent();
final int callId = intent.getIntExtra(IntentExtras.Request.CALL_ID, -1);
mCallId = intent.getIntExtra(IntentExtras.Request.CALL_ID, -1);
final int callType = intent.getIntExtra(IntentExtras.Request.CALL_TYPE, -1);
final String sponsor = intent.getStringExtra(IntentExtras.Request.SPONSOR);
final ArrayList<String> members = intent.getStringArrayListExtra(IntentExtras.Request.MEMBERS);
if (callId == -1 || callType == -1 || sponsor == null || members == null) {
if (mCallId == -1 || callType == -1 || sponsor == null || members == null) {
throw new IllegalArgumentException("should have intent extra of call_id, sponsor and members");
}

CallFragment fragment = CallFragment.newInstance(callId, sponsor, members);
CallFragment fragment = CallFragment.newInstance(mCallId, sponsor, members);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.call_main_container, fragment)
.commit();

ILVCallOption option = new ILVCallOption(sponsor);
if (callId == 0) {
if (mCallId == 0) {

ILVCallManager.getInstance().makeMutiCall(members, option.setCallType(ILVCallConstants.CALL_TYPE_VIDEO), new ILiveCallBack() {

Expand All @@ -94,7 +97,7 @@ public void onError(String module, int errCode, String errMsg) {
}
});
} else {
ILVCallManager.getInstance().acceptCall(callId, option.setCallType(callType));
ILVCallManager.getInstance().acceptCall(mCallId, option.setCallType(callType));
}
}

Expand All @@ -107,7 +110,9 @@ protected void onResume() {

@Override
public void onActionEndCall(int callId, String sponsor, ArrayList<String> members) {
ILVCallManager.getInstance().endCall(callId);
Log.d(TAG, "onActionEndCall, callId: " + callId);
// TODO: 这里如果我调用 `ILVCallManager.getInstance().endCall(mCallId)` 是不会触发 `onCallEnd` 的,这是为什么?
endCall();
}

@Override
Expand Down Expand Up @@ -157,5 +162,12 @@ public void onException(int iExceptionId, int errCode, String errMsg) {
@Override
public void onBackPressed() {
Log.d(TAG, "onBackPress");
endCall();
}

private void endCall() {
ILVCallManager.getInstance().endCall(mCallId);
setResult(CallResultCode.LOCAL_CANCEL, new Intent().putExtra(IntentExtras.Result.MESSAGE, "结束通话"));
finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ public void onNewIncomingCall(int callId, int callType, ILVIncomingNotification
}

private void gotoCall(String sponsor, int callId, int callType, ArrayList<String> members) {
// mRecentCallsList
// .updateCalls(members, callId != 0)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(success -> {
// Log.d(TAG, "gotoCall success = " + success);
mRecentCallsList
.updateCalls(members, callId != 0)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(success -> {
Log.d(TAG, "gotoCall success = " + success);
startActivityForResult(CallActivity.createIntent(this, callId, callType, sponsor, members), RequestCode.REQ_CALL);
// });
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import com.example.zhiruili.videoconf.data.RecentCallsDbHelper;
import com.example.zhiruili.videoconf.data.RecentCallsListContract.*;
import com.example.zhiruili.videoconf.data.TestHelper;

import java.util.List;

Expand Down

0 comments on commit e1a577e

Please sign in to comment.