标签:android开发
1 组件监听事件,业务逻辑之前判断网络情况
public abstract class OnClickNetworkListener implements View.OnClickListener { @Override public void onClick(View v) { boolean isNetworkOk = Config.isNetworkConnected(Config.currentContext); if (isNetworkOk) { onNetworkClick(v); } else { Toast.makeText(Config.currentContext, SysConfig.NETWORK_FAIL, Toast.LENGTH_SHORT).show(); } } public abstract void onNetworkClick(View v); }
2 组件监听事件,业务逻辑之前判断是否点击过快重复点击
public abstract class OnClickFastListener implements View.OnClickListener{ private static long lastClickTime; public static boolean isFastDoubleClick() { long time = System.currentTimeMillis(); long timeD = time - lastClickTime; if ( 0 < timeD && timeD < 500) { return true; } lastClickTime = time; return false; } @Override public void onClick(View v) { if (OnClickFastListener.isFastDoubleClick()) { return; } onFastClick(v); } public abstract void onFastClick(View v); }
版权声明:本文为博主原创文章,未经博主允许不得转载。
android自定义组件监听,监听网络,防止组件点击过快重复点击
标签:android开发
原文地址:http://blog.csdn.net/qq_23547831/article/details/47831787