资源简介
个人做二维码扫描,觉得效果还不错,留存以后用
代码片段和文件信息
/*
* Copyright (C) 2012 ZXing authors
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.toltech.treefrog.qrcodescanner;
import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.preference.PreferenceManager;
import cn.toltech.treefrog.qrcodescanner.camera.CameraManager;
import cn.toltech.treefrog.qrcodescanner.camera.FrontLightMode;
/**
* Detects ambient light and switches on the front light when very dark and off again when sufficiently light.
*
* @author Sean Owen
* @author Nikolaus Huber
*/
final class AmbientLightManager implements SensorEventListener {
private static final float TOO_DARK_LUX = 45.0f;
private static final float BRIGHT_ENOUGH_LUX = 450.0f;
private final Context context;
private CameraManager cameraManager;
private Sensor lightSensor;
AmbientLightManager(Context context) {
this.context = context;
}
void start(CameraManager cameraManager) {
this.cameraManager = cameraManager;
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
if (lightSensor != null) {
sensorManager.registerListener(this lightSensor SensorManager.SENSOR_DELAY_NORMAL);
}
}
}
void stop() {
if (lightSensor != null) {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
sensorManager.unregisterListener(this);
cameraManager = null;
lightSensor = null;
}
}
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float ambientLightLux = sensorEvent.values[0];
if (cameraManager != null) {
if (ambientLightLux <= TOO_DARK_LUX) {
cameraManager.setTorch(true);
} else if (ambientLightLux >= BRIGHT_ENOUGH_LUX) {
cameraManager.setTorch(false);
}
}
}
@Override
public void onAccuracyChanged(Sensor sensor int accuracy) {
// do nothing
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2934 2015-10-28 09:18 qrcodescanner\AmbientLightManager.java
文件 4594 2015-10-28 09:19 qrcodescanner\BeepManager.java
文件 4326 2015-10-28 09:08 qrcodescanner\camera\AutoFocusManager.java
文件 5800 2015-10-28 09:08 qrcodescanner\camera\CameraConfigurationManager.java
文件 16993 2015-10-28 09:08 qrcodescanner\camera\CameraConfigurationUtils.java
文件 13706 2015-10-29 13:51 qrcodescanner\camera\CameraManager.java
文件 1312 2015-10-28 09:13 qrcodescanner\camera\FrontLightMode.java
文件 2521 2015-10-28 09:08 qrcodescanner\camera\open\OpenCameraInterface.java
文件 1923 2015-10-28 09:08 qrcodescanner\camera\PreviewCallback.java
文件 11712 2015-10-30 11:02 qrcodescanner\CaptureActivity.java
文件 5926 2015-10-29 10:10 qrcodescanner\CaptureActivityHandler.java
文件 3923 2015-10-28 09:08 qrcodescanner\Contents.java
文件 4116 2015-10-28 09:08 qrcodescanner\DecodeFormatManager.java
文件 4304 2015-10-29 10:08 qrcodescanner\DecodeHandler.java
文件 4107 2015-10-29 09:55 qrcodescanner\DecodeThread.java
文件 3487 2015-10-28 09:08 qrcodescanner\InactivityTimer.java
文件 10414 2015-10-28 09:08 qrcodescanner\Intents.java
文件 762 2015-10-28 09:08 qrcodescanner\IntentSource.java
文件 3205 2015-10-28 09:08 qrcodescanner\PreferencesActivity.java
文件 4481 2015-10-28 09:23 qrcodescanner\PreferencesFragment.java
文件 11924 2015-10-29 13:57 qrcodescanner\view\ViewfinderView.java
文件 1195 2015-10-28 09:23 qrcodescanner\ViewfinderResultPointCallback.java
目录 0 2015-10-28 09:08 qrcodescanner\camera\open
目录 0 2015-10-29 13:51 qrcodescanner\camera
目录 0 2015-10-29 13:57 qrcodescanner\view
目录 0 2015-10-30 11:02 qrcodescanner
----------- --------- ---------- ----- ----
123665 26
相关资源
- android中listview的item滑动删除效果已解
- android仿iphone日期时间选择控件
- weibosdkcore.jar
- Android下的推箱子游戏
- 基于WebSocket实现的Android和H5聊天通讯
- Android安卓逆向教程
- Android代码-EffortlessPermissions
- Android-运动步数修改器
- Android手势识别的实现源码.rar
- Android应用源码给安卓app加密码的项目
- Android-CircularSeekBar用于Android的定制圆
- Android益智类游戏开发源码
- Android 仿新浪微博客户端APP源码.rar
- 安卓音乐播放器-乐看播放器源码.ra
- Android 指南针的源码实现.rar
- Android 安卓管理日志,所有输出日志保
- android调用C语言实现内存的读取与修改
- Android实现过渡动画、引导页 Android判
- Android实现画板、写字板功能
- android实现简单的画画板代码
- Android实现QQ侧滑(删除、置顶等)功
- 基于Android技术的北斗/GPS车载导航系统
- android java和webview交互demo
- glide jar包
- slf4j-api-1.7.2.jar
- Android黑白名单的来店拦截
- Android仿qq消息列表
- Android应用源码蓝牙串口搜索配对连接
- Ubuntu14.04编译android4.4源码一次性成功
- Android Studio使用JNI调用C代码 demo \“
评论
共有 条评论