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 ...
随机推荐
- View.VISIBLE、INVISIBLE、GONE的区别
android中UI应用的开发中经常会使用view.setVisibility()来设置控件的可见性,其中该函数有3个可选值,他们有着不同的含义: View.VISIBLE--->可见View. ...
- POJ 1077 Eight
题意:经典的八数码=3= 3*3的格子,里面有1~8这8个数字,还有一个空格x,移动空格的位置,直到移到1~8按顺序排好,输出移动的序列. 解法:看到题果断写了个广搜……然后T了……百度了一下说广搜虽 ...
- poj 4052(ac自动机)
题意:自己百度吧!! 分析:就是通过它的fail指针来找出它的子串就行了,这题其实不难的.这好像还是金华邀请赛的题哦! 代码实现: #include<cstdio> #include< ...
- IOS 点击按钮 光环 冲击波效果
UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 0) radius:ROUND_WIDTH/2 - ...
- 基于wke封装的duilib的webkit浏览器控件,可以c++与js互交,源码及demo下载地址
转载请说明原出处,谢谢~~ 前些日子用wke内核封装了duilib的webkit浏览器控件,好多群里朋友私聊我希望可以我公布源码,今天把这个控件的源码和使用demo公布.其实这个控件封装起来没什么难度 ...
- DataGird导出EXCEL的几个方法
DataGird导出EXCEL的几个方法(WebControl) using System;using System.Data;using System.Text;using System.Web;u ...
- codevs3044 线段树+扫描线
3044 矩形面积求并 http://hzwer.com/879.html 扫描线 // #pragma comment(linker, "/STACK:1024000000,1024000 ...
- Tkinter教程之Message篇
本文转载自:http://blog.csdn.net/jcodeer/article/details/1811326 '''Tkinter教程之Message篇'''#Message也是用来显示文本的 ...
- Some_problem_with_octopress
今天我总算是使用上了高大上的octopress了,不容易啊,现在我把之前的博客全部搬到了octopress上了,在github上办博客让我不用再担心流量和广告了!---爽啊 我使用octopress时 ...
- linux 系统维护命令
cat /home/username/.bash_history :查看用户的历史操作记录 (centos , mac 支持) last -x : 使用root登陆使用last -x可查看用户登陆历史 ...