| | |
| | | import com.hdl.hdllinphonesdk.utils.HDLImageUtils; |
| | | import com.hdl.hdllinphonesdk.utils.HDLLog; |
| | | |
| | | import org.linphone.core.Call; |
| | | import org.linphone.core.Core; |
| | | import org.linphone.core.CoreListenerStub; |
| | | |
| | | /** |
| | | * Linphone接听页面 |
| | | */ |
| | |
| | | private int callTime;//通话时间 |
| | | |
| | | private CountDownTimer mCountDownTimer; |
| | | |
| | | //Linphone |
| | | private CoreListenerStub mCoreListener; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | mCountDownTimer.cancel(); |
| | | mCountDownTimer = null; |
| | | } |
| | | |
| | | if (mReceiver != null) { |
| | | unregisterReceiver(mReceiver); |
| | | } |
| | | HDLLinphoneKit.getInstance().onDestroy(); |
| | | onDestroyLinphone(); |
| | | |
| | | HDLLog.i(TAG,"onDestroy"); |
| | | |
| | |
| | | view.setLayoutParams(layoutParams); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * init OnClickListener |
| | | */ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 开锁点击事件 |
| | | */ |
| | |
| | | iv_lp_unlock.setEnabled(false); |
| | | startOpenDoorCountdown(); |
| | | } |
| | | |
| | | /** |
| | | * 开启倒计时 |
| | | */ |
| | | void startOpenDoorCountdown() { |
| | | mCountDownTimer.start(); |
| | | } |
| | | |
| | | /** |
| | | * 通话记录开启倒计时 |
| | | */ |
| | |
| | | timer_lp_calltime.setBase(SystemClock.elapsedRealtime());//计时器清零 |
| | | timer_lp_calltime.start(); |
| | | } |
| | | |
| | | int getTimerCallTime(){ |
| | | int temp0 = Integer.parseInt(timer_lp_calltime.getText().toString().split(":")[0]); |
| | | int temp1 =Integer.parseInt(timer_lp_calltime.getText().toString().split(":")[1]); |
| | | return temp0 * 60 + temp1; |
| | | } |
| | | |
| | | |
| | | |
| | | /****************封装常用方法********/ |
| | |
| | | } |
| | | |
| | | /**********LinPhone**********/ |
| | | /** |
| | | * initLinphone |
| | | */ |
| | | void initLinphone(){ |
| | | IntentFilter intentFilter = new IntentFilter(RECEIVE_FINISH_VIDEO_ACTIVITY); |
| | | mReceiver = new FinishVideoActivityReceiver(); |
| | | registerReceiver(mReceiver, intentFilter); |
| | | HDLLinphoneKit.getInstance().setAndroidVideoWindow(video_lp_rendering, video_lp_rendering2); |
| | | } |
| | | |
| | | |
| | | public class FinishVideoActivityReceiver extends BroadcastReceiver { |
| | | mCoreListener = new CoreListenerStub() { |
| | | @Override |
| | | public void onReceive(Context context, Intent intent) { |
| | | HDLLinphoneIntercomActivity.this.finish(); |
| | | public void onCallStateChanged(Core core, Call call, Call.State state, String message) { |
| | | if (state == Call.State.End || state == Call.State.Released) { |
| | | // Once call is finished (end state), terminate the activity |
| | | // We also check for released state (called a few seconds later) just in case |
| | | // we missed the first one |
| | | showToast(getString(R.string.lp_endOfCallStr)); |
| | | finish(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | Core core = HDLLinphoneKit.getInstance().getCore(); |
| | | // We need to tell the core in which to display what |
| | | if (core != null) { |
| | | core.setNativeVideoWindowId(video_lp_rendering); |
| | | core.setNativePreviewWindowId(video_lp_rendering2); |
| | | // Listen for call state changes |
| | | core.addListener(mCoreListener); |
| | | } |
| | | } |
| | | |
| | | private FinishVideoActivityReceiver mReceiver; |
| | | public static final String RECEIVE_FINISH_VIDEO_ACTIVITY = "receive_finish_video_activity"; |
| | | /** |
| | | * onDestroyLinphone |
| | | */ |
| | | void onDestroyLinphone(){ |
| | | Core core = HDLLinphoneKit.getInstance().getCore(); |
| | | if (core != null) { |
| | | core.removeListener(mCoreListener); |
| | | core.setNativeVideoWindowId(null); |
| | | core.setNativePreviewWindowId(null); |
| | | } |
| | | video_lp_rendering = null; |
| | | video_lp_rendering2 = null; |
| | | } |
| | | |
| | | |
| | | } |