pjsip视频通信开发(上层应用)之拨号键盘下部份拨号和删除功能
我们开发的是视频电话,所以既可以视频通话,可以只有音频的通话,所以底部含有两个按钮,最后一个就是删除功能,如果输入错误,我们可以删除输入的内容。
这里我们要通过重写LinearLayout来实现这部份,对应着上面的功能我们可以写一个接口来实现这些功能,如下:
- public interface OnDialActionListener {
- /**
- * The make call button has been pressed
- */
- void placeCall();
- /**
- * The video button has been pressed
- */
- void placeVideoCall();
- /**
- * The delete button has been pressed
- */
- void deleteChar();
- /**
- * The delete button has been long pressed
- */
- void deleteAll();
- }
通过回调来在主界面实现这些功能。例如在OnClick函数中
- @Override
- public void onClick(View v) {
- if (actionListener != null) {
- int viewId = v.getId();
- if (viewId == R.id.dialVideoButton) {
- actionListener.placeVideoCall();
- }else if(viewId == R.id.dialButton) {
- actionListener.placeCall();
- }else if(viewId == R.id.deleteButton) {
- actionListener.deleteChar();
- }
- }
- }
我们可以通过本地的接口来实现内部函数,然后在主界面实例化这个接口并填写接口的实现方式。整体的代码如下:
- package com.jwzhangjie.pjsip.widgets;
- import com.jwzhangjie.pjsip.R;
- import android.content.Context;
- import android.util.AttributeSet;
- import android.view.Gravity;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.View.OnLongClickListener;
- import android.widget.LinearLayout;
- public class DialerCallBar extends LinearLayout implements OnClickListener, OnLongClickListener {
- public interface OnDialActionListener {
- /**
- * The make call button has been pressed
- */
- void placeCall();
- /**
- * The video button has been pressed
- */
- void placeVideoCall();
- /**
- * The delete button has been pressed
- */
- void deleteChar();
- /**
- * The delete button has been long pressed
- */
- void deleteAll();
- }
- private OnDialActionListener actionListener;
- public DialerCallBar(Context context) {
- this(context, null, 0);
- }
- public DialerCallBar(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
- public DialerCallBar(Context context, AttributeSet attrs, int style) {
- super(context, attrs);
- LayoutInflater inflater = LayoutInflater.from(context);
- inflater.inflate(R.layout.dialpad_additional_buttons, this, true);
- findViewById(R.id.dialVideoButton).setOnClickListener(this);
- findViewById(R.id.dialButton).setOnClickListener(this);
- findViewById(R.id.deleteButton).setOnClickListener(this);
- findViewById(R.id.deleteButton).setOnLongClickListener(this);
- if(getOrientation() == LinearLayout.VERTICAL) {
- LayoutParams lp;
- for(int i=0; i < getChildCount(); i++) {
- lp = (LayoutParams) getChildAt(i).getLayoutParams();
- int w = lp.width;
- lp.width = lp.height;
- lp.height = w;
- lp.gravity = Gravity.CENTER_HORIZONTAL;
- // Added for clarity but not necessary
- getChildAt(i).setLayoutParams(lp);
- }
- }
- }
- /**
- * Set a listener for this widget actions
- * @param l the listener called back when some user action is done on this widget
- */
- public void setOnDialActionListener(OnDialActionListener l) {
- actionListener = l;
- }
- /**
- * Set the action buttons enabled or not
- */
- public void setEnabled(boolean enabled) {
- findViewById(R.id.dialButton).setEnabled(enabled);
- findViewById(R.id.dialVideoButton).setEnabled(enabled);
- findViewById(R.id.deleteButton).setEnabled(enabled);
- }
- @Override
- public void onClick(View v) {
- if (actionListener != null) {
- int viewId = v.getId();
- if (viewId == R.id.dialVideoButton) {
- actionListener.placeVideoCall();
- }else if(viewId == R.id.dialButton) {
- actionListener.placeCall();
- }else if(viewId == R.id.deleteButton) {
- actionListener.deleteChar();
- }
- }
- }
- @Override
- public boolean onLongClick(View v) {
- if (actionListener != null) {
- int viewId = v.getId();
- if(viewId == R.id.deleteButton) {
- actionListener.deleteAll();
- v.setPressed(false);
- return true;
- }
- }
- return false;
- }
- }
pjsip视频通信开发(上层应用)之拨号键盘下部份拨号和删除功能的更多相关文章
- pjsip视频通信开发(上层应用)之数字键盘的制作
在pjsip视频通信开发(上层应用)之EditText重写中我制作了一个显示输入内容的EditText,这里将制作一个数字键盘,其实跟计算器一样,最多的就是用TableLayout来实现,内部通过权重 ...
- pjsip视频通信开发(上层应用)之拨号界面整体界面功能实现
在前面的几章里面写了显示.键盘.拨号.删除功能,这里我将他们进行组合,形成一个拨号键盘全部功能.首先是布局 <LinearLayout xmlns:android="http://sc ...
- pjsip视频通信开发(上层应用)之EditText重写
我们经常使用手机的打电话功能,当我们按键盘的时候,有一个地方显示我们按键的内容,当我们的手点击那个地方的时候,并没有弹出软件盘,所以我们再有数字键盘的时候,要屏蔽系统的软件盘. 我们分析一下,软件盘弹 ...
- pjsip视频通信开发(底层实现)之用户注册(1)
一.PJSIP简介 对于pjsip的介绍可以看http://www.cnblogs.com/my_life/articles/2175462.html 文章,里面详细介绍了它的组成框架以及各部份的组成 ...
- Android IOS WebRTC 音视频开发总结(七五)-- WebRTC视频通信中的错误恢复机制
本文主要介绍WebRTC视频通信中的错误恢复机制(我们翻译和整理的,译者:jiangpeng),最早发表在[这里] 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信ID:blac ...
- Web实现音频、视频通信
Google开源实时通信项目WebRTC Google正式开源了WebRTC实时通信项目,希望浏览器厂商能够将该技术内建在浏览器中,从而使Web应用开发人员能够通过HTML标签和JavaScript ...
- Android 串口蓝牙通信开发Java版本
Android串口BLE蓝牙通信Java版 0. 导语 Qt on Android 蓝牙通信开发 我们都知道,在物联网中,BLE蓝牙是通信设备的关键设备.在传统的物联网应用中,无线WIFI.蓝牙和Zi ...
- p2p音视频通信
今年音频没事干了,根据业务需求,调研音视频p2p通信,减小服务器压力,一切从0开始. 需要信令服务器,打洞服务器,帮助链接打通双方,实现p2p音视频通信. 服务器和客服端交互等都需要实现. 谷歌web ...
- 《转》iOS音频视频初级开发
代码改变世界 Posts - 73, Articles - 0, Comments - 1539 Cnblogs Dashboard Logout HOME CONTACT GALLERY RSS ...
随机推荐
- Delphi or函数的用法
function GetFlag(a: string): Integer;var I: Integer;begin Result := 0; for I := 0 to 3 - 1 do begin ...
- 锋利的jQuery读书笔记---jQuery中的事件
jQuery中的事件: 1.加载DOM:注意window.onload和$(document).ready()的不同 2.事件绑定 3.合成事件 --2和3的详细信息见代码- <!DOCTYPE ...
- View.VISIBLE、INVISIBLE、GONE的区别
android中UI应用的开发中经常会使用view.setVisibility()来设置控件的可见性,其中该函数有3个可选值,他们有着不同的含义: View.VISIBLE--->可见View. ...
- 《Python CookBook2》 第一章 文本 - 检查字符串中是否包含某字符集合中的字符 && 简化字符串的translate方法的使用
检查字符串中是否包含某字符集合中的字符 任务: 检查字符串中是否出现了某个字符集合中的字符 解决方案: 方案一: import itertools def containAny(seq,aset): ...
- Windows安装pomelo过程
安装总要出点状况的.操作系统是win7 64bit. 为了保证顺利,打开的是VS2012命令行提示.运行 npm install -g pomelo 经过一系列输出,最后安装提示完成了.但是输入 po ...
- oracle检查点checkpoint信息
1.关于checkpoint的概述 checkpoint是oracle在数据库一致性关闭.实例恢复和oracle基本操作中不可缺少的机制,包含以下相关的含义: A.检查点的位置(checkpoint ...
- c++ 概念及学习/c++ concept&learning(三)
这一篇继续说说程序设计中的基本语句:控制块 一 if类控制语句 if if else if , else if ,else if(条件语句){如果条件为真,要做的一些事情} if(条件语句) {如 ...
- python编码问题的理解与解决
错误:'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) 看到网上很多都不清楚,做了一天的 ...
- as3 中trace() 函数对效率的影响
进行页游开发的过程中,很多开发者都有一个习惯,在数据输出中添加trace()函数来跟踪数值 - 不进行条件编译,发布的时候也不删除.实际上大量的trace函数会降低程序的效率,我们可以用一个简单的例子 ...
- URL的格式scheme
url scheme: scheme + (://) + userinfo + (@) + hostname + (:) + port + path + (?) + query + (#) + fra ...