Commit 26882168 by tangguangrui

Initial commit

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
introduction.txt
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
#NDK
obj/
*.swp
*~
/build
/debug
/release
apply plugin: 'com.android.application'
def APP_VSN = "1.0.1"//版本号
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "cn.runworld.mctower.visitor"
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// 设置支持的SO库架构
abiFilters 'armeabi-v7a' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
debug {
storeFile file('mctower.keystore')
storePassword "mctower123321"
keyAlias "mctower"
keyPassword "mctower123321"
}
}
buildTypes {
release {
minifyEnabled false //是否混淆
shrinkResources false
debuggable false
jniDebuggable false
signingConfig signingConfigs.debug
buildConfigField("boolean", "SHOW_LOG", "false")//是否显示log信息
buildConfigField("boolean", "SAVE_LOG_TO_SDCARD", "false")//是否将log信息保存到sd卡
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "APPVsn", sprintf("\"%s\"", APP_VSN))
}
debug {
minifyEnabled false//是否混淆
shrinkResources false
debuggable true
jniDebuggable true
signingConfig signingConfigs.debug
buildConfigField("boolean", "SHOW_LOG", "true")//是否显示log信息
buildConfigField("boolean", "SAVE_LOG_TO_SDCARD", "false")//是否将log信息保存到sd卡
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "APPVsn", sprintf("\"%s\"", APP_VSN))
}
}
//android SDK 6.0以后取消了HttpClient相关jar包,如果需要使用需要添加这行代码
// useLibrary 'org.apache.http.legacy'
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
// 生成的包名信息
android.applicationVariants.all { variant ->
variant.outputs.all {
def date = new Date().format("yyyyMMddHHmmss", TimeZone.getTimeZone("GMT+08"))
outputFileName = "mctower_V" + "${variant.versionName}_${date}_" + variant.buildType.name + ".apk"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.6'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//xUtils
implementation files('libs/xUtils-2.6.14.jar')
//身份证相关库
implementation files('libs/idcard.jar')
implementation files('libs/invsusb.jar')
//KLog
implementation 'com.github.zhaokaiqiang.klog:library:1.6.0'
//权限检测库
implementation 'pub.devrel:easypermissions:1.2.0'
//gson
implementation 'com.google.code.gson:gson:2.8.5'
//网络图片加载
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
//图片加载库,后续适配androidx的时候,升级PhotoView版本
api 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.9'
//七牛
implementation 'com.qiniu:qiniu-android-sdk:7.3.15'
implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'
implementation 'com.tencent.bugly:nativecrashreport:latest.release'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-dontwarn com.tencent.bugly.**
#-keep public class com.tencent.bugly.**{*;}
\ No newline at end of file
package cn.mctower.visitor;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("cn.mctower.visitor", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cn.mctower.visitor">
<application
android:name=".MCTowerApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".MainActivity"
android:theme="@style/Theme.MyAppCompatTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DetailActivity"
android:theme="@style/Theme.MyAppCompatTheme"
android:windowSoftInputMode="adjustPan"/>
<service android:name="com.brilliants.idcardlib.IDCardService"/>
</application>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_LOGS" />
</manifest>
\ No newline at end of file
package cn.dankal.base.activity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import cn.dankal.base.interfaces.IBaseInterface;
import cn.dankal.base.interfaces.IHotpicJumpCallBack;
import cn.dankal.base.interfaces.IPermissionCheck;
import cn.dankal.base.utils.LogUtils;
import cn.dankal.base.utils.ToastUtils;
import cn.dankal.base.utils.Utils;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
/**
* @类名: BaseActivity
* @功能描述: 基础Activity
* @创建人: Alex
*/
public class BaseAppCompatActivity extends AppCompatActivity implements
IBaseInterface,IHotpicJumpCallBack,
EasyPermissions.PermissionCallbacks{
protected String TAG = this.getClass().getSimpleName();
private Handler handler = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void show(String message) {
ToastUtils.show(message);
}
@Override
public void show(int resourceId) {
show(getResources().getString(resourceId));
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
public final <E extends View> E getView(int id) {
try {
return (E) findViewById(id);
} catch (ClassCastException ex) {
LogUtils.e("getView error",
"Could not cast View to concrete class.");
throw ex;
}
}
@Override
public void jumpActivity(Class<? extends Activity> clazz, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
startActivity(intent);
}
}else{
Intent intent = new Intent(this, clazz);
startActivity(intent);
}
}
@Override
public void jumpActivity(Class<? extends Activity> clazz, int flag, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
intent.setFlags(flag);
startActivity(intent);
}
}else{
Intent intent = new Intent(this, clazz);
intent.setFlags(flag);
startActivity(intent);
}
}
@Override
public void jumpActivityForResult(Class<? extends Activity> clazz,
int requestCode, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
startActivityForResult(intent, requestCode);
}
}else{
Intent intent = new Intent(this, clazz);
startActivityForResult(intent, requestCode);
}
}
@Override
public void jumpActivityForResult(Class<? extends Activity> clazz, Bundle data,
int requestCode, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
startActivityForResult(intent, requestCode);
}
}else {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
startActivityForResult(intent, requestCode);
}
}
@Override
public void jumpActivity(Class<? extends Activity> clazz, Bundle data, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
startActivity(intent);
}
}else {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
startActivity(intent);
}
}
@Override
public void jumpActivity(Class<? extends Activity> clazz, Bundle data,
int flag, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
intent.setFlags(flag);
startActivity(intent);
}
}else {
Intent intent = new Intent(this, clazz);
intent.putExtras(data);
intent.setFlags(flag);
startActivity(intent);
}
}
@Override
public void jumpActivity(Intent intent, boolean needLogin) {
if(needLogin) {
if (isLogin()) {
startActivity(intent);
}
}else {
startActivity(intent);
}
}
@Override
public boolean isLogined() {
return false;
}
/**
* 检测是否登录,如果未登录会自动开启登录页面
*/
public boolean isLogin(){
if(!isLogined()){
//TODO 没有登录的话需要进入登录页面
return false;
}
return true;
}
@Override
public void doJump(Intent intent) {
startActivity(intent);
}
@Override
public void doCloseCurrentPage() {
finish();
}
@Override
public void doSendBroadcast(Intent intent) {
sendBroadcast(intent);
}
@Override
public void postRunnable(Runnable runnable) {
if(runnable != null) {
if(handler == null)
handler = new Handler();
handler.post(runnable);
}
}
private IPermissionCheck permissionRequestCallback;
private int permissionRequestCode;
public void requestPermissions(@NonNull String[] permissions, @NonNull int code, @NonNull String reason, IPermissionCheck callback){
permissionRequestCallback = callback;
permissionRequestCode = code;
//判断有没有权限
if (EasyPermissions.hasPermissions(this, permissions)) {
LogUtils.e("aaa","************hasPermissions");
// 如果有权限了, 就做你该做的事情
if(permissionRequestCallback != null)
permissionRequestCallback.hasGotPermissions(code);
} else {
// 如果没有权限, 就去申请权限
// this: 上下文
// Dialog显示的正文
// code 请求码, 用于回调的时候判断是哪次申请
// perms 就是你要申请的权限
LogUtils.e("aaa","************has NO Permissions");
EasyPermissions.requestPermissions(this, reason, code, permissions);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// 将返回结果转给EasyPermissions
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
@Override
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
permissionRequestCallback.hasGotPermissions(permissionRequestCode);
}
@Override
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
new AppSettingsDialog.Builder(this)
.setTitle("权限已经被您拒绝")
.setRationale("如果不打开权限则app可能有部分功能无法正常使用,点击确定去打开权限")
.setRequestCode(requestCode)//用于onActivityResult回调做其它对应相关的操作
.build()
.show();
}
/**
* 设置状态栏的颜色
* @param activity
* @param colorId
*/
public static void setStatusBarColor(Activity activity, int colorId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(activity.getResources().getColor(colorId));
}
}
protected static void setAndroidNativeLightStatusBar(Activity activity, boolean dark) {
View decor = activity.getWindow().getDecorView();
if (dark) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (isShouldHideInput(v, ev)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
return super.dispatchTouchEvent(ev);
}
// 必不可少,否则所有的组件都不会有TouchEvent了
if (getWindow().superDispatchTouchEvent(ev)) {
return true;
}
return onTouchEvent(ev);
}
public boolean isShouldHideInput(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] leftTop = { 0, 0 };
//获取输入框当前的location位置
v.getLocationInWindow(leftTop);
int left = leftTop[0];
int top = leftTop[1];
int bottom = top + v.getHeight();
int right = left + v.getWidth();
if (event.getX() > left && event.getX() < right
&& event.getY() > top && event.getY() < bottom) {
// 点击的是输入框区域,保留点击EditText的事件
return false;
} else {
return true;
}
}
return false;
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
}
}
package cn.dankal.base.activity;
import android.app.ActionBar;
import android.app.Dialog;
import cn.dankal.base.dialog.BaseLoadingDialog;
import cn.dankal.base.interfaces.INetBaseInterface;
import cn.mctower.visitor.R;
/**
* @类名: NetBaseActivity
* @功能描述: 网络基础Activity
* @创建人: Alex
*/
public class NetBaseAppCompatActivity extends BaseAppCompatActivity implements INetBaseInterface {
public static final String TAG = "NetBaseAppCompatActivity";
/**
* 操作提示Dialog
*/
protected String title = "";
protected ActionBar actionBar;
public Dialog mAlertDialog;
@Override
public Dialog createDialog() {
if (mAlertDialog == null)
mAlertDialog = new BaseLoadingDialog(this, R.style.basedDialogStyle);
return mAlertDialog;
}
@Override
protected void onDestroy() {
if (mAlertDialog != null && mAlertDialog.isShowing()) {
mAlertDialog.dismiss();
}
super.onDestroy();
}
/**
* 显示加载动画
*/
public void showLoadingDialog(){
createDialog();
mAlertDialog.show();
}
/**
* 关闭加载动画
*/
public void dismmisLoadingDialog(){
if(mAlertDialog != null && mAlertDialog.isShowing())
mAlertDialog.dismiss();
}
}
package cn.dankal.base.dialog;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import cn.dankal.base.utils.UIUtil;
import cn.mctower.visitor.R;
public class BaseLoadingDialog extends Dialog {
public BaseLoadingDialog(Context context, int theme) {
super(context, theme);
View view = LayoutInflater.from(context).inflate(
R.layout.base_dialog_circle, null);
//设定布局
this.getWindow().setGravity(Gravity.CENTER);
this.getWindow().setLayout(UIUtil.Dp2Px(context,60),UIUtil.Dp2Px(context,60));
this.getWindow().setContentView(view);
this.setCanceledOnTouchOutside(false);
}
@Override
public void onBackPressed() {
//进度条显示时不允许后退
if(this.isShowing())
return;
else
super.onBackPressed();
}
}
package cn.dankal.base.http;
import android.app.Dialog;
import android.text.TextUtils;
import org.json.JSONException;
import org.json.JSONObject;
import cn.dankal.base.activity.NetBaseAppCompatActivity;
import cn.dankal.base.interfaces.IHttpCallBack;
import cn.dankal.base.interfaces.INetBaseInterface;
import cn.dankal.base.utils.LogUtils;
public class DialogHttpCallBack implements IHttpCallBack {
/**
* 操作提示Dialog
*/
private Dialog mAlertDialog;
private INetBaseInterface activity;
public String msg = "";
public boolean showInfoWhenRequestSuccess = true;
public DialogHttpCallBack(INetBaseInterface activity) {
this.activity = activity;
this.mAlertDialog = activity.createDialog();
}
public DialogHttpCallBack(INetBaseInterface activity,boolean autoShowInfo) {
this(activity);
showInfoWhenRequestSuccess = autoShowInfo;
}
@Override
public void requestStart() {
if (mAlertDialog == null) {
mAlertDialog = activity.createDialog();
}
if(activity != null){
if(activity instanceof NetBaseAppCompatActivity){
if(((NetBaseAppCompatActivity)activity).isFinishing()){
return;
}else{
mAlertDialog.show();
}
}else
return;
}
}
/**
* 请求成功,如果服务器返回状态为1时,会对用户的基本信息进行本地保存
* @param result
*/
@Override
public void requestSuccess(String result) {
successCallBack(result);
}
/**
* 当服务器返回状态为0时调用该接口
* @param result
*/
@Override
public void requestFailure(String code, String result) {
activity.show(result);
}
@Override
public void requestOffLine() {
}
@Override
public void requestFinish() {
if (mAlertDialog != null && mAlertDialog.isShowing()) {
mAlertDialog.cancel();
}
}
/**
* 当服务器返回状态为1时调用该接口返回data属性的string内容
* @param result
*/
@Override
public void successCallBack(String result) {
}
@Override
public void downLoadSuccess(String result) {
}
@Override
public void downLoadFailure(String result) {
}
@Override
public void saveUserVarsData(String varsJson) {
}
public String getInfo(){
return msg;
}
}
package cn.dankal.base.http;
import cn.dankal.base.interfaces.IDownloadFileCallBack;
/**
* Created by Alex Tang on 2016/5/17.
*/
public class FileDownloadHttpCallBack implements IDownloadFileCallBack {
@Override
public void downloadStart() {
}
@Override
public void downloadSuccess(String result) {
}
@Override
public void downloadFailure(String result) {
}
}
package cn.dankal.base.http;
import android.text.TextUtils;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import cn.dankal.base.interfaces.IHttpCallBack;
import cn.dankal.base.utils.LogUtils;
import cn.mctower.visitor.MCTowerApplication;
public class HttpCallBack implements IHttpCallBack {
@Override
public void requestStart() {
}
/**
* 请求成功,如果服务器返回状态为1时,会对用户的基本信息进行本地保存
* @param result
*/
@Override
public void requestSuccess(String result) {
String msg;
try {
JSONObject obj = new JSONObject(result);
int status = obj.optInt("status", 0);
if (status == 200) {
String data = obj.optString("data");
String vars = obj.optString("vars");
if(!TextUtils.isEmpty(vars)){
saveUserVarsData(vars);
}
data = data.replace("\"page\":[]","\"page\":{}");
data = data.replace("\"page\":\"\"","\"page\":{}");
data = data.replace("\"last_time\":[]","\"last_time\":{}");
successCallBack(data);
} else {
msg = obj.optString("info", "服务器繁忙,请稍后再试!");
requestFailure(String.valueOf(status),msg);
}
} catch (JSONException e) {
msg = "服务器返回数据出错!";
requestFailure("-1",msg);//app数据解析错误
LogUtils.e("解析失败", e.getMessage());
}
}
/**
* 当服务器返回状态为0时调用该接口
* @param result
*/
@Override
public void requestFailure(String code, String result) {
Toast.makeText(MCTowerApplication.getContext(), result, Toast.LENGTH_SHORT).show();
}
@Override
public void requestOffLine() {
}
@Override
public void requestFinish() {
}
/**
* 当服务器返回状态为1时调用该接口返回data属性的string内容
* @param result
*/
@Override
public void successCallBack(String result) {
}
@Override
public void downLoadSuccess(String result) {
}
@Override
public void downLoadFailure(String result) {
}
@Override
public void saveUserVarsData(String varsJson) {
}
}
package cn.dankal.base.http;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.widget.Toast;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.socks.library.KLog;
import org.apache.http.entity.StringEntity;
import java.io.File;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.dankal.base.interfaces.IHttpCallBack;
import cn.dankal.base.interfaces.IHttpPostFileCallBack;
import cn.dankal.base.utils.LogUtils;
import cn.dankal.base.utils.StringUtils;
import cn.dankal.base.utils.ToastUtils;
import cn.dankal.base.utils.Utils;
public class HttpPostHelper {
public static final String TAG = HttpPostHelper.class.getSimpleName();
public static void httpGet(final Context context, final String url,
final IHttpCallBack callback, final HashMap<String, String> map) {
if (!Utils.isNetworkAvailable(context)) {
Toast.makeText(context, "请打开网络!", Toast.LENGTH_LONG).show();
callback.requestOffLine();
return;
}
String str = getURLAndParameter(url, map);
LogUtils.e("url", str);
RequestParams params = new RequestParams();
if(map != null)
for (String strKey : map.keySet()) {
// params.addBodyParameter(strKey, map.get(strKey));
params.addQueryStringParameter(strKey,map.get(strKey));
}
HttpUtils http = new HttpUtils();
http.configCurrentHttpCacheExpiry(100);
http.send(HttpRequest.HttpMethod.GET, url, params,
new RequestCallBack<String>() {
@Override
public void onStart() {
callback.requestStart();
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
LogUtils.e("result", responseInfo.result);
callback.requestSuccess(responseInfo.result);
callback.requestFinish();
// saveCookie(responseInfo.getAllHeaders());
}
@Override
public void onFailure(HttpException error, String msg) {
LogUtils.e("请求失败:", msg);
callback.requestFailure("-3","请求失败!");
callback.requestFinish();
}
});
}
public static void httpPutJson(final Context context, final String url,
final IHttpCallBack callback, final String json) {
if (!Utils.isNetworkAvailable(context)) {
Toast.makeText(context, "请打开网络!", Toast.LENGTH_LONG).show();
callback.requestOffLine();
return;
}
String str = getURLAndParameter(url, null);
RequestParams params = new RequestParams();
params.setContentType("application/json");
try {
params.setBodyEntity(new StringEntity(json, "UTF-8"));
HttpUtils http = new HttpUtils();
http.send(HttpRequest.HttpMethod.PUT, url, params,
new RequestCallBack<String>() {
@Override
public void onStart() {
callback.requestStart();
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
LogUtils.e("result", responseInfo.result);
callback.requestSuccess(responseInfo.result);
callback.requestFinish();
}
@Override
public void onFailure(HttpException error, String msg) {
LogUtils.e("请求失败:", "error : " +msg + error.getLocalizedMessage());
callback.requestFailure("-3","请求失败!");
callback.requestFinish();
}
});
LogUtils.e("url", str);
LogUtils.e("body", json);
}catch (Exception e){
e.printStackTrace();
}
}
public static void httpPost(final Context context, final String url,
final IHttpCallBack callback, HashMap<String, String> map, int retryTimes) {
if (!Utils.isNetworkAvailable(context)) {
LogUtils.e(TAG, "isNetworkAvailable = false");
ToastUtils.show("您的设备目前没有连接网络!");
// ToastUtils.show("您的设备目前没有连接网络!");
callback.requestOffLine();
callback.requestFailure("-2","网络连接失败,请查看网络连接");
KLog.e("HttpPost***url=" + url + "\n" + "请求失败:网络连接失败,请查看网络连接");
callback.requestFinish();
return;
}
//参加参数
RequestParams params = new RequestParams();
HashMap<String, String> allParams = createAllParams(context, map);
for (String strKey : allParams.keySet()) {
//添加普通参数
params.addBodyParameter(strKey, allParams.get(strKey));
params.addQueryStringParameter(strKey,allParams.get(strKey));
// LogUtils.e(TAG,"["+strKey+","+allParams.get(strKey)+"]");
}
// params.setHeader("X-Access-Token","d7d3353c3c54fe8383b584a165e65e12");
//获得完整的访问Url
String str = getURLAndParameter(url, allParams);
LogUtils.e("url", "HttpPostRequest*** url ="+str);
final String urlLog = str;
final HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(30 * 1000);
if(retryTimes > 0)
http.configRequestRetryCount(retryTimes);
http.configRequestThreadPoolSize(5);
LogUtils.e(TAG,"REQUEST URL = "+url);
http.send(HttpRequest.HttpMethod.POST, url, params,
new RequestCallBack<String>() {
@Override
public void onStart() {
KLog.e("HttpPostRequest*** 开始请求["+ System.currentTimeMillis()+"] url=" + url);
callback.requestStart();
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = responseInfo.result;
KLog.e("HttpPostRequest*** 请求成功[" + System.currentTimeMillis() + "] url=" + url + "--" + ":结果:【size=" + result.length() + "】" + result);
callback.requestSuccess(result);
callback.requestFinish();
}
@Override
public void onFailure(HttpException error, String msg) {
KLog.e("HttpPostRequest*** 请求失败["+ System.currentTimeMillis()+"] url=" + url + "--" + "错误信息:"+msg);
callback.requestFailure("-3","网络开小差啦,请重试呦。。。");
callback.requestFinish();
}
});
}
public static void httpPostFiles(final Context context, final String url, final IHttpPostFileCallBack callback , ArrayList<File> files, HashMap<String,String> para){
if (!Utils.isNetworkAvailable(context)) {
LogUtils.e(TAG, "isNetworkAvailable = false");
Toast.makeText(context,"您的设备目前没有连接网络!", Toast.LENGTH_SHORT).show();
// ToastUtils.show("您的设备目前没有连接网络!");
callback.requestOffLine();
callback.requestFailure("网络连接失败,请查看网络连接");
KLog.e("HttpPost***url=" + url + "\n" + "请求失败:网络连接失败,请查看网络连接");
callback.requestFinish();
return;
}
RequestParams params = new RequestParams();
if(files != null) {
int i = 0;
for (File file : files) {
if (file.exists()) {
i ++;
params.addBodyParameter("img"+i, file, "image/jpg");
LogUtils.e("111","img"+i+":"+file.getPath()+"/"+file.getName());
}
}
}
HashMap<String, String> allParams = createAllParams(context, para);
for (String strKey : allParams.keySet()) {
//添加普通参数
params.addBodyParameter(strKey, allParams.get(strKey));
}
//获得完整的访问Url
String str = getURLAndParameter(url, allParams);
LogUtils.e("url", "HttpPostRequest*** url ="+str);
HttpUtils http = new HttpUtils();
http.configRequestThreadPoolSize(5);
http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
@Override
public void onCancelled() {
if(callback != null)
callback.onCancle();
}
@Override
public void onStart() {
KLog.e("HttpPostRequest*** 开始请求["+ System.currentTimeMillis()+"] url=" + url);
if(callback != null)
callback.requestStart();
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
KLog.e("HttpPostRequest*** onLoading ["+ System.currentTimeMillis()+"] url=" + url + "--" + "进度:"+total+"/"+current);
//这里可以增加loading,或进度条开始
if(callback != null)
callback.onLoading(total,current);
}
@Override
public void onFailure(HttpException arg0, String arg1) {
KLog.e("HttpPostRequest*** 请求失败["+ System.currentTimeMillis()+"] url=" + url + "--" + "错误信息:"+arg1);
//请求失败,可做异常提示处理和loading、进度条消失
if(callback != null)
callback.requestFailure(arg1);
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
KLog.e("HttpPostRequest*** 请求成功["+ System.currentTimeMillis()+"] url=" + url + "--" + ":结果:【size="+responseInfo.result.length()+"】"+responseInfo.result);
//请求成功,做相应处理和loading、进度条消失
if(callback != null) {
callback.successCallBack(responseInfo.result);
}
}
});
}
public static void httpPost(final Context context, String url,
final IHttpCallBack callback, HashMap<String, String> map) {
httpPost(context, url, callback, map, 0);
}
/* *//**
*
* @param context
* @param url
* @param callback
*//*
public static void downLoad(final Context context, String url, final IHttpCallBack callback) {
if (!Utils.isNetworkAvailable(context)) {
Toast.makeText(context, "请打开网络!", Toast.LENGTH_LONG).show();
callback.requestOffLine();
return;
}
//获得app名称
int m = url.lastIndexOf("/");
int n = url.length();
if (url.toLowerCase().endsWith(".apk")) {
n = url.length();
} else {
n = url.toLowerCase().lastIndexOf(".apk?") + 4;
}
String str = url.substring(m + 1, n);
LogUtils.e("apk下载地址", "apk名称: " + str);
String downLoadPath = Constant.BaseImagesDir + str;
HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(30 * 1000);
http.download(url, downLoadPath, false, false, new RequestCallBack<File>() {
@Override
public void onStart() {
callback.requestStart();
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
super.onLoading(total, current, isUploading);
}
@Override
public void onSuccess(ResponseInfo<File> responseInfo) {
callback.downLoadSuccess(responseInfo.result.getPath());
}
@Override
public void onFailure(HttpException e, String s) {
callback.downLoadFailure(s);
}
});
}
*/
public static void httpPostWithoutCommonParams(final Context context, String url,
final IHttpCallBack callback, HashMap<String, String> map) {
if (!Utils.isNetworkAvailable(context)) {
Toast.makeText(context, "请打开网络!", Toast.LENGTH_LONG).show();
callback.requestOffLine();
return;
}
RequestParams params = new RequestParams();
if(map != null && map.size() > 0)
for (String strKey : map.keySet()) {
params.addBodyParameter(strKey, map.get(strKey));
}
final HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(30 * 1000);
http.send(HttpRequest.HttpMethod.POST, url, params,
new RequestCallBack<String>() {
@Override
public void onStart() {
callback.requestStart();
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
LogUtils.e("result", responseInfo.result);
callback.requestSuccess(responseInfo.result);
callback.requestFinish();
}
@Override
public void onFailure(HttpException error, String msg) {
LogUtils.e("请求失败:", msg);
callback.requestFailure("-3","请求失败!");
callback.requestFinish();
}
});
}
public static void httpGetWithoutCommonParams(final Context context, String url,
final IHttpCallBack callback) {
if (!Utils.isNetworkAvailable(context)) {
return;
}
final HttpUtils http = new HttpUtils();
http.configDefaultHttpCacheExpiry(30 * 1000);
http.send(HttpRequest.HttpMethod.GET, url, null,
new RequestCallBack<String>() {
@Override
public void onStart() {
callback.requestStart();
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
LogUtils.e("result", responseInfo.result);
callback.requestSuccess(responseInfo.result);
callback.requestFinish();
}
@Override
public void onFailure(HttpException error, String msg) {
LogUtils.e("请求失败:", msg);
callback.requestFailure("-3","请求失败!");
callback.requestFinish();
}
});
}
public static String getURLAndParameter(String url, HashMap<String, String> map) {
if (TextUtils.isEmpty(url))
return "";
if(map == null || map.isEmpty())
return url;
StringBuilder encodedParams = new StringBuilder(url);
if (map.entrySet().size() > 0) {
if (url.contains("?"))
encodedParams.append('&');
else
encodedParams.append('?');
}
for (Map.Entry<String, String> entry : map.entrySet()) {
Map<String, String> pramas = StringUtils.URLRequest(url);
if (!pramas.containsKey(entry.getKey())) {
encodedParams.append(entry.getKey());
encodedParams.append('=');
encodedParams.append(entry.getValue());
encodedParams.append('&');
}
}
if (map.entrySet().size() > 0)
encodedParams.deleteCharAt(encodedParams.length() - 1);
String strUrl = encodedParams.toString();
return strUrl;
}
/**
* 获取网络请求通用参数
*
* @param context
* @return
*/
private static HashMap<String, String> getCommonParams(Context context) {
HashMap<String, String> map = new HashMap<String, String>();
/*map.put("imei", Utils.getDeviceId(context)); // 手机辨识码
map.put("os", "android"); // 操作系统
String model = Build.MODEL; // 手机型号
map.put("dev", model); // 设备名称
String release = Build.VERSION.RELEASE; // android系统版本号
map.put("osver", release);
map.put("ver", Constant.vsn); // app版本号
map.put("chnl", Utils.getChannelCode(context)); // 渠道来源*/
/*map.put("geihui_timestamp", String.valueOf(Calendar.getInstance().getTimeInMillis())); // 当前时间戳,从1970年1月1日0时开始到当前时间的毫秒数
map.put("geihui_app", "1");
map.put("device_type", "app");
UserInfoBean userInfoBean = GotGoodBargainApplication.getUserInfo();
if(userInfoBean != null && !TextUtils.isEmpty(userInfoBean.token)){
map.put("token",userInfoBean.token);
}*/
map.put("app_type", "2");
map.put("system_version", Build.VERSION.RELEASE);
map.put("device_id", Utils.getDeviceId(context));
map.put("model", Build.MANUFACTURER+"-"+ Build.MODEL);
return map;
}
public static HashMap<String, String> createAllParams(Context context, HashMap<String, String> normalParams) {
HashMap<String, String> allParams = new HashMap<String, String>();
if (normalParams != null)
//添加普通参数
allParams.putAll(normalParams);
//添加必要参数
allParams.putAll(getCommonParams(context));
//参数排序
List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(allParams.entrySet());
Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
//拼接参数
StringBuffer signStr = new StringBuffer("");
for (Map.Entry<String, String> mapping : infoIds) {
signStr.append(mapping.getKey() + mapping.getValue());
}
return allParams;
}
public static String toMd5(String str) {
return toMd5(str.getBytes());
}
public static String toMd5(byte[] bytes) {
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(bytes);
return toHexString(algorithm.digest(), "");
} catch (NoSuchAlgorithmException e) {
// Log.v("he--------------------------------ji", "toMd5(): " + e);
// throw new RuntimeException(e);
// 05-20 09:42:13.697: ERROR/hjhjh(256):
// 5d5c87e61211ab7a4847f7408f48ac
}
return null;
}
public static String toHexString(byte[] bytes, String separator) {
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
String hex = Integer.toHexString(0xFF & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex).append(separator);
}
return hexString.toString();
}
}
package cn.dankal.base.http;
import com.lidroid.xutils.db.annotation.Column;
import com.lidroid.xutils.db.annotation.Id;
import com.lidroid.xutils.db.annotation.Table;
/**
* 创建日期:2017/3/23 on 11:09
* 描述:
* 作者: Alex tang
*/
@Table(name = "httpLog")
public class HttpPostLogBean {
@Id
public String url;
@Column(column = "startTime")
public long startTime;
public long endTime;
public double serverGetRequestTime;
public String apiProcessTime;
public double serverSendResponseTime;
public boolean requestIsSuccess;
}
package cn.dankal.base.http;
import android.text.TextUtils;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import cn.dankal.base.interfaces.IHttpCallBack;
import cn.dankal.base.utils.LogUtils;
public class NOToastHttpCallBack implements IHttpCallBack {
public static final String TAG = NOToastHttpCallBack.class.getSimpleName();
private boolean needLoginWithLocaldata = true;
public NOToastHttpCallBack(){
}
public NOToastHttpCallBack(boolean needLoginWithLocaldata){
this.needLoginWithLocaldata = needLoginWithLocaldata;
}
@Override
public void requestStart() {
}
/**
* 请求成功,如果服务器返回状态为1时,会对用户的基本信息进行本地保存
* @param result
*/
@Override
public void requestSuccess(String result) {
successCallBack(result);
}
/**
* 当服务器返回状态为0时调用该接口
* @param result
*/
@Override
public void requestFailure(String code, String result) {
LogUtils.e("请求失败", result);
}
@Override
public void requestOffLine() {
}
@Override
public void requestFinish() {
}
/**
* 当服务器返回状态为1时调用该接口返回data属性的string内容
* @param result
*/
@Override
public void successCallBack(String result) {
}
@Override
public void downLoadSuccess(String result) {
}
@Override
public void downLoadFailure(String result) {
}
@Override
public void saveUserVarsData(String varsJson) {
LogUtils.e("AAAA","**** saveUserVarsData");
Gson gson = new Gson();
}
}
package cn.dankal.base.http;
import cn.dankal.base.interfaces.IHttpCallBack;
import cn.dankal.base.utils.LogUtils;
public class NoDataProcessNOToastHttpCallBack implements IHttpCallBack {
public static final String TAG = NoDataProcessNOToastHttpCallBack.class.getSimpleName();
@Override
public void requestStart() {
}
/**
* 请求成功,如果服务器返回状态为1时,会对用户的基本信息进行本地保存
* @param result
*/
@Override
public void requestSuccess(String result) {
}
/**
* 当服务器返回状态为0时调用该接口
* @param result
*/
@Override
public void requestFailure(String code, String result) {
LogUtils.e("请求失败", result);
}
@Override
public void requestOffLine() {
}
@Override
public void requestFinish() {
}
/**
* 当服务器返回状态为1时调用该接口返回data属性的string内容
* @param result
*/
@Override
public void successCallBack(String result) {
}
@Override
public void downLoadSuccess(String result) {
}
@Override
public void downLoadFailure(String result) {
}
@Override
public void saveUserVarsData(String varsJson) {
}
}
package cn.dankal.base.interfaces;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
/**
* @类名: IBaseInterface
* @功能描述: 界面通用接口类
* @创建人: Alex
* @创建时间: 2015-10-9 下午3:16:18
*/
public interface IBaseInterface {
/**
* 显示Toast形式的提示信息
*
* @param message
*/
public abstract void show(String message);
/**
* 显示提示
*
* @param resourceId
*/
public abstract void show(int resourceId);
/**
* 根据id获取控件
* @param id
* @return
*/
public abstract <E extends View> E getView(int id);
/**
* 跳转界面
* @param clazz
*/
public abstract void jumpActivity(Class<? extends Activity> clazz, boolean needLogin);
/**
* 跳转界面
* @param clazz
* @param flag
*/
public abstract void jumpActivity(Class<? extends Activity> clazz, int flag, boolean needLogin);
/**
* 跳转界面
* @param clazz
* @param requestCode
*/
public abstract void jumpActivityForResult(Class<? extends Activity> clazz,
int requestCode, boolean needLogin);
/**
* 跳转界面
* @param clazz
* @param data
* @param requestCode
*/
public void jumpActivityForResult(Class<? extends Activity> clazz, Bundle data,
int requestCode, boolean needLogin);
/**
* 跳转界面
* @param clazz
* @param data
*/
public abstract void jumpActivity(Class<? extends Activity> clazz,
Bundle data, boolean needLogin);
/**
* 跳转界面
* @param clazz
* @param data
* @param flag
*/
public abstract void jumpActivity(Class<? extends Activity> clazz,
Bundle data, int flag, boolean needLogin);
/**
* 跳转界面
* @param intent
*/
public abstract void jumpActivity(Intent intent, boolean needLogin);
/**
* 是否登录了
* @return
*/
boolean isLogined();
}
\ No newline at end of file
package cn.dankal.base.interfaces;
/**
* Created by Alex Tang on 2016/4/25.
*/
public interface IBottomBtnsDialogInterface {
public void onButtomClick(Object bean);
}
package cn.dankal.base.interfaces;
public interface IDownloadFileCallBack {
public void downloadStart();
public void downloadSuccess(String result);
public void downloadFailure(String result);
}
package cn.dankal.base.interfaces;
/**
* Created by Alex Tang on 2015/12/9.
*/
public interface IHomepageTagChangeInterface {
void changeTagSelectedStatus(int id);
void changeToMallRebateCuponPage();
}
package cn.dankal.base.interfaces;
import android.content.Intent;
/**
* Created by Alex Tang on 2017/1/11.
*/
public interface IHotpicJumpCallBack {
public void doJump(Intent intent);
public void doCloseCurrentPage();
public void doSendBroadcast(Intent intent);
public void postRunnable(Runnable runnable);
}
package cn.dankal.base.interfaces;
public interface IHttpCallBack {
public void requestStart();
public void requestSuccess(String result);
public void requestFailure(String code, String result);
public void requestOffLine();
public void requestFinish();
public void successCallBack(String result);
public void downLoadSuccess(String result);
public void downLoadFailure(String result);
/**
* 保存接口返回的用户基础数据
*/
public void saveUserVarsData(String varsJson);
}
package cn.dankal.base.interfaces;
public interface IHttpPostFileCallBack {
public void requestStart();
public void requestFailure(String result);
public void requestOffLine();
public void requestFinish();
public void successCallBack(String result);
public void onCancle();
public void onLoading(long total, long current);
}
package cn.dankal.base.interfaces;
import android.app.Dialog;
/**
* @类名: INetBaseInterface
* @功能描述: 有网络请求界面通用接口
* @创建人: Alex
* @创建时间: 2015-10-9 下午3:16:49
*/
public interface INetBaseInterface extends IBaseInterface {
/**
* 创建操作提示Dialog
* @return
*/
public abstract Dialog createDialog();
/**
* 显示加载动画
*/
public void showLoadingDialog();
/**
* 关闭加载动画
*/
public void dismmisLoadingDialog();
}
\ No newline at end of file
package cn.dankal.base.interfaces;
import android.widget.ImageView;
/**
* Created by Alex Tang on 2015/10/28.
*/
public interface INetPicInterface {
void display(ImageView container, String url);
void display(ImageView container, String url, INetPicLoadCallBack callback);
void displayLocalPic(ImageView container, String picPath);
}
package cn.dankal.base.interfaces;
import android.graphics.Bitmap;
import android.widget.ImageView;
/**
* Created by Alex Tang on 2015/12/4.
*/
public interface INetPicLoadCallBack {
void onLoadCompleted(ImageView imageView, String url, Bitmap bitmap);
void onLoadFailed(ImageView imageView, String url);
}
package cn.dankal.base.interfaces;
/**
* 创建日期:2019/2/22 on 3:31 PM
* 描述:
* 作者:Alex tang
*/
public interface IOnGoodsItemMenuClickedListener {
void onDelete(int position);
void onShare(int position);
}
package cn.dankal.base.interfaces;
/**
* 创建日期:2018/12/14 on 10:59 AM
* 描述:
* 作者:Alex tang
*/
public interface IPermissionCheck {
public void hasGotPermissions(int code);
}
package cn.dankal.base.interfaces;
/**
* Created by Alex Tang on 2016/2/17.
*/
public interface IPhotoGotResult {
void gotPhotoSuccess(String photoFilePath);
}
package cn.dankal.base.interfaces;
import android.view.View;
/**
* Created by Alex Tang on 2016/11/9.
*/
public interface ISuperDetailPageViewClickListener {
public static final int TYPE_SHARE_BUTTON = 1;
public static final int TYPE_QUESTION_MARK = 2;
void onViewClicked(View view, int type);
}
package cn.dankal.base.interfaces;
import android.webkit.WebView;
/**
* Created by Alex Tang on 2015/12/11.
*/
public interface IWebViewJsClassLoadInterface {
/**
* 为webview添加js交互方法类
* @param webView
*/
void addJsInteracteClass(WebView webView);
}
package cn.dankal.base.interfaces;
public interface OnCustomCalendarChangeLisenter {
public void onDaySelected(String selectedDay);
public void onDayUnselected(String unselectedDay);
public void onMonthChanged(int currentMonth);
public void onYearChanged(int currentYear);
}
package cn.dankal.base.utils;
import android.content.Context;
import android.text.TextUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import cn.mctower.visitor.Constant;
/**
* Created by Alex Tang on 2015/12/15.
*/
public class FileUtils {
public static final String TAG = FileUtils.class.getSimpleName();
protected static final String mSdcardDataDir = Constant.BaseImagesDir;
/**
* 删除文件
*
* @param path
*/
public static void deleteFile(String path) {
File file = new File(path);
if (file.exists())
file.delete();
}
/**
* 删除文件件夹
* @param pPath
*/
public static void deleteDir(final String pPath) {
File dir = new File(pPath);
deleteDirWihtFile(dir);
}
public static void deleteDirWihtFile(File dir) {
if (dir == null || !dir.exists() || !dir.isDirectory())
return;
if(dir.listFiles() == null)
return;
for (File file : dir.listFiles()) {
if (file.isFile())
file.delete(); // 删除所有文件
else if (file.isDirectory())
deleteDirWihtFile(file); // 递规的方式删除文件夹
}
dir.delete();// 删除目录本身
}
public static File copy(Context context, String fileName, String destPath) {
try {
InputStream is = context.getAssets().open(fileName);
File file = new File(destPath);
FileOutputStream fos = new FileOutputStream(file);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.flush();
fos.close();
is.close();
return file;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 查找指定目录下的指定文件
* @param dir
* @param fileName
* @return
*/
public static File getFile(String dir, String fileName) {
File fileDir = new File(dir);
if (fileDir.isDirectory()) {
File[] fileArray = fileDir.listFiles();
if (null != fileArray && 0 != fileArray.length) {
for (File file : fileArray) {
if (TextUtils.equals(fileName, file.getName())) {
return file;
}
}
}
}
return null;
}
public static long getDirectorySize(File directory){
long size = 0;
LogUtils.e("aaa","directory ="+directory.getAbsolutePath());
File[] files = directory.listFiles();
for(File file : files){
if(file.isFile()){
size += file.length();
LogUtils.e("aaa","file ="+file.getAbsolutePath());
LogUtils.e("aaa","file size = "+file.length());
}else{
size = getDirectorySize(file);
}
}
return size;
}
}
package cn.dankal.base.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Environment;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by yangna on 14-5-6.
*/
public class ImageUtil {
/**
* @param options
* @param reqWidth
* @return
*/
private static int calculateInWidthSize(BitmapFactory.Options options,
int reqWidth) {
// 婧愬浘鐗囩殑瀹藉害
final int width = options.outWidth;
int inSampleSize = 1;
if (width > reqWidth) {
final int widthRatio = Math.round((float) width / (float) reqWidth);
inSampleSize = widthRatio;
}
return inSampleSize;
}
/**
* 如果最大值没有超过 max 原比例输出
*
* @param options
* @param max
* @return
*/
private static int calculateRatio(BitmapFactory.Options options, int max) {
final int width = options.outWidth;
final int height = options.outHeight;
int inSampleSize = 1;
if (width > max || height > max) {
if (width >= height) {
final int widthRatio = Math.round((float) width / (float) max);
inSampleSize = widthRatio;
} else {
final int heightRatio = Math
.round((float) height / (float) max);
inSampleSize = heightRatio;
}
}
return inSampleSize;
}
/**
* 按宽度等比缩放,reqWidth <= 0 图片不缩放
*
* @param pathName
* @param reqWidth
* @return
*/
@Deprecated
public static Bitmap decodeBitmapWidthFromResource(String pathName,
int reqWidth) {
if (reqWidth > 0) {
// 绗竴娆¤В鏋愬皢inJustDecodeBounds璁剧疆涓簍rue锛屾潵鑾峰彇鍥剧墖澶у皬
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(pathName, options);
// 璋冪敤涓婇潰瀹氫箟鐨勬柟娉曡绠梚nSampleSize鍊?
options.inSampleSize = calculateInWidthSize(options, reqWidth);
// 浣跨敤鑾峰彇鍒扮殑inSampleSize鍊煎啀娆¤В鏋愬浘鐗?
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(pathName, options);
} else {
return BitmapFactory.decodeFile(pathName);
}
}
/**
* 按最大值等比缩放,如果高或宽没有超过最大值按原图显示
*
* @param pathName
* @param max
* @return
*/
public static Bitmap decodeBitmapFromResource(String pathName, int max) {
if (max > 0) {
// 绗竴娆¤В鏋愬皢inJustDecodeBounds璁剧疆涓簍rue锛屾潵鑾峰彇鍥剧墖澶у皬
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(pathName, options);
// 璋冪敤涓婇潰瀹氫箟鐨勬柟娉曡绠梚nSampleSize鍊?
options.inSampleSize = calculateRatio(options, max);
// 浣跨敤鑾峰彇鍒扮殑inSampleSize鍊煎啀娆¤В鏋愬浘鐗?
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(pathName, options);
} else {
return BitmapFactory.decodeFile(pathName);
}
}
/**
* 创建缩略图
*
* @param src
* @param width
* @param height
* @return
*/
public static Bitmap createScaleBitmap(Bitmap src, int width, int height) {
Matrix m = new Matrix();
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
float scale = 1;
// 绔栧浘
if (srcWidth > srcHeight) {
scale = width / (float) srcWidth;
} else {
scale = height / (float) srcHeight;
}
m.postScale(scale, scale);
Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(),
src.getHeight(), m, true);
src.recycle();
return bitmap;
}
/**
* 创建缩略图,先拿原图,再创建新图
*
* @param srcPath
* @param max
* @return
*/
public static Bitmap getScaleImage(String srcPath, int max) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(srcPath, newOpts);
newOpts.inJustDecodeBounds = false;
float w = newOpts.outWidth;
float h = newOpts.outHeight;
int be = 1;// be=1琛ㄧず涓嶇缉鏀?
int scale = (int) (Math.max(w, h) / (float) max);
if (scale > 1) {
be = scale;
}
newOpts.inSampleSize = be;// 璁剧疆缂╂斁姣斾緥
try {
return BitmapFactory.decodeStream(new FileInputStream(srcPath),
null, newOpts);
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
/**
* 创建缩略图
*
* @param src
* @param max
* @return
*/
public static Bitmap createScaleBitmap(Bitmap src, int max) {
Matrix m = new Matrix();
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
float scale = (max / (float) (Math.max(srcWidth, srcHeight)));
m.postScale(scale, scale);
Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(),
src.getHeight(), m, true);
return bitmap;
}
/**
*
* 裁剪图片意图
*
* @param activity
* @param uri
* @param outputX
* @param outputY
* @param requestCode
*/
public static void cropImage(Activity activity, Uri uri, int outputX,
int outputY, int requestCode) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", outputX);
intent.putExtra("outputY", outputY);
intent.putExtra("outputFormat", "JPEG");
intent.putExtra("noFaceDetection", true);
intent.putExtra("return-data", true);
activity.startActivityForResult(intent, requestCode);
}
/**
* 姘村钩鏂瑰悜妯$硦搴?
*/
private static float hRadius = 10;
/**
*
*/
private static float vRadius = 10;
/**
* 模糊迭代度
*/
private static int iterations = 7;
/**
* 高斯模糊
*/
public static Drawable BoxBlurFilter(Bitmap bmp) {
int width = bmp.getWidth();
int height = bmp.getHeight();
int[] inPixels = new int[width * height];
int[] outPixels = new int[width * height];
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_4444);
bmp.getPixels(inPixels, 0, width, 0, 0, width, height);
for (int i = 0; i < iterations; i++) {
blur(inPixels, outPixels, width, height, hRadius);
blur(outPixels, inPixels, height, width, vRadius);
}
blurFractional(inPixels, outPixels, width, height, hRadius);
blurFractional(outPixels, inPixels, height, width, vRadius);
bitmap.setPixels(inPixels, 0, width, 0, 0, width, height);
Drawable drawable = new BitmapDrawable(null, bitmap);
return drawable;
}
static void blur(int[] in, int[] out, int width, int height, float radius) {
int widthMinus1 = width - 1;
int r = (int) radius;
int tableSize = 2 * r + 1;
int divide[] = new int[256 * tableSize];
for (int i = 0; i < 256 * tableSize; i++)
divide[i] = i / tableSize;
int inIndex = 0;
for (int y = 0; y < height; y++) {
int outIndex = y;
int ta = 0, tr = 0, tg = 0, tb = 0;
for (int i = -r; i <= r; i++) {
int rgb = in[inIndex + clamp(i, 0, width - 1)];
ta += (rgb >> 24) & 0xff;
tr += (rgb >> 16) & 0xff;
tg += (rgb >> 8) & 0xff;
tb += rgb & 0xff;
}
for (int x = 0; x < width; x++) {
out[outIndex] = (divide[ta] << 24) | (divide[tr] << 16)
| (divide[tg] << 8) | divide[tb];
int i1 = x + r + 1;
if (i1 > widthMinus1)
i1 = widthMinus1;
int i2 = x - r;
if (i2 < 0)
i2 = 0;
int rgb1 = in[inIndex + i1];
int rgb2 = in[inIndex + i2];
ta += ((rgb1 >> 24) & 0xff) - ((rgb2 >> 24) & 0xff);
tr += ((rgb1 & 0xff0000) - (rgb2 & 0xff0000)) >> 16;
tg += ((rgb1 & 0xff00) - (rgb2 & 0xff00)) >> 8;
tb += (rgb1 & 0xff) - (rgb2 & 0xff);
outIndex += height;
}
inIndex += width;
}
}
static void blurFractional(int[] in, int[] out, int width, int height,
float radius) {
radius -= (int) radius;
float f = 1.0f / (1 + 2 * radius);
int inIndex = 0;
for (int y = 0; y < height; y++) {
int outIndex = y;
out[outIndex] = in[0];
outIndex += height;
for (int x = 1; x < width - 1; x++) {
int i = inIndex + x;
int rgb1 = in[i - 1];
int rgb2 = in[i];
int rgb3 = in[i + 1];
int a1 = (rgb1 >> 24) & 0xff;
int r1 = (rgb1 >> 16) & 0xff;
int g1 = (rgb1 >> 8) & 0xff;
int b1 = rgb1 & 0xff;
int a2 = (rgb2 >> 24) & 0xff;
int r2 = (rgb2 >> 16) & 0xff;
int g2 = (rgb2 >> 8) & 0xff;
int b2 = rgb2 & 0xff;
int a3 = (rgb3 >> 24) & 0xff;
int r3 = (rgb3 >> 16) & 0xff;
int g3 = (rgb3 >> 8) & 0xff;
int b3 = rgb3 & 0xff;
a1 = a2 + (int) ((a1 + a3) * radius);
r1 = r2 + (int) ((r1 + r3) * radius);
g1 = g2 + (int) ((g1 + g3) * radius);
b1 = b2 + (int) ((b1 + b3) * radius);
a1 *= f;
r1 *= f;
g1 *= f;
b1 *= f;
out[outIndex] = (a1 << 24) | (r1 << 16) | (g1 << 8) | b1;
outIndex += height;
}
out[outIndex] = in[width - 1];
inIndex += width;
}
}
static int clamp(int x, int a, int b) {
return (x < a) ? a : (x > b) ? b : x;
}
/**
* 鍒涘缓甯︽湁瑙掓爣鏁板瓧鐨勫渾褰?
*
* @param context
* @param num
* @param bgColor
* getResources().getColor(R.color.bg_red);
* @return
*/
public static Drawable createCircleFlag(Context context, String num,
int bgColor) {
int textSize = UIUtil.sp2px(context, 25);
int r = textSize;
// 鏂板缓涓?涓柊鐨勮緭鍑哄浘鐗?
Bitmap output = Bitmap.createBitmap(2 * r, 2 * r,
Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(output);
// 鍒涘缓鍦?
Paint paint = new Paint(Paint.FAKE_BOLD_TEXT_FLAG
| Paint.ANTI_ALIAS_FLAG);
paint.setColor(bgColor);
paint.setAntiAlias(true);
canvas.drawColor(Color.TRANSPARENT);
canvas.drawCircle(r, r, r, paint);
// 鍐欏瓧
paint.setTextSize(textSize);
paint.setColor(Color.WHITE);
paint.setTextAlign(Paint.Align.CENTER);
Paint.FontMetrics fontMetrics = paint.getFontMetrics();
int h = (int) (fontMetrics.bottom - fontMetrics.top) / 4;
canvas.drawText(num, r, r + h, paint);
Drawable dr = new BitmapDrawable(null, output);
dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
return dr;
}
/**
* 清除imageView
*
* @param mImageView
*/
public static void clearImageCache(ImageView mImageView) {
try {
BitmapDrawable bd = ((BitmapDrawable) mImageView.getDrawable());
if (bd != null) {
mImageView.setImageDrawable(null);
Bitmap bitmap = bd.getBitmap();
if (bitmap != null && !bitmap.isRecycled()) {
bitmap.recycle();
}
}
} catch (ClassCastException e) {
}
}
/**
* we need to recyle bitmap.
*
* @param o
*/
public static void clearBitmap(Object o) {
if (o instanceof View) {
if (o instanceof ImageView) {
ImageView recyleView = (ImageView) o;
clearImageCache(recyleView);
}
}
if (o instanceof ViewGroup) {
ViewGroup group = (ViewGroup) o;
for (int i = 0; i < group.getChildCount(); i++) {
clearBitmap(group.getChildAt(i));
}
}
}
/**
* 读取图片的旋转的角度
*
* @param path
* 图片绝对路径
* @return 图片的旋转角度
*/
public static int getBitmapDegree(String path) {
int degree = 0;
try {
// 从指定路径下读取图片,并获取其EXIF信息
ExifInterface exifInterface = new ExifInterface(path);
// 获取图片的旋转信息
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return degree;
}
/**
* 将图片按照某个角度进行旋转
*
* @param bm
* 需要旋转的图片
* @param degree
* 旋转角度
* @return 旋转后的图片
*/
public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
Bitmap returnBm = null;
// 根据旋转角度,生成旋转矩阵
Matrix matrix = new Matrix();
matrix.postRotate(degree);
try {
// 将原始图片按照旋转矩阵进行旋转,并得到新的图片
returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
} catch (OutOfMemoryError e) {
}
if (returnBm == null) {
returnBm = bm;
}
if (bm != returnBm) {
bm.recycle();
}
return returnBm;
}
/**
* 转换图片成圆形
*
* @param bitmap 传入Bitmap对象
* @return
*/
public static Bitmap toRoundBitmap(Bitmap bitmap) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float roundPx;
float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom;
if (width <= height) {
roundPx = width / 2;
top = 0;
bottom = width;
left = 0;
right = width;
height = width;
dst_left = 0;
dst_top = 0;
dst_right = width;
dst_bottom = width;
} else {
roundPx = height / 2;
float clip = (width - height) / 2;
left = clip;
right = width - clip;
top = 0;
bottom = height;
width = height;
dst_left = 0;
dst_top = 0;
dst_right = height;
dst_bottom = height;
}
Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect src = new Rect((int) left, (int) top, (int) right,
(int) bottom);
final Rect dst = new Rect((int) dst_left, (int) dst_top,
(int) dst_right, (int) dst_bottom);
final RectF rectF = new RectF(dst);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, src, dst, paint);
return output;
}
/**
* 缩放Bitmap图片
**/
public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) width / w);
float scaleHeight = ((float) height / h);
matrix.postScale(scaleWidth, scaleHeight);// 利用矩阵进行缩放不会造成内存溢出
Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
return newbmp;
}
public static String saveImageToFile(Bitmap bmp) throws Exception {
//生成路径
String root = Environment.getExternalStorageDirectory().getAbsolutePath();
root = Environment.getDataDirectory().getAbsolutePath() + "/data/cn.runworld.mctower.visitor/";
String dirName = "erweima16";
File appDir = new File(root , dirName);
if (!appDir.exists()) {
appDir.mkdirs();
}
LogUtils.e("aa","path = "+appDir.getAbsolutePath());
//文件名为时间
long timeStamp = System.currentTimeMillis();
String fileName = timeStamp + ".jpg";
//获取文件
File file = new File(appDir, fileName);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
return file.getAbsolutePath();
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw e;
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
throw e;
}
}
}
}
package cn.dankal.base.utils;
import android.util.Log;
import com.lidroid.xutils.http.RequestParams;
import com.socks.library.KLog;
import org.apache.http.NameValuePair;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.List;
import cn.mctower.visitor.Constant;
public final class LogUtils {
private static boolean sIsLogEnabled = true;// 是否打开LOG
// private static boolean sIsLogEnabled = true;// 是否打开LOG
private static String sApplicationTag = "com.mctower";// LOG默认TAG
private static final String TAG_CONTENT_PRINT = "%s:%s.%s:%d";
private static StackTraceElement getCurrentStackTraceElement() {
return Thread.currentThread().getStackTrace()[4];
}
// 打印LOG
public static void trace() {
if (sIsLogEnabled) {
KLog.d(getContent(getCurrentStackTraceElement()));
}
}
// 获取LOG
private static String getContent(StackTraceElement trace) {
return String.format(TAG_CONTENT_PRINT, sApplicationTag,
trace.getClassName(), trace.getMethodName(),
trace.getLineNumber());
}
// 打印默认TAG的LOG
public static void traceStack() {
if (sIsLogEnabled) {
traceStack(sApplicationTag, Log.ERROR);
}
}
// 打印Log当前调用栈信�?
public static void traceStack(String tag, int priority) {
if (sIsLogEnabled) {
StackTraceElement[] stackTrace = Thread.currentThread()
.getStackTrace();
Log.println(priority, tag, stackTrace[4].toString());
StringBuilder str = new StringBuilder();
String prevClass = null;
for (int i = 5; i < stackTrace.length; i++) {
String className = stackTrace[i].getFileName();
int idx = className.indexOf(".java");
if (idx >= 0) {
className = className.substring(0, idx);
}
if (prevClass == null || !prevClass.equals(className)) {
str.append(className.substring(0, idx));
}
prevClass = className;
str.append(".").append(stackTrace[i].getMethodName())
.append(":").append(stackTrace[i].getLineNumber())
.append("->");
}
Log.println(priority, tag, str.toString());
}
}
// 指定TAG和指定内容的方法
public static void d(String tag, String msg) {
if (sIsLogEnabled) {
KLog.d(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
}
}
// 默认TAG和制定内容的方法
public static void d(String msg) {
if (sIsLogEnabled) {
KLog.d(sApplicationTag, getContent(getCurrentStackTraceElement())
+ ">" + msg);
}
}
// 下面的定义和上面方法相同,可以定义不同等级的Debugger
public static void i(String tag, String msg) {
if (sIsLogEnabled) {
KLog.i(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
}
}
public static void w(String tag, String msg) {
if (sIsLogEnabled) {
KLog.w(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
}
}
public static void v(String tag, String msg) {
if (sIsLogEnabled) {
KLog.v(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
}
}
public static void e(String tag, String msg) {
if (sIsLogEnabled) {
KLog.e(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
}
}
public static void r(String tag, String msg) {
e(tag,msg);
/*if (sIsLogEnabled) {
Log.e(tag, getContent(getCurrentStackTraceElement()) + ">" + msg);
saveToFile(tag + "-->" + getContent(getCurrentStackTraceElement()) + ">" + msg);
}*/
}
public static void json(String tag, String json){
if (sIsLogEnabled) {
KLog.json(tag, json);
}
}
public static void json(String json){
if (sIsLogEnabled) {
KLog.json(json);
}
}
}
package cn.dankal.base.utils;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import cn.dankal.base.interfaces.INetPicInterface;
import cn.dankal.base.interfaces.INetPicLoadCallBack;
/**
* Created by Alex Tang on 2016/4/19.
*/
public class NetPicUtil implements INetPicInterface {
private DisplayImageOptions options;
public NetPicUtil(){
options = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
}
public NetPicUtil(int loadingPicResId, int emptyUrlPicResId, int loadFailPicResId){
options = new DisplayImageOptions.Builder()
.showImageOnLoading(loadingPicResId)
.showImageForEmptyUri(emptyUrlPicResId)
.showImageOnFail(loadFailPicResId)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
}
@Override
public void display(ImageView container, String url) {
ImageLoader.getInstance().displayImage(url,container,options);
}
public void display(ImageView container, String url, final INetPicLoadCallBack callBack) {
ImageLoader.getInstance().displayImage(url, container, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if(callBack != null)
callBack.onLoadFailed((ImageView)view,imageUri);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if(callBack != null)
callBack.onLoadCompleted((ImageView)view,imageUri,loadedImage);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
}
@Override
public void displayLocalPic(ImageView container, String picPath) {
ImageLoader.getInstance().displayImage(picPath,container);
}
public void setOptions(DisplayImageOptions option){
options = option;
}
public void setDefaultPics(int loadingPicId,int emptyUriPicId,int loadFailurePicId){
options = new DisplayImageOptions.Builder()
.showImageOnLoading(loadingPicId)
.showImageForEmptyUri(emptyUriPicId)
.showImageOnFail(loadFailurePicId)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
}
}
package cn.dankal.base.utils;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
/**
* 创建日期:2019/4/1 on 11:07 AM
* 描述:
* 作者:Alex tang
*/
public class RealPathFromUriUtils {
/**
* 根据Uri获取图片的绝对路径
*
* @param context 上下文对象
* @param uri 图片的Uri
* @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
*/
public static String getRealPathFromUri(Context context, Uri uri) {
int sdkVersion = Build.VERSION.SDK_INT;
if (sdkVersion >= 19) { // api >= 19
return getRealPathFromUriAboveApi19(context, uri);
} else { // api < 19
return getRealPathFromUriBelowAPI19(context, uri);
}
}
/**
* 适配api19以下(不包括api19),根据uri获取图片的绝对路径
*
* @param context 上下文对象
* @param uri 图片的Uri
* @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
*/
private static String getRealPathFromUriBelowAPI19(Context context, Uri uri) {
return getDataColumn(context, uri, null, null);
}
/**
* 适配api19及以上,根据uri获取图片的绝对路径
*
* @param context 上下文对象
* @param uri 图片的Uri
* @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
*/
@SuppressLint("NewApi")
private static String getRealPathFromUriAboveApi19(Context context, Uri uri) {
String filePath = null;
if (DocumentsContract.isDocumentUri(context, uri)) {
// 如果是document类型的 uri, 则通过document id来进行处理
String documentId = DocumentsContract.getDocumentId(uri);
if (isMediaDocument(uri)) { // MediaProvider
// 使用':'分割
String id = documentId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=?";
String[] selectionArgs = {id};
filePath = getDataColumn(context, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection, selectionArgs);
} else if (isDownloadsDocument(uri)) { // DownloadsProvider
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId));
filePath = getDataColumn(context, contentUri, null, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
// 如果是 content 类型的 Uri
filePath = getDataColumn(context, uri, null, null);
} else if ("file".equals(uri.getScheme())) {
// 如果是 file 类型的 Uri,直接获取图片对应的路径
filePath = uri.getPath();
}
return filePath;
}
/**
* 获取数据库表中的 _data 列,即返回Uri对应的文件路径
*
* @return
*/
private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
String path = null;
String[] projection = new String[]{MediaStore.Images.Media.DATA};
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndexOrThrow(projection[0]);
path = cursor.getString(columnIndex);
}
} catch (Exception e) {
if (cursor != null) {
cursor.close();
}
}
return path;
}
/**
* @param uri the Uri to check
* @return Whether the Uri authority is MediaProvider
*/
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* @param uri the Uri to check
* @return Whether the Uri authority is DownloadsProvider
*/
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
}
package cn.dankal.base.utils;
import android.content.Context;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
/**
* 屏幕工具类--获取手机屏幕信息
*
* @author zihao
*
*/
public class ScreenUtil {
/**
* 获取屏幕的宽度
*
* @param context
* @return
*/
public static int getScreenWidth(Context context) {
WindowManager manager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
return display.getWidth();
}
/**
* 获取屏幕的高度
*
* @param context
* @return
*/
public static int getScreenHeight(Context context) {
WindowManager manager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
return display.getHeight();
}
/**
* 获取屏幕中控件顶部位置的高度--即控件顶部的Y点
*
* @return
*/
public static int getScreenViewTopHeight(View view) {
return view.getTop();
}
/**
* 获取屏幕中控件底部位置的高度--即控件底部的Y点
*
* @return
*/
public static int getScreenViewBottomHeight(View view) {
return view.getBottom();
}
/**
* 获取屏幕中控件左侧的位置--即控件左侧的X点
*
* @return
*/
public static int getScreenViewLeftHeight(View view) {
return view.getLeft();
}
/**
* 获取屏幕中控件右侧的位置--即控件右侧的X点
*
* @return
*/
public static int getScreenViewRightHeight(View view) {
return view.getRight();
}
}
\ No newline at end of file
package cn.dankal.base.utils;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.StreamCorruptedException;
import cn.mctower.visitor.MCTowerApplication;
public class SharedPreferenceHelper {
public static final String TAG = SharedPreferenceHelper.class.getSimpleName();
public static void saveSharedPreferences(String key, String value) {
SharedPreferences mPre;
SharedPreferences.Editor mEditor;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
mEditor = mPre.edit();
mEditor.putString(key, value);
mEditor.commit();
}
public static void saveSharedPreferencesLong(String key, long value) {
SharedPreferences mPre;
SharedPreferences.Editor mEditor;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
mEditor = mPre.edit();
mEditor.putLong(key, value);
mEditor.commit();
}
public static void saveSharedPreferencesInt(String key, int value) {
SharedPreferences mPre;
SharedPreferences.Editor mEditor;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
mEditor = mPre.edit();
mEditor.putInt(key, value);
mEditor.commit();
}
public static void saveSharedPreferences(String key, boolean value) {
SharedPreferences mPre;
SharedPreferences.Editor mEditor;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
mEditor = mPre.edit();
mEditor.putBoolean(key, value);
mEditor.commit();
}
public static String getSharedPreferences(String key) {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
String value = mPre.getString(key, "");
return value;
}
public static String getSharedPreferences(String key, String defValue) {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
String value = mPre.getString(key, defValue);
return value;
}
public static long getSharedPreferencesLong(String key) {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
long value = mPre.getLong(key, 0);
return value;
}
public static int getSharedPreferencesInt(String key) {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
int value = mPre.getInt(key, 0);
return value;
}
public static boolean getSharedPreferencesBoolean(String key) {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
return mPre.getBoolean(key, false);
}
/**
* 将对象保存在SharedPreferences中
* @param obj
* @param key
*/
public static void saveSharedPreferencesObject(Object obj , String key){
if(obj == null){
SharedPreferenceHelper.saveSharedPreferences(key,"");
}else {
try {
// 保存对象
SharedPreferences mPre;
SharedPreferences.Editor mEditor;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
mEditor = mPre.edit();
//先将序列化结果写到byte缓存中,其实就分配一个内存空间
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bos);
//将对象序列化写入byte缓存
os.writeObject(obj);
//将序列化的数据转为16进制保存
String bytesToHexString = bytesToHexString(bos.toByteArray());
//保存该16进制数组
mEditor.putString(key, bytesToHexString);
mEditor.commit();
} catch (IOException e) {
e.printStackTrace();
LogUtils.e(TAG, "保存obj失败");
}
}
}
/**
* 从SharedPreferences中获取对象
* @param key
* @return
*/
public static Object getSharedPreferencesObject(String key){
try {
SharedPreferences mPre;
mPre = PreferenceManager.getDefaultSharedPreferences(MCTowerApplication
.getContext());
if (mPre.contains(key)) {
String string = mPre.getString(key, "");
if(TextUtils.isEmpty(string)){
return null;
}else{
//将16进制的数据转为数组,准备反序列化
byte[] stringToBytes = stringToBytes(string);
ByteArrayInputStream bis=new ByteArrayInputStream(stringToBytes);
ObjectInputStream is=new ObjectInputStream(bis);
//返回反序列化得到的对象
Object readObject = is.readObject();
return readObject;
}
}
} catch (StreamCorruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
//所有异常返回null
return null;
}
/*public static void setUserSharedPreferencesFile(Context context,String uid){
File file = null;
if(!TextUtils.isEmpty(uid)){
file = new File(File.separator+"data"+File.separator+"data"+File.separator+context.getPackageName() +
"shared_prefs"+File.separator+"com.geihui_preferences.xml");
}else{
file = new File(File.separator+"data"+File.separator+"data"+File.separator+context.getPackageName() +
"shared_prefs"+File.separator+"uid_"+uid+".xml");
}
if(file.exists()){
LogUtils.e("aaaaaaa", "fille exists");
}
}*/
/**
* desc:将数组转为16进制
* @param bArray
* @return
* modified:
*/
public static String bytesToHexString(byte[] bArray) {
if(bArray == null){
return null;
}
if(bArray.length == 0){
return "";
}
StringBuffer sb = new StringBuffer(bArray.length);
String sTemp;
for (int i = 0; i < bArray.length; i++) {
sTemp = Integer.toHexString(0xFF & bArray[i]);
if (sTemp.length() < 2)
sb.append(0);
sb.append(sTemp.toUpperCase());
}
return sb.toString();
}
/**
* desc:将16进制的数据转为数组
* <p>创建人:聂旭阳 , 2014-5-25 上午11:08:33</p>
* @param data
* @return
* modified:
*/
public static byte[] stringToBytes(String data){
String hexString=data.toUpperCase().trim();
if (hexString.length()%2!=0) {
return null;
}
byte[] retData=new byte[hexString.length()/2];
for(int i=0;i<hexString.length();i++)
{
int int_ch; // 两位16进制数转化后的10进制数
char hex_char1 = hexString.charAt(i); ////两位16进制数中的第一位(高位*16)
int int_ch1;
if(hex_char1 >= '0' && hex_char1 <='9')
int_ch1 = (hex_char1-48)*16; //// 0 的Ascll - 48
else if(hex_char1 >= 'A' && hex_char1 <='F')
int_ch1 = (hex_char1-55)*16; //// A 的Ascll - 65
else
return null;
i++;
char hex_char2 = hexString.charAt(i); ///两位16进制数中的第二位(低位)
int int_ch2;
if(hex_char2 >= '0' && hex_char2 <='9')
int_ch2 = (hex_char2-48); //// 0 的Ascll - 48
else if(hex_char2 >= 'A' && hex_char2 <='F')
int_ch2 = hex_char2-55; //// A 的Ascll - 65
else
return null;
int_ch = int_ch1+int_ch2;
retData[i/2]=(byte) int_ch;//将转化后的数放入Byte里
}
return retData;
}
}
package cn.dankal.base.utils;
import android.text.TextUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class StringUtils {
/**
* 将每三个数字加上逗号处理(通常使用金额方面的编辑)
*
* @param str
* 无逗号的数字
* @return 加上逗号的数字
*/
public static String addComma(String str) {
// 将传进数字反转
String reverseStr = new StringBuilder(str).reverse().toString();
String strTemp = "";
for (int i = 0; i < reverseStr.length(); i++) {
if (i * 3 + 3 > reverseStr.length()) {
strTemp += reverseStr.substring(i * 3, reverseStr.length());
break;
}
strTemp += reverseStr.substring(i * 3, i * 3 + 3) + ",";
}
// 将 【789,456,】 中最后一个【,】去除
if (strTemp.endsWith(",")) {
strTemp = strTemp.substring(0, strTemp.length() - 1);
}
// 将数字重新反转
String resultStr = new StringBuilder(strTemp).reverse().toString();
return resultStr;
}
/**
* 将带有分隔符的string装换为List<String>
*
* @param str
* @param regularExpression
* @return
*/
public static List<String> string2List(String str, String regularExpression) {
List<String> result = null;
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(regularExpression)) {
String[] temp = str.split(regularExpression);
if (temp != null) {
result = new ArrayList<String>();
for (String obj : temp) {
result.add(obj);
}
}
}
return result;
}
/**
* 将List<String> 转换为已regularExpression为分隔符的String
*
* @param regularExpression
* @return
*/
public static String list2String(List<String> data, String regularExpression) {
String result = null;
if (data != null && !TextUtils.isEmpty(regularExpression)) {
StringBuffer buffer = new StringBuffer("");
for (String temp : data) {
if (buffer.toString().equals(""))
buffer.append(temp);
else
buffer.append(regularExpression + temp);
}
result = buffer.toString();
}
return result;
}
public static String intToIp(int i) {
return (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF)
+ "." + (i >> 24 & 0xFF);
}
/**
* 解析出url请求的路径,包括页面
*
* @param strURL
* url地址
* @return url路径
*/
public static String UrlPage(String strURL) {
String strPage = null;
String[] arrSplit = null;
strURL = strURL.trim();
arrSplit = strURL.split("[?]");
if (strURL.length() > 0) {
if (arrSplit.length > 1) {
if (arrSplit[0] != null) {
strPage = arrSplit[0];
}
}
}
return strPage;
}
/**
* 去掉url中的路径,留下请求参数部分
*
* @param strURL url地址
* @return url请求参数部分
*/
private static String TruncateUrlPage(String strURL) {
String strAllParam = null;
String[] arrSplit = null;
strURL = strURL.trim();
arrSplit = strURL.split("[?]");
if (strURL.length() > 1) {
if (arrSplit.length > 1) {
if (arrSplit[1] != null) {
strAllParam = arrSplit[1];
}
}
}
return strAllParam;
}
/**
* 解析出url参数中的键值对 如 "index.jsp?Action=del&id=123",解析出Action:del,id:123存入map中
*
* @param url url地址
* @return url请求参数部分
*/
public static Map<String, String> URLRequest(String url) {
Map<String, String> mapRequest = new HashMap<String, String>();
String[] arrSplit = null;
String strUrlParam = TruncateUrlPage(url);
if (strUrlParam == null) {
return mapRequest;
}
// 每个键值为一组 www.2cto.com
arrSplit = strUrlParam.split("[&]");
for (String strSplit : arrSplit) {
String[] arrSplitEqual = null;
arrSplitEqual = strSplit.split("[=]");
// 解析出键值
if (arrSplitEqual.length > 1) {
// 正确解析
mapRequest.put(arrSplitEqual[0], arrSplitEqual[1]);
} else {
if (arrSplitEqual[0] != "") {
// 只有参数没有值,不加入
mapRequest.put(arrSplitEqual[0], "");
}
}
}
return mapRequest;
}
/**
* 生成随机字符串
* @param length
* @return
*/
public static String getRandomString(int length) { //length表示生成字符串的长度
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
public static String getLimitString(String string , int length){
if(string != null){
if(string.length() <= length){
return string;
}else{
return string.substring(0,15)+"....";
}
}else
return null;
}
/**
* 将long转换为日期
* @param fromat
* @param millSec
* @return
*/
public static String longToData(String fromat, long millSec){
SimpleDateFormat formatter = new SimpleDateFormat(fromat);
Date date= new Date(millSec);
return formatter.format(date);
}
/**
* double 转换为金额
* @param num
* @return
*/
public static String doubleToMoney(double num){
// DecimalFormat df = new DecimalFormat("#.00");
return String.format("%.2f", num);
}
public static HashMap<String, String> longToCountDownTime(long leftTimeSecond){
HashMap<String, String> result = new HashMap<>();
String second = String.valueOf(leftTimeSecond % 60);
if(second.length() == 1){
second = "0"+second;
}
result.put("second",second);
String minute = String.valueOf(( leftTimeSecond/60 ) % 60);
if(minute.length() == 1){
minute = "0"+minute;
}
result.put("minute",minute);
String hour = String.valueOf(leftTimeSecond / (60 * 60));
if(hour.length() ==1){
hour = "0"+hour;
}
result.put("hour",hour);
return result;
}
}
package cn.dankal.base.utils;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import cn.mctower.visitor.MCTowerApplication;
import cn.mctower.visitor.R;
/**
* Created by Alex Tang on 2016/12/29.
*/
public class ToastUtils {
private static Toast mToast;
public static void show(String message) {
if(!TextUtils.isEmpty(message)) {
mToast = new Toast(MCTowerApplication.getContext());
LayoutInflater inflater = LayoutInflater.from(MCTowerApplication.getContext());
View layout = inflater.inflate(R.layout.custom_toast, null);
TextView msg = (TextView) layout.findViewById(R.id.msg);
msg.setText(message);
mToast = new Toast(MCTowerApplication.getContext());
mToast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, UIUtil.Dp2Px(MCTowerApplication.getContext(), 60));
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.setView(layout);
mToast.show();
}
}
public static void cancelToast() {
if (mToast != null) {
mToast.cancel();
}
}
public static void show(int resourceId) {
show(MCTowerApplication.getContext().getResources().getString(resourceId));
}
}
package cn.dankal.base.utils;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Environment;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Calendar;
public class UIUtil {
/**
* 获取屏幕真实大小(像素)
* @param ctx
* @return
*/
public static DisplayMetrics getScreenPhysicalSize(Context ctx) {
DisplayMetrics dm = new DisplayMetrics();
WindowManager wm = (WindowManager) ctx
.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(dm);
return dm;
}
/**
* dp转像素
* @param context
* @param dp
* @return
*/
public static int Dp2Px(Context context, float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
/**
* 像素转dp
* @param context
* @param px
* @return
*/
public static int Px2Dp(Context context, float px) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (px / scale + 0.5f);
}
public static Bitmap saveViewAsImage(View view , String path){
Bitmap bitmap = null;
if(view != null && !TextUtils.isEmpty(path)){
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
if(bitmap != null){
System.out.println("bitmap got!");
try{
File dir = new File(path.substring(0,path.lastIndexOf("/")));
if(!dir.exists())
dir.mkdirs();
FileOutputStream out = new FileOutputStream(path);
bitmap.compress(Bitmap.CompressFormat.PNG,70, out);
System.out.println("file" + path + "output done.");
}catch(Exception e) {
e.printStackTrace();
}
}else{
System.out.println("bitmap is NULL!");
}
}
return bitmap;
}
public static Bitmap convertViewToBitmap(View view){
Bitmap bitmap = null;
if(view != null){
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
}
return bitmap;
}
/**
* 将px值转换为sp值,保证文字大小不变
*
* @param context
* @param pxValue
* (DisplayMetrics类中属性scaledDensity)
* @return
*/
public static int px2sp(Context context, float pxValue) {
final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (pxValue / fontScale + 0.5f);
}
/**
* 将sp值转换为px值,保证文字大小不变
*
* @param spValue
* (DisplayMetrics类中属性scaledDensity)
* @return
*/
public static int sp2px(Context context, float spValue) {
final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (spValue * fontScale + 0.5f);
}
/**
* 以defaultWidth作为基准和手机屏幕宽度做比较,计算出value对应的手机频幕应显示的像素值
* @param context
* @param defaulWidth 基准像素
* @param value 需要转换的值
* @return
*/
public static int getRealPx(Context context, int defaulWidth, int value){
int screenWidth = getScreenPhysicalSize(context).widthPixels;
return screenWidth * value / defaulWidth;
}
/**
* 以720像素作为基准和手机屏幕宽度做比较,计算出value对应的手机频幕应显示的像素值
* @param context
* @param value
* @return
*/
public static int getRealPx(Context context, int value){
return getRealPx(context,720,value);
}
/**
* 获取控件的高度
*/
public static int getViewMeasuredHeight(View view) {
calculateViewMeasure(view);
return view.getMeasuredHeight();
}
/**
* 获取控件的宽度
*/
public static int getViewMeasuredWidth(View view) {
calculateViewMeasure(view);
return view.getMeasuredWidth();
}
/**
* 测量控件的尺寸
*/
private static void calculateViewMeasure(View view) {
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
view.measure(w, h);
}
public static String viewSaveToImage(View view) {
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
view.setDrawingCacheBackgroundColor(Color.WHITE);
// 把一个View转换成图片
Bitmap cachebmp = loadBitmapFromView(view);
FileOutputStream fos;
String imagePath = "";
try {
// 判断手机设备是否有SD卡
boolean isHasSDCard = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
if (isHasSDCard) {
// SD卡根目录
File sdRoot = Environment.getExternalStorageDirectory();
File file = new File(sdRoot, Calendar.getInstance().getTimeInMillis()+".png");
fos = new FileOutputStream(file);
imagePath = file.getAbsolutePath();
} else
throw new Exception("创建文件失败!");
cachebmp.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
LogUtils.e("","imagePath="+imagePath);
view.destroyDrawingCache();
return imagePath;
}
private static Bitmap loadBitmapFromView(View v) {
int w = v.getWidth();
int h = v.getHeight();
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
c.drawColor(Color.WHITE);
/** 如果不设置canvas画布为白色,则生成透明 */
v.layout(0, 0, w, h);
v.draw(c);
return bmp;
}
public static void showSoftInputFromWindow(Activity activity, EditText editText) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
//显示软键盘
// activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
//如果上面的代码没有弹出软键盘 可以使用下面另一种方式
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, 0);
}
public static int getStatusBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
int height = resources.getDimensionPixelSize(resourceId);
return height;
}
}
package cn.dankal.base.utils;
import android.app.Activity;
import android.content.ClipData;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.provider.MediaStore;
import android.text.ClipboardManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.webkit.WebView;
import com.lidroid.xutils.http.RequestParams;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import static android.content.Context.CLIPBOARD_SERVICE;
public class Utils {
/**
* 获取本机mac
*
* @param context
* @return
*/
public static String getLocalMacAddress(Context context) {
WifiManager wifi = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
return info.getMacAddress();
}
/**
* 加密
*
* @param str
* @return
*/
public static String MD5(String str) {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
e.printStackTrace();
return "";
}
char[] charArray = str.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++) {
byteArray[i] = (byte) charArray[i];
}
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16) {
hexValue.append("0");
}
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
/**
* 检测当的网络(WLAN、3G/2G)状态
*
* @param context
* Context
* @return true 表示网络可用
*/
public static boolean isNetworkAvailable(Context context) {
if(context == null)
return false;
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
// 当前网络是连接的
if (info.getState() == NetworkInfo.State.CONNECTED) {
// 当前所连接的网络可用
return true;
}
}
}
return false;
}
/**
* 检查SD卡是否存在
*
* @return
*/
public static boolean checkSDCard() {
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED))
return true;
else
return false;
}
/**
* 精确获取屏幕尺寸
*
* @param ctx
* @return
*/
public static DisplayMetrics getScreenPhysicalSize(Activity ctx) {
DisplayMetrics dm = new DisplayMetrics();
ctx.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm;
}
/**
* 获取渠道信息
*
* @param context
* @return
*/
public static String getChannelCode(Context context) {
String code = getMetaData(context, "UMENG_CHANNEL");
if (code != null) {
return code;
}
return "1_market";
}
/**
* 获取配置文件属性值
*
* @param context
* @param key
* @return
*/
private static String getMetaData(Context context, String key) {
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(),
PackageManager.GET_META_DATA);
Object value = ai.metaData.get(key);
if (value != null) {
return value.toString();
}
} catch (Exception e) {
//
}
return null;
}
/**
* 获取用户信息
*
* @param context
* @return
*/
public static HashMap<String, String> getDeviceInfo(Context context) {
HashMap<String, String> map = new HashMap<String, String>();
// android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context
// .getSystemService(Context.TELEPHONY_SERVICE);
map.put("imei", getDeviceId(context)); // 手机辨识码
// map.put("mob", tm.getLine1Number()); //手机号码,非登录APP号码
map.put("os", "android"); // 操作系统
String model = Build.MODEL; // 手机型号
map.put("dev", model); // 设备名称
String release = Build.VERSION.RELEASE; // android系统版本号
map.put("osver", release); // app版本号
map.put("chnl", getChannelCode(context)); // 渠道来源
map.put("t", String.valueOf(SystemClock.currentThreadTimeMillis())); // 当前时间戳,从1970年1月1日0时开始到当前时间的毫秒数
// LogUtils.e("json==========>", strJson);
return map;
}
/**
* 获取用户信息
*
* @param context
* @param params
*/
public static void getDeviceInfo(Context context, RequestParams params) {
// android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context
// .getSystemService(Context.TELEPHONY_SERVICE);
params.addHeader("imei", getDeviceId(context)); // 手机辨识码
// params.addHeader("mob", tm.getLine1Number()); //手机号码,非登录APP号码
params.addHeader("os", "android"); // 操作系统
String model = Build.MODEL; // 手机型号
params.addHeader("dev", model); // 设备名称
String release = Build.VERSION.RELEASE; // android系统版本号
params.addHeader("osver", release);
params.addHeader("chnl", getChannelCode(context)); // 渠道来源
params.addHeader("t",
String.valueOf(SystemClock.currentThreadTimeMillis())); // 当前时间戳,从1970年1月1日0时开始到当前时间的毫秒数
}
/**
* 获取设备标识
*
* @param context
* @return
*/
public static String getDeviceId(Context context) {
android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
String strId = "";
if(ActivityCompat.checkSelfPermission(context, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED){
strId = android.provider.Settings.Secure.getString(
context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
if(TextUtils.isEmpty(strId))
strId = getLocalMacAddress(context);
return strId;
}
strId = tm.getDeviceId();
// 如果为空,获取ANDROIDID
if (TextUtils.isEmpty(strId)) {
strId = android.provider.Settings.Secure.getString(
context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
}
if(TextUtils.isEmpty(strId)) {
strId = getLocalMacAddress(context);
}
return strId;
}
public static final String TAG = "Push";
public static final String RESPONSE_METHOD = "method";
public static final String RESPONSE_CONTENT = "content";
public static final String RESPONSE_ERRCODE = "errcode";
public static final String ACTION_MESSAGE = "com.baiud.pushdemo.action.MESSAGE";
public static final String ACTION_RESPONSE = "bccsclient.action.RESPONSE";
public static final String ACTION_SHOW_MESSAGE = "bccsclient.action.SHOW_MESSAGE";
protected static final String EXTRA_ACCESS_TOKEN = "access_token";
public static final String EXTRA_MESSAGE = "message";
/**
* 获取AppKey
*
* @param context
* @param metaKey
* @return
*/
public static String getMetaValue(Context context, String metaKey) {
Bundle metaData = null;
String apiKey = null;
if (context == null || metaKey == null) {
return null;
}
try {
ApplicationInfo ai = context.getPackageManager()
.getApplicationInfo(context.getPackageName(),
PackageManager.GET_META_DATA);
if (null != ai) {
metaData = ai.metaData;
}
if (null != metaData) {
apiKey = metaData.getString(metaKey);
}
} catch (NameNotFoundException e) {
}
return apiKey;
}
/**
* 获取字符串长度
*
* @param value
* @return
*/
public static int length(String value) {
int valueLength = 0;
String chinese = "[\u4e00-\u9fa5]";
// 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1
for (int i = 0; i < value.length(); i++) {
// 获取一个字符
String temp = value.substring(i, i + 1);
// 判断是否为中文字符
if (temp.matches(chinese)) {
// 中文字符长度为1
valueLength += 2;
} else {
// 其他字符长度为0.5
valueLength += 1;
}
}
return valueLength;
}
public static String getRootFilePath() {
if (checkSDCard()) {
return Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/dankal/";// filePath:/sdcard/
} else {
return Environment.getDataDirectory().getAbsolutePath()
+ "/cn.dankal.shell/"; // filePath: /data/data/
}
}
// 获取截图
public static Bitmap convertViewToBitmap(View view) {
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache().copy(Config.RGB_565, false);
return bitmap;
}
public static int compareVersion(String inVersion, String currentVertion) {
String[] spritedInVersion = inVersion.split("\\.");
String[] spritedCurrentVertion = currentVertion.split("\\.");
if (spritedInVersion.length == spritedCurrentVertion.length) {
int lenth = spritedInVersion.length;
for (int i = 0; i < lenth; i++) {
if (Integer.valueOf(spritedInVersion[i]).compareTo(
Integer.valueOf(spritedCurrentVertion[i])) > 0) {
return 1;
} else if (Integer.valueOf(spritedInVersion[i]).compareTo(
Integer.valueOf(spritedCurrentVertion[i])) < 0) {
return -1;
}
}
} else {
int smallLenth = spritedInVersion.length < spritedCurrentVertion.length ? spritedInVersion.length
: spritedCurrentVertion.length;
for (int i = 0; i < smallLenth; i++) {
if (Integer.valueOf(spritedInVersion[i]).compareTo(
Integer.valueOf(spritedCurrentVertion[i])) > 0) {
return 1;
} else if (Integer.valueOf(spritedInVersion[i]).compareTo(
Integer.valueOf(spritedCurrentVertion[i])) < 0) {
return -1;
}
}
if (spritedInVersion.length < spritedCurrentVertion.length) {
return -1;
} else {
return 1;
}
}
return 0;
}
/**
* 通过Uri获取真实文件路径
* @param activity
* @param contentUri
* @return
*/
public static String getRealPathFromURI(Activity activity, Uri contentUri) {
String res = null;
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = activity.getContentResolver().query(contentUri, proj, null, null, null);
if(cursor.moveToFirst()){;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
res = cursor.getString(column_index);
}
cursor.close();
return res;
}
public static synchronized String getCurrentUserAgent(String str) {
Locale locale = Locale.getDefault();
StringBuffer buffer = new StringBuffer();
// Add version
final String version = Build.VERSION.RELEASE;
if (version.length() > 0) {
buffer.append(version);
} else {
// default to "1.0"
buffer.append("1.0");
}
buffer.append("; ");
final String language = locale.getLanguage();
if (language != null) {
buffer.append(language.toLowerCase());
final String country = locale.getCountry();
if (country != null) {
buffer.append("-");
buffer.append(country.toLowerCase());
}
} else {
// default to "en"
buffer.append("en");
}
// add the model for the release build
if ("REL".equals(Build.VERSION.CODENAME)) {
final String model = Build.MODEL;
if (model.length() > 0) {
buffer.append("; ");
buffer.append(model);
}
}
final String id = Build.ID;
if (id.length() > 0) {
buffer.append(" Build/");
buffer.append(id);
}
return String.format(str, buffer);
}
public static String getDay(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date data = new Date();
return sdf.format(data);
}
public static String getDayZn(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
Date data = new Date();
return sdf.format(data);
}
public static String getDay(long time){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date data = new Date(time);
return sdf.format(data);
}
public static String getDaytime(long time){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date data = new Date(time);
return sdf.format(data);
}
/**
* 获取app的版本名称
* @param context
* @return
*/
public static String getAppVersionName(Context context){
PackageInfo packageInfo = getPackageInfo(context);
if(packageInfo != null){
return packageInfo.versionName;
}else
return null;
}
/**
* 获取app的版本编号
* @param context
* @return
*/
public static int getAppVersionCode(Context context){
PackageInfo packageInfo = getPackageInfo(context);
if(packageInfo != null){
return packageInfo.versionCode;
}else
return 0;
}
private static PackageInfo getPackageInfo(Context context) {
PackageInfo pi = null;
try {
PackageManager pm = context.getPackageManager();
pi = pm.getPackageInfo(context.getPackageName(),0);
return pi;
} catch (Exception e) {
e.printStackTrace();
}
return pi;
}
}
/*
* Copyright 2014 - 2015 Henning Dodenhof
*
* 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.dankal.base.views;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.ImageView;
import cn.mctower.visitor.R;
public class CircleImageView extends ImageView {
private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
private static final int COLORDRAWABLE_DIMENSION = 2;
private static final int DEFAULT_BORDER_WIDTH = 0;
private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
private static final int DEFAULT_FILL_COLOR = Color.TRANSPARENT;
private static final boolean DEFAULT_BORDER_OVERLAY = false;
private final RectF mDrawableRect = new RectF();
private final RectF mBorderRect = new RectF();
private final Matrix mShaderMatrix = new Matrix();
private final Paint mBitmapPaint = new Paint();
private final Paint mBorderPaint = new Paint();
private final Paint mFillPaint = new Paint();
private int mBorderColor = DEFAULT_BORDER_COLOR;
private int mBorderWidth = DEFAULT_BORDER_WIDTH;
private int mFillColor = DEFAULT_FILL_COLOR;
private Bitmap mBitmap;
private BitmapShader mBitmapShader;
private int mBitmapWidth;
private int mBitmapHeight;
private float mDrawableRadius;
private float mBorderRadius;
private ColorFilter mColorFilter;
private boolean mReady;
private boolean mSetupPending;
private boolean mBorderOverlay;
public CircleImageView(Context context) {
super(context);
init();
}
public CircleImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);
a.recycle();
init();
}
private void init() {
super.setScaleType(SCALE_TYPE);
mReady = true;
if (mSetupPending) {
setup();
mSetupPending = false;
}
}
@Override
public ScaleType getScaleType() {
return SCALE_TYPE;
}
@Override
public void setScaleType(ScaleType scaleType) {
if (scaleType != SCALE_TYPE) {
throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
}
}
@Override
public void setAdjustViewBounds(boolean adjustViewBounds) {
if (adjustViewBounds) {
throw new IllegalArgumentException("adjustViewBounds not supported.");
}
}
@Override
protected void onDraw(Canvas canvas) {
if (mBitmap == null) {
return;
}
if (mFillColor != Color.TRANSPARENT) {
canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mDrawableRadius, mFillPaint);
}
canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mDrawableRadius, mBitmapPaint);
if (mBorderWidth != 0) {
canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, mBorderRadius, mBorderPaint);
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
setup();
}
public int getBorderColor() {
return mBorderColor;
}
public void setBorderColor(int borderColor) {
if (borderColor == mBorderColor) {
return;
}
mBorderColor = borderColor;
mBorderPaint.setColor(mBorderColor);
invalidate();
}
public void setBorderColorResource(int borderColorRes) {
setBorderColor(getContext().getResources().getColor(borderColorRes));
}
public int getFillColor() {
return mFillColor;
}
public void setFillColor(int fillColor) {
if (fillColor == mFillColor) {
return;
}
mFillColor = fillColor;
mFillPaint.setColor(fillColor);
invalidate();
}
public void setFillColorResource(int fillColorRes) {
setFillColor(getContext().getResources().getColor(fillColorRes));
}
public int getBorderWidth() {
return mBorderWidth;
}
public void setBorderWidth(int borderWidth) {
if (borderWidth == mBorderWidth) {
return;
}
mBorderWidth = borderWidth;
setup();
}
public boolean isBorderOverlay() {
return mBorderOverlay;
}
public void setBorderOverlay(boolean borderOverlay) {
if (borderOverlay == mBorderOverlay) {
return;
}
mBorderOverlay = borderOverlay;
setup();
}
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
mBitmap = bm;
setup();
}
@Override
public void setImageDrawable(Drawable drawable) {
super.setImageDrawable(drawable);
mBitmap = getBitmapFromDrawable(drawable);
setup();
}
@Override
public void setImageResource(int resId) {
super.setImageResource(resId);
mBitmap = getBitmapFromDrawable(getDrawable());
setup();
}
@Override
public void setImageURI(Uri uri) {
super.setImageURI(uri);
mBitmap = uri != null ? getBitmapFromDrawable(getDrawable()) : null;
setup();
}
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
mBitmapPaint.setColorFilter(mColorFilter);
invalidate();
}
private Bitmap getBitmapFromDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
try {
Bitmap bitmap;
if (drawable instanceof ColorDrawable) {
bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private void setup() {
if (!mReady) {
mSetupPending = true;
return;
}
if (getWidth() == 0 && getHeight() == 0) {
return;
}
if (mBitmap == null) {
invalidate();
return;
}
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setShader(mBitmapShader);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mFillPaint.setStyle(Paint.Style.FILL);
mFillPaint.setAntiAlias(true);
mFillPaint.setColor(mFillColor);
mBitmapHeight = mBitmap.getHeight();
mBitmapWidth = mBitmap.getWidth();
mBorderRect.set(0, 0, getWidth(), getHeight());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
mDrawableRect.set(mBorderRect);
if (!mBorderOverlay) {
mDrawableRect.inset(mBorderWidth, mBorderWidth);
}
mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
updateShaderMatrix();
invalidate();
}
private void updateShaderMatrix() {
float scale;
float dx = 0;
float dy = 0;
mShaderMatrix.set(null);
if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
scale = mDrawableRect.height() / (float) mBitmapHeight;
dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
} else {
scale = mDrawableRect.width() / (float) mBitmapWidth;
dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
}
mShaderMatrix.setScale(scale, scale);
mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
mBitmapShader.setLocalMatrix(mShaderMatrix);
}
}
package cn.mctower.visitor;
import cn.dankal.base.utils.Utils;
/**
* Author:Alex tang
* Date:2020-07-20
* Time:12:47
* Description:
*/
public class Constant {
public static String BaseImagesDir = Utils.getRootFilePath() + "/image/";
// public static String Host = "https://api-mircrosoft-building.dankal.cn/v1/";
public static String Host = "https://api.mctower.dankal.cn/v1/";
public static final String API_VISIT_RECORD_LIST = Host + "mini/visit/users";
public static final String API_VISIT_DETAIL = Host + "mini/visit/user/detail/";
public static final String API_GET_QINIU_TOKEN = Host + "cms/property/common/ignore/qiniu";
public static final String API_SAVE_USER_INFO = Host + "mini/visit/user/binding";
public static final String API_SAVE_USER_INFO_OTHER = Host + "mini/visit/user/binding/other";
public static final String API_SAVE_NOTE = Host + "mini/visit/user/remark";
}
package cn.mctower.visitor;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.brilliants.idcardlib.IDCard;
import com.brilliants.idcardlib.IDCardCallBack;
import com.brilliants.idcardlib.IDCardUtils;
import com.google.gson.Gson;
import com.invs.invsIdCard;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UploadManager;
import com.qiniu.android.storage.UploadOptions;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cn.dankal.base.activity.NetBaseAppCompatActivity;
import cn.dankal.base.http.DialogHttpCallBack;
import cn.dankal.base.http.HttpPostHelper;
import cn.dankal.base.http.NOToastHttpCallBack;
import cn.dankal.base.utils.ImageUtil;
import cn.dankal.base.utils.LogUtils;
import cn.dankal.base.utils.NetPicUtil;
import cn.dankal.base.utils.ToastUtils;
import cn.dankal.base.utils.UIUtil;
import cn.dankal.base.views.CircleImageView;
import cn.mctower.visitor.model.DetailPageBean;
import cn.mctower.visitor.model.QiNiuTokenBean;
import cn.mctower.visitor.model.RemarkBean;
import cn.mctower.visitor.model.VisitRecordBean;
public class DetailActivity extends NetBaseAppCompatActivity {
@ViewInject(R.id.titleTv)
TextView titleTv;
@ViewInject(R.id.headPic)
CircleImageView headPic;
@ViewInject(R.id.name)
TextView name;
@ViewInject(R.id.idPic)
ImageView idPic;
@ViewInject(R.id.realName)
TextView realName;
@ViewInject(R.id.gender)
TextView gender;
@ViewInject(R.id.idNoTitle)
TextView idNoTitle;
@ViewInject(R.id.idCode)
TextView idCode;
@ViewInject(R.id.idNum)
TextView idNum;
@ViewInject(R.id.takePhotoFrame)
LinearLayout takePhotoFrame;
@ViewInject(R.id.facePicBtn)
RelativeLayout facePicBtn;
@ViewInject(R.id.idPicBtn)
RelativeLayout idPicBtn;
@ViewInject(R.id.idPicture)
ImageView idPicture;
@ViewInject(R.id.addIDPicTipFrame)
LinearLayout addIDPicTipFrame;
@ViewInject(R.id.facePicture)
ImageView facePicture;
@ViewInject(R.id.addFacePicTipFrame)
LinearLayout addFacePicTipFrame;
@ViewInject(R.id.listView)
RecyclerView listView;
@ViewInject(R.id.noteInput)
EditText noteInput;
@ViewInject(R.id.bindBtn)
TextView bindBtn;
@ViewInject(R.id.otherBindBtn)
TextView otherBindBtn;
@ViewInject(R.id.readSuccessDialogFrame)
RelativeLayout readSuccessDialogFrame;
@ViewInject(R.id.idPicInDialog)
ImageView idPicInDialog;
@ViewInject(R.id.nameInDialog)
TextView nameInDialog;
@ViewInject(R.id.genderInDialog)
TextView genderInDialog;
@ViewInject(R.id.idCodeInDialog)
TextView idCodeInDialog;
@ViewInject(R.id.bindBtnInDialog)
TextView bindBtnInDialog;
@ViewInject(R.id.otherBindDialogFrame)
RelativeLayout otherBindDialogFrame;
@ViewInject(R.id.otherIdInput)
EditText otherIdInput;
@ViewInject(R.id.otherIdPicture)
ImageView otherIdPicture;
private String id;
private MyAdapter adapter;
private ArrayList<VisitRecordBean> data = new ArrayList<>();
private DetailPageBean bean;
private NetPicUtil netPicUtil = new NetPicUtil(R.mipmap.ic_tou,R.mipmap.ic_tou,R.mipmap.ic_tou);
// private IDCard idCard;
private List<LocalMedia> mSelectList = new ArrayList<>();
private LocalMedia idPicMedia;
private LocalMedia facePicMedia;
private boolean isTakeIdPicNow = false;
private invsIdCard invsIdCard;
private Bitmap identityImgBitmap;
private QiNiuTokenBean qiNiuTokenBean;
private CountDownTimer countDownTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
setAndroidNativeLightStatusBar(this,true);
setStatusBarColor(this,android.R.color.white);
ViewUtils.inject(this);
id = getIntent().getStringExtra("id");
titleTv.setText("详情");
int width = (UIUtil.getScreenPhysicalSize(this).widthPixels - UIUtil.Dp2Px(this,22f) * 2 - UIUtil.Dp2Px(this,15f) ) / 2;
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) idPicBtn.getLayoutParams();
lp.height = (int)(width * 1.15);
lp.width = width;
idPicBtn.setLayoutParams(lp);
LinearLayout.LayoutParams lp1 = (LinearLayout.LayoutParams) facePicBtn.getLayoutParams();
lp1.height = (int)(width * 1.15);
lp1.width = width;
facePicBtn.setLayoutParams(lp1);
LinearLayoutManager lm = new LinearLayoutManager(this);
lm.setOrientation(LinearLayoutManager.VERTICAL);
listView.setLayoutManager(lm);
adapter = new MyAdapter();
listView.setAdapter(adapter);
loadData();
}
private void loadData(){
HttpPostHelper.httpGet(this, Constant.API_VISIT_DETAIL+id,new DialogHttpCallBack(this){
@Override
public void successCallBack(String result) {
super.successCallBack(result);
bean = new Gson().fromJson(result,DetailPageBean.class);
setViews();
}
},null);
}
private void initQiNiuToken(){
HttpPostHelper.httpGet(this, Constant.API_GET_QINIU_TOKEN, new NOToastHttpCallBack() {
@Override
public void successCallBack(String result) {
super.successCallBack(result);
LogUtils.e("aaaa","json == ====" +result);
qiNiuTokenBean = new Gson().fromJson(result, QiNiuTokenBean.class);
//设置身份证图片
if(qiNiuTokenBean != null && !TextUtils.isEmpty(qiNiuTokenBean.url)){
if(bean.user.isBindingId != 0) {
if (!TextUtils.isEmpty(bean.user.identityImg)) {
netPicUtil.setDefaultPics(R.mipmap.ic_the, R.mipmap.ic_the, R.mipmap.ic_the);
netPicUtil.display(idPic, qiNiuTokenBean.url + bean.user.identityImg);
}
if (!TextUtils.isEmpty(bean.user.certificatesImg)) {
addIDPicTipFrame.setVisibility(View.GONE);
idPicture.setVisibility(View.VISIBLE);
netPicUtil.display(idPicture, qiNiuTokenBean.url + bean.user.certificatesImg);
}
}
if(!TextUtils.isEmpty(bean.user.faceImg))
netPicUtil.display(facePicture,qiNiuTokenBean.url+bean.user.faceImg);
}
}
}, null);
}
private void setViews(){
if(bean != null){
if(bean.user != null) {
if (!TextUtils.isEmpty(bean.user.wxImg)){
netPicUtil.display(headPic,bean.user.wxImg);
}
name.setText(bean.user.wxName);
realName.setText(bean.user.userName);
gender.setText(bean.user.sex);
idCode.setText(bean.user.identityCard);
idNum.setText(bean.user.isBindingId != 0 ? "证件号码:"+bean.user.identityCard : "");
bindBtn.setText(bean.user.isBindingId == 1 ? "更新" : "绑定");
otherBindBtn.setText(bean.user.isBindingId == 2 ? "更新其他证件" : "绑定其他证件");
// idNoTitle.setVisibility(bean.user.isBindingId == 1 ? View.INVISIBLE : View.VISIBLE);
// idCode.setVisibility(bean.user.isBindingId == 1 ? View.INVISIBLE : View.VISIBLE);
noteInput.setText(bean.user.remark);
initQiNiuToken();
}
if(bean.visitList != null){
data.addAll(bean.visitList);
adapter.notifyDataSetChanged();
}
}
}
//显示去读取身份证弹框
private void showReadIdAlert(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final Dialog dialog = builder.create();
LayoutInflater inflaterDl = LayoutInflater.from(this);
RelativeLayout layout = (RelativeLayout) inflaterDl.inflate(R.layout.layout_dialog_read_id_info, null);
dialog.show();
dialog.getWindow().setContentView(layout);
TextView btn = layout.findViewById(R.id.btn);
btn.setOnClickListener(v -> {
dialog.dismiss();
});
}
private void showReadIdSuccessAlert(invsIdCard invsIdCard){
if (invsIdCard != null) {
// identityImgBitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_tou);
//解析身份证图片
identityImgBitmap = IDCardUtils.Wlt2Bitmap(invsIdCard.wlt);
idPicInDialog.setImageBitmap(identityImgBitmap);
nameInDialog.setText(invsIdCard.getName());
genderInDialog.setText(invsIdCard.getSex1());
idCodeInDialog.setText(invsIdCard.getIdNo());
readSuccessDialogFrame.setVisibility(View.VISIBLE);
bindBtnInDialog.setOnClickListener(v -> {
readSuccessDialogFrame.setVisibility(View.GONE);
bindId(invsIdCard);
});
}else{
show("读取身份信息失败");
}
}
private void bindId(invsIdCard info){
if(info != null) {
invsIdCard = info;
idPic.setImageBitmap(identityImgBitmap);
realName.setText(info.getName());
gender.setText(info.getSex1());
idCode.setText(info.getIdNo());
uploadImages(false);
}
}
private String identityImgUrl; //身份证照片url
private String certificatesImgUrl; //证件照片url
private String faceImgUrl; //脸部照片url
private UploadFileInfoBean needUploadBean;
private ArrayList<UploadFileInfoBean> files;//需要上传的图片信息数组
private void uploadImages(boolean isBindOther){
if (qiNiuTokenBean == null) {
show("获取七牛token失败");
return;
}
if(facePicMedia != null || idPicMedia != null || identityImgBitmap != null){
files = new ArrayList<>();
//先处理bitmap,身份证bitmap
if(!isBindOther) { //绑定身份证
if (identityImgBitmap != null) {
try {
String path = ImageUtil.saveImageToFile(identityImgBitmap);
if (!TextUtils.isEmpty(path)) {
File file = new File(path);
LogUtils.e("aaa", "file = " + file.getAbsolutePath());
if (file.exists() && file.isFile()) {
LogUtils.e("aaa", "add idImg");
files.add(new UploadFileInfoBean(file, "idImg", 0));
}
}
} catch (Exception e) {
e.printStackTrace();
// show(e.getMessage());
}
}
if (facePicMedia != null) {
File file = new File(getLocalMediaPath(facePicMedia));
if (file.exists() && file.isFile())
files.add(new UploadFileInfoBean(file, "faceImg", 0));
}
}else { //绑定其他证件
if (idPicMedia != null) {
File file = new File(getLocalMediaPath(idPicMedia));
if (file.exists() && file.isFile())
files.add(new UploadFileInfoBean(file, "certificatesImg", 0));
}
}
if(files.size() > 0) {
initPicUpload();
uploadFiles(isBindOther);
}else{
uploadData(isBindOther);
}
}else{
uploadData(isBindOther);
}
}
private UploadManager uploadManager;
private ProgressDialog progressDialog;
private void initPicUpload(){
Configuration config = new Configuration.Builder()
.responseTimeout(60)
.build();
uploadManager = new UploadManager(config);
progressDialog = new ProgressDialog(this,ProgressDialog.THEME_HOLO_LIGHT);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle("上传图片");
progressDialog.setMax(100);
progressDialog.setProgress(0);
progressDialog.show();
}
private void uploadFiles(boolean isBindOther){
if(uploadManager != null){
needUploadBean = null;
//检测是否还有待上传的文件
for(UploadFileInfoBean bean : files){
if(bean.status == 0) {
needUploadBean = bean;
break;
}
}
if(needUploadBean != null){ //上传图片
String keyStr = "mctower_pic_" + System.currentTimeMillis() + "_" + new Random().nextInt(99999);
String msg = "";
switch (needUploadBean.type){
case "idImg":
msg = "正在上传身份证头像";
break;
case "faceImg":
msg = "正在上传面部照片";
break;
case "certificatesImg":
msg = "正在上传证件照片";
break;
}
progressDialog.setMessage(msg);
uploadManager.put(needUploadBean.file, keyStr, qiNiuTokenBean.token,
(key, info, res) -> {
//res包含hash、key等信息,具体字段取决于上传策略的设置
if (info.isOK()) {
LogUtils.e("qiniu", "Upload Success");
needUploadBean.url = key;
needUploadBean.status = 1;
progressDialog.dismiss();
} else {
LogUtils.e("qiniu", "Upload Fail info=" + info + " res = " + res);
//如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
runOnUiThread(new Runnable() {
public void run() {
show("上传图片失败");
}
});
needUploadBean.status = -1;
progressDialog.dismiss();
}
uploadFiles(isBindOther);
// LogUtils.e("qiniu", key + ",\r\n " + info + ",\r\n " + res);
}, new UploadOptions(null, null, false,
(key, percent) -> {
progressDialog.setMax(100);
progressDialog.setProgress((int) (percent * 100));
LogUtils.e("qiniu", "key = " + key + ",percent = " + percent);
}, null));
}else{ //图片都已上传过,提交数据到服务器
for(UploadFileInfoBean bean : files){
if(bean.status == 1) {
switch (bean.type){
case "idImg":
identityImgUrl = bean.url;
break;
case "faceImg":
faceImgUrl = bean.url;
break;
case "certificatesImg":
certificatesImgUrl = bean.url;
break;
}
}
}
uploadData(isBindOther);
}
}
}
private void uploadData(boolean isBindOther){
if(isBindOther){//绑定其他证件
String code = otherIdInput.getText().toString();
if(TextUtils.isEmpty(code)){
ToastUtils.show("请输入证件号");
return;
}
UploadBindOtherDataBean bean = new UploadBindOtherDataBean();
bean.certificatesCode = code;
if (!TextUtils.isEmpty(certificatesImgUrl))
bean.certificatesImg = certificatesImgUrl;
bean.uuid = id;
HttpPostHelper.httpPutJson(this, Constant.API_SAVE_USER_INFO_OTHER, new DialogHttpCallBack(this) {
@Override
public void successCallBack(String result) {
super.successCallBack(result);
idNum.setText("证件号码:"+code);
ToastUtils.show("操作成功");
}
}, new Gson().toJson(bean));
}else {//绑定身份证
UploadDataBean bean = new UploadDataBean();
bean.identityCard = invsIdCard.getIdNo();
if (!TextUtils.isEmpty(identityImgUrl))
bean.identityImg = identityImgUrl;
if (!TextUtils.isEmpty(faceImgUrl))
bean.faceImg = faceImgUrl;
bean.sex = invsIdCard.getSex1();
bean.userName = invsIdCard.getName();
bean.uuid = id;
HttpPostHelper.httpPutJson(this, Constant.API_SAVE_USER_INFO, new DialogHttpCallBack(this) {
@Override
public void successCallBack(String result) {
super.successCallBack(result);
bindBtn.setText("更新");
idNoTitle.setVisibility(View.INVISIBLE);
idCode.setVisibility(View.INVISIBLE);
ToastUtils.show("操作成功");
}
}, new Gson().toJson(bean));
}
}
/**
* 从设备读取数据
*/
private boolean startReadDeviceData = false;
private void readDataFromDevice(){
startReadDeviceData = true;
if(countDownTimer != null)
countDownTimer.cancel();
countDownTimer = new CountDownTimer(3000,1000) {
@Override
public void onTick(long l) {
/*invsIdCard in = new invsIdCard();
in.setIdNo(String.valueOf(l));
in.setSex1("男");
in.setName("哈哈哈哈");
showReadIdSuccessAlert(in);*/
}
@Override
public void onFinish() {
dismmisLoadingDialog();
showReadIdAlert();
}
}.start();
showLoadingDialog();
/*if(idCard == null) {
idCard = new IDCard(getApplicationContext(), new IDCardCallBack() {
@Override
public void idCardDeviceComment() {
}
@Override
public void idCardDeviceUnComment() {
}
@Override
public void readIDCardDataFail() {
//读卡器读取身份证信息失败
runOnUiThread(() -> {
showReadIdAlert();
dismmisLoadingDialog();
});
countDownTimer.cancel();
}
@Override
public void readIDCardData(invsIdCard invsIdCard, boolean b) {
//读卡器读取身份证信息成功
runOnUiThread(() -> {
showReadIdSuccessAlert(invsIdCard);
dismmisLoadingDialog();
});
countDownTimer.cancel();
}
});
}
*/
}
@OnClick({R.id.backBtn,R.id.otherBindBtn,R.id.otherIdPicture,R.id.uploadFacePicBtn,R.id.addFacePicTipFrame,R.id.bindBtn,
R.id.cancelBtnInDialog,R.id.readSuccessDialogFrame,R.id.otherBindDialogFrame,R.id.saveNoteBtn,
R.id.cancelBtn4OtherBind,R.id.bindBtn4OtherBind})
public void click(View view){
switch (view.getId()){
case R.id.backBtn:
onBackPressed();
break;
case R.id.otherBindBtn:
otherBindDialogFrame.setVisibility(View.VISIBLE);
break;
case R.id.otherIdPicture:
takePhoto(true);
break;
case R.id.uploadFacePicBtn:
case R.id.addFacePicTipFrame:
takePhoto(false);
break;
case R.id.bindBtn:
readDataFromDevice();
break;
case R.id.readSuccessDialogFrame:
case R.id.otherBindDialogFrame:
break;
case R.id.cancelBtnInDialog:
readSuccessDialogFrame.setVisibility(View.GONE);
break;
case R.id.saveNoteBtn:
saveNote();
break;
case R.id.cancelBtn4OtherBind:
otherBindDialogFrame.setVisibility(View.GONE);
break;
case R.id.bindBtn4OtherBind:
if(TextUtils.isEmpty(otherIdInput.getText().toString().trim())){
ToastUtils.show("请输入证件号");
break;
}
if(idPicMedia == null){
ToastUtils.show("请拍摄证件照");
break;
}
otherBindDialogFrame.setVisibility(View.GONE);
uploadImages(true);
break;
}
}
private void saveNote(){
String note = noteInput.getText().toString().trim();
if(!TextUtils.isEmpty(note)){
RemarkBean remarkBean= new RemarkBean();
remarkBean.remark = note;
remarkBean.userUuid = id;
HttpPostHelper.httpPutJson(this,Constant.API_SAVE_NOTE,new DialogHttpCallBack(this){
@Override
public void successCallBack(String result) {
super.successCallBack(result);
ToastUtils.show("备注成功");
}
},remarkBean.toString());
}
}
private void takePhoto(boolean isIDCard){
isTakeIdPicNow = isIDCard;
PictureSelector.create(this)
.openCamera(PictureMimeType.ofImage())
.theme(R.style.picture_default_style)
.maxSelectNum(1)// 最大图片选择数量
.minSelectNum(1)// 最小选择数量
.imageSpanCount(4)// 每行显示个数
.selectionMode(PictureConfig.SINGLE)// 多选 or 单选
.previewImage(true)// 是否可预览图片
.isCamera(true)// 是否显示拍照按钮
.isZoomAnim(true)// 图片列表点击 缩放效果 默认true
.enableCrop(false)// 是否裁剪
.compress(true)// 是否压缩
.synOrAsy(true)//同步true或异步false 压缩 默认同步
.glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
.freeStyleCropEnabled(true)// 裁剪框是否可拖拽
.selectionMedia(mSelectList)// 是否传入已选图片
.minimumCompressSize(100)// 小于100kb的图片不压缩
.forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data == null) {
return;
}
switch (requestCode) {
case PictureConfig.CHOOSE_REQUEST:
// 图片选择结果回调
mSelectList = PictureSelector.obtainMultipleResult(data);
if(mSelectList != null && mSelectList.size() > 0) {
LocalMedia media = mSelectList.get(0);
if (isTakeIdPicNow) {
idPicMedia = media;
otherIdPicture.setImageBitmap(BitmapFactory.decodeFile(getLocalMediaPath(idPicMedia)));
idPicture.setImageBitmap(BitmapFactory.decodeFile(getLocalMediaPath(idPicMedia)));
idPicture.setVisibility(View.VISIBLE);
addIDPicTipFrame.setVisibility(View.GONE);
} else {
facePicMedia = media;
facePicture.setImageBitmap(BitmapFactory.decodeFile(getLocalMediaPath(facePicMedia)));
facePicture.setVisibility(View.VISIBLE);
addFacePicTipFrame.setVisibility(View.GONE);
}
}
break;
}
}
//获取LocalMedia的路径
private String getLocalMediaPath(LocalMedia media){
String path = "";
if (media.isCut() && !media.isCompressed()) {
// 裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
} else {
// 原图
path = media.getPath();
}
return path;
}
@Override
public void onBackPressed() {
super.onBackPressed();
/*if(idCard != null)
idCard .unInit();*/
}
class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private LayoutInflater layoutInflater = LayoutInflater.from(DetailActivity.this);
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = layoutInflater.inflate(R.layout.itme_visit_record_log, parent, false);
return new CustomViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
VisitRecordBean bean = data.get(position);
CustomViewHolder viewHolder = (CustomViewHolder) holder;
viewHolder.topDot1.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
viewHolder.topDot2.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
viewHolder.topLine1.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
viewHolder.topLine2.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
viewHolder.bottomDot1.setVisibility(position == data.size() - 1 ? View.GONE : View.VISIBLE);
viewHolder.bottomDot2.setVisibility(position == data.size() - 1 ? View.GONE : View.VISIBLE);
viewHolder.bottomLine1.setVisibility(position == data.size() - 1 ? View.GONE : View.VISIBLE);
viewHolder.bottomLine2.setVisibility(position == data.size() - 1 ? View.GONE : View.VISIBLE);
viewHolder.companyName.setText(bean.companyName);
viewHolder.invatePerson.setText(bean.staffName);
viewHolder.time.setText(bean.visitorTime);
viewHolder.mobile.setText(bean.phone);
}
@Override
public int getItemCount() {
return data.size();
}
}
public void readIdCardFailure(){
if(startReadDeviceData) {
runOnUiThread(() -> {
showReadIdAlert();
dismmisLoadingDialog();
});
if (countDownTimer != null)
countDownTimer.cancel();
}
}
public void setIdCardInfo(invsIdCard invsIdCard){
if(startReadDeviceData) {
runOnUiThread(() -> {
showReadIdSuccessAlert(invsIdCard);
dismmisLoadingDialog();
});
if (countDownTimer != null)
countDownTimer.cancel();
}
}
class CustomViewHolder extends RecyclerView.ViewHolder{
private TextView companyName;
private TextView invatePerson;
private TextView time;
private TextView mobile;
private TextView topDot1;
private TextView topLine1;
private TextView topDot2;
private TextView topLine2;
private TextView bottomDot1;
private TextView bottomDot2;
private TextView bottomLine1;
private TextView bottomLine2;
public CustomViewHolder(@NonNull View itemView) {
super(itemView);
companyName = itemView.findViewById(R.id.companyName);
invatePerson = itemView.findViewById(R.id.invatePerson);
time = itemView.findViewById(R.id.time);
mobile = itemView.findViewById(R.id.mobile);
topDot1 = itemView.findViewById(R.id.topDot1);
topLine1 = itemView.findViewById(R.id.topLine1);
topDot2 = itemView.findViewById(R.id.topDot2);
topLine2 = itemView.findViewById(R.id.topLine2);
bottomDot1 = itemView.findViewById(R.id.bottomDot1);
bottomDot2 = itemView.findViewById(R.id.bottomDot2);
bottomLine1 = itemView.findViewById(R.id.bottomLine1);
bottomLine2 = itemView.findViewById(R.id.bottomLine2);
}
}
class UploadDataBean {
public String faceImg; //img",
public String identityCard; //4113*****",
public String identityImg; //img",
public String sex; //男女",
public String userName; //wjz",
public String uuid; //uuid"
}
class UploadFileInfoBean{
public File file;
public String type;
public int status; // 0: 待上传 1:上传成功 -1:上传失败
public String url;
public UploadFileInfoBean(File file, String type, int stutas) {
this.file = file;
this.type = type;
this.status = stutas;
}
}
class UploadBindOtherDataBean{
public String certificatesCode;
public String certificatesImg;
public String uuid;
}
}
package cn.mctower.visitor;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import com.brilliants.idcardlib.IDCard;
import com.brilliants.idcardlib.IDCardCallBack;
import com.invs.invsIdCard;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.tencent.bugly.Bugly;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import cn.dankal.base.activity.NetBaseAppCompatActivity;
/**
* Author:Alex tang
* Date:2020-07-20
* Time:11:41
* Description:
*/
public class MCTowerApplication extends Application {
private static Context context;
private static IDCard idCard;
private Activity currentActivity;
@Override
public void onCreate() {
super.onCreate();
this.context = this;
//初始化imageloader
ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
config.threadPriority(Thread.NORM_PRIORITY - 2);
config.denyCacheImageMultipleSizesInMemory();
config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
config.diskCacheSize(300 * 1024 * 1024); // 300 MiB
config.tasksProcessingOrder(QueueProcessingType.LIFO);
ImageLoader.getInstance().init(config.build());
Bugly.init(getApplicationContext(), "2c5f751c8c", true);
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
currentActivity = activity;
}
@Override
public void onActivityStarted(@NonNull Activity activity) {
currentActivity = activity;
}
@Override
public void onActivityResumed(@NonNull Activity activity) {
currentActivity = activity;
}
@Override
public void onActivityPaused(@NonNull Activity activity) {
}
@Override
public void onActivityStopped(@NonNull Activity activity) {
}
@Override
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
}
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
}
});
idCard = new IDCard(this, new IDCardCallBack() {
@Override
public void idCardDeviceComment() {
}
@Override
public void idCardDeviceUnComment() {
}
@Override
public void readIDCardDataFail() {
if(currentActivity != null){
if(currentActivity instanceof MainActivity){
((MainActivity)currentActivity).readIdCardFailure();
}else if(currentActivity instanceof DetailActivity){
((DetailActivity)currentActivity).readIdCardFailure();
}
}
}
@Override
public void readIDCardData(invsIdCard invsIdCard, boolean b) {
if(currentActivity != null){
if(currentActivity instanceof MainActivity){
((MainActivity)currentActivity).setIdCardInfo(invsIdCard);
}else if(currentActivity instanceof DetailActivity){
((DetailActivity)currentActivity).setIdCardInfo(invsIdCard);
}
}
}
});
}
@Override
public void onTerminate() {
super.onTerminate();
if(idCard != null)
idCard.unInit();
}
public static Context getContext(){
return context;
}
}
package cn.mctower.visitor;
import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.brilliants.idcardlib.IDCard;
import com.brilliants.idcardlib.IDCardCallBack;
import com.google.gson.Gson;
import com.invs.invsIdCard;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import java.util.ArrayList;
import java.util.HashMap;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cn.dankal.base.activity.NetBaseAppCompatActivity;
import cn.dankal.base.http.DialogHttpCallBack;
import cn.dankal.base.http.HttpPostHelper;
import cn.dankal.base.interfaces.IPermissionCheck;
import cn.dankal.base.utils.LogUtils;
import cn.dankal.base.utils.ToastUtils;
import cn.mctower.visitor.model.VisitRecordBean;
import cn.mctower.visitor.model.VisitRecordPageBean;
public class MainActivity extends NetBaseAppCompatActivity {
@ViewInject(R.id.titleTv)
TextView titleTv;
@ViewInject(R.id.visitorFrame)
LinearLayout visitorFrame;
@ViewInject(R.id.visitorBtn)
TextView visitorBtn;
@ViewInject(R.id.searchPageFrame)
LinearLayout searchPageFrame;
@ViewInject(R.id.inputTipFrame)
LinearLayout inputTipFrame;
@ViewInject(R.id.clearBtn)
ImageView clearBtn;
@ViewInject(R.id.input)
EditText input;
@ViewInject(R.id.searchBtn)
TextView searchBtn;
@ViewInject(R.id.tip)
TextView tip;
@ViewInject(R.id.listView)
RecyclerView listView;
private ArrayList<VisitRecordBean> data = new ArrayList<>();
private MyAdapter adapter;
private invsIdCard invsIdCard;
// private IDCard idCard;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setAndroidNativeLightStatusBar(this,true);
setStatusBarColor(this,android.R.color.white);
ViewUtils.inject(this);
titleTv.setText("信息");
input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if(b){
inputTipFrame.setVisibility(View.GONE);
}else{
if(TextUtils.isEmpty(input.getText().toString()))
inputTipFrame.setVisibility(View.VISIBLE);
}
}
});
input.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
clearBtn.setVisibility(!TextUtils.isEmpty(input.getText().toString()) ? View.VISIBLE : View.GONE);
}
});
input.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
click(searchBtn);
return true;
}
return false;
});
LinearLayoutManager lm = new LinearLayoutManager(this);
lm.setOrientation(LinearLayoutManager.VERTICAL);
listView.setLayoutManager(lm);
adapter = new MyAdapter();
listView.setAdapter(adapter);
String[] permission = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
requestPermissions(permission, 12122, "需要存储权限", new IPermissionCheck() {
@Override
public void hasGotPermissions(int code) {
}
});
readDataFromDevice();
}
@OnClick({R.id.backBtn,R.id.visitorBtn,R.id.clearBtn,R.id.searchBtn})
public void click(View view){
switch (view.getId()){
case R.id.backBtn:
onBackPressed();
break;
case R.id.visitorBtn:
visitorFrame.setVisibility(View.GONE);
searchPageFrame.setVisibility(View.VISIBLE);
break;
case R.id.clearBtn:
input.setText("");
break;
case R.id.searchBtn:
doSearch();
break;
}
}
@Override
public void onBackPressed() {
if(searchPageFrame.getVisibility() == View.VISIBLE){
visitorFrame.setVisibility(View.VISIBLE);
searchPageFrame.setVisibility(View.GONE);
data.clear();
adapter.notifyDataSetChanged();
}else
super.onBackPressed();
}
private void doSearch(){
String key = input.getText().toString().trim();
HashMap<String,String> param = new HashMap<>();
// if(!TextUtils.isEmpty(key))
param.put("search",key);
param.put("pageIndex","1");
param.put("pageSize","10000");
HttpPostHelper.httpGet(this,Constant.API_VISIT_RECORD_LIST,new DialogHttpCallBack(this){
@Override
public void requestStart() {
super.requestStart();
data.clear();
}
@Override
public void successCallBack(String result) {
super.successCallBack(result);
VisitRecordPageBean bean = new Gson().fromJson(result,VisitRecordPageBean.class);
if(bean != null && bean.data != null){
data.addAll(bean.data);
adapter.notifyDataSetChanged();
}
}
@Override
public void requestFinish() {
super.requestFinish();
setTip();
}
},param);
}
private void setTip(){
if(data.size() > 0){
tip.setVisibility(View.GONE);
}else{
tip.setText("系统中无匹配姓名的记录");
tip.setVisibility(View.VISIBLE);
}
}
/**
* 从设备读取数据
*/
private void readDataFromDevice(){
/*idCard = new IDCard(getApplicationContext(), new IDCardCallBack() {
@Override
public void idCardDeviceComment() {
// ToastUtils.show("读卡器已连接");
}
@Override
public void idCardDeviceUnComment() {
// ToastUtils.show("读卡器已断开");
}
@Override
public void readIDCardDataFail() {
//读卡器读取身份证信息失败
runOnUiThread(() -> ToastUtils.show("读取失败"));
}
@Override
public void readIDCardData(invsIdCard invsIdCard, boolean b) {
runOnUiThread(() -> input.setText(invsIdCard.getName()));
}
});*/
}
@Override
protected void onDestroy() {
super.onDestroy();
// idCard.unInit();
}
public void setIdCardInfo(invsIdCard invsIdCard){
if(invsIdCard != null){
runOnUiThread(() -> input.setText(invsIdCard.getName()));
}
}
public void readIdCardFailure(){
runOnUiThread(() -> ToastUtils.show("读取失败"));
}
class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = layoutInflater.inflate(R.layout.itme_visit_record, parent, false);
return new CustomViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
VisitRecordBean bean = data.get(position);
CustomViewHolder viewHolder = (CustomViewHolder) holder;
viewHolder.name.setText(bean.clientName);
viewHolder.mobile.setText(bean.phone);
viewHolder.company.setText(bean.companyName);
viewHolder.staffName.setText(bean.staffName);
viewHolder.item.setOnClickListener(view -> {
if(!TextUtils.isEmpty(bean.userUuid)) {
Intent intent = new Intent(MainActivity.this, DetailActivity.class);
intent.putExtra("id", bean.userUuid);
startActivity(intent);
}else
ToastUtils.show("本条邀请还未分享给访客");
});
}
@Override
public int getItemCount() {
return data.size();
}
}
class CustomViewHolder extends RecyclerView.ViewHolder{
private RelativeLayout item;
private TextView name;
private TextView mobile;
private TextView company;
private TextView staffName;
public CustomViewHolder(@NonNull View itemView) {
super(itemView);
item = itemView.findViewById(R.id.item);
name = itemView.findViewById(R.id.name);
staffName = itemView.findViewById(R.id.staffName);
mobile = itemView.findViewById(R.id.mobile);
company = itemView.findViewById(R.id.company);
}
}
}
package cn.mctower.visitor.model;
import java.util.ArrayList;
/**
* Author:Alex tang
* Date:2020-07-21
* Time:15:10
* Description:
*/
public class DetailPageBean {
public UserInfoBean user;
public ArrayList<VisitRecordBean> visitList;
public static class UserInfoBean{
public String uuid; //4855f420006b4e0097bdfa6874729edd",
public String wxName; //F",
public String wxImg; //https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJfaKrsAASnzvgPU5F7DBs1meONalvLMDxnv3ic6pPIuI0Vyicyicp9zFpSu6iaZiaAjNmLFsn5icuuTTQA/132",
public String userName; //F",
public String sex; //null,
public String identityCard; //null,
public String identityImg; //null
public int isBindingId;
public String faceImg;
public String remark;
public String certificatesImg;
}
}
package cn.mctower.visitor.model;
/**
* Author:Alex tang
* Date:2020-07-23
* Time:10:26
* Description:
*/
public class QiNiuTokenBean {
public String token;
public String url;
}
package cn.mctower.visitor.model;
import com.google.gson.Gson;
import androidx.annotation.NonNull;
/**
* Author:Alex tang
* Date:2020-08-03
* Time:10:23
* Description:
*/
public class RemarkBean {
public String remark;
public String userUuid;
@NonNull
@Override
public String toString() {
return new Gson().toJson(this);
}
}
package cn.mctower.visitor.model;
/**
* Author:Alex tang
* Date:2020-07-21
* Time:13:29
* Description:
*/
public class VisitRecordBean {
public String clientName; // 客户名字",
public String companyName; // 公司名字",
public String staffName;
public String companyUuid; // uuid",
public String phone; // 客户名字",
public String userUuid; // 客户名字",
public String uuid; // 访客申请uuid",
public String visitorTime; // 公司名字"
}
package cn.mctower.visitor.model;
import java.util.ArrayList;
/**
* Author:Alex tang
* Date:2020-07-21
* Time:13:30
* Description:
*/
public class VisitRecordPageBean {
public ArrayList<VisitRecordBean> data;
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#66000000" />
<corners android:radius="10dp" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="0"
/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topRightRadius="0dp"
android:topLeftRadius="0dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:endColor="#00000000"
android:startColor="#55cccccc"
android:angle="90"
/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/blackTransparentColor" />
<corners android:radius="4dp" />
<padding
android:bottom="10dp"
android:left="20dp"
android:right="20dp"
android:top="10dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#AADBFF"
android:endColor="#0998FF"
android:angle="0"
/>
<corners android:radius="50dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#F7F8FA"
android:endColor="#F7F8FA"
android:angle="0"
/>
<corners android:radius="50dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="0"
/>
<corners android:radius="50dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="0"
/>
<corners android:radius="10dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#2D506B"
android:endColor="#2D506B"
android:angle="0"
/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="0dp"
android:topRightRadius="10dp"
android:topLeftRadius="0dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#F7F8FA"
android:endColor="#F7F8FA"
android:angle="0"
/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#ffffff"
android:endColor="#ffffff"
android:angle="0"
/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#ffeef1f7"
android:endColor="#ffeef1f7"
android:angle="0"
/>
<corners
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<solid android:color="@android:color/white" />
<size
android:height="12dp"
android:width="12dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".DetailActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/pageBg">
<include layout="@layout/sub_layout_titlebar"/>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/nameFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="49dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:translationZ="10dp"
android:elevation="1dp"
android:background="@drawable/top_roundrectangle_colorffeef1f7_bg"
android:gravity="center_horizontal">
<TextView
android:id="@+id/name"
android:textColor="#2D506B"
android:textSize="17sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="37dp"
android:layout_marginBottom="6dp"/>
</LinearLayout>
<cn.dankal.base.views.CircleImageView
android:id="@+id/headPic"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="19dp"
android:layout_centerHorizontal="true"
android:background="@mipmap/ic_tou"
android:translationZ="11dp"/>
<RelativeLayout
android:id="@+id/infoFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginBottom="11dp"
android:translationZ="10dp"
android:elevation="1dp"
android:background="@drawable/bottom_roundrectangle_white_bg"
android:layout_below="@id/nameFrame">
<ImageView
android:id="@+id/idPic"
android:layout_width="71dp"
android:layout_height="86dp"
android:src="@mipmap/ic_the"
android:layout_marginTop="19dp"
android:layout_marginLeft="19dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="22dp"
android:scaleType="centerCrop"/>
<LinearLayout
android:id="@+id/titleFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical"
android:layout_alignTop="@id/idPic"
android:layout_alignBottom="@id/idPic"
android:layout_toRightOf="@id/idPic">
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="姓名"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="性别"/>
<TextView
android:id="@+id/idNoTitle"
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentBottom="true"
android:text="身份证"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignTop="@id/idPic"
android:layout_alignBottom="@id/idPic"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:gravity="center_vertical|right">
<TextView
android:id="@+id/realName"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"/>
<TextView
android:id="@+id/gender"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"/>
<TextView
android:id="@+id/idCode"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:visibility="gone"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/takePhotoFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/infoFrame"
android:visibility="visible">
<RelativeLayout
android:id="@+id/idPicBtn"
android:layout_width="wrap_content"
android:layout_height="183dp"
android:background="@drawable/roundrectangle_white_bg"
android:gravity="center"
android:orientation="vertical"
android:layout_below="@id/infoFrame"
android:layout_marginLeft="22dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:translationZ="10dp"
android:elevation="1dp"
android:layout_weight="1">
<LinearLayout
android:id="@+id/addIDPicTipFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_centerHorizontal="true"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="20dp"
android:src="@mipmap/ic_certificate"/>
<TextView
android:textSize="14sp"
android:textColor="#54ACF6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="证件照片"/>
</LinearLayout>
<ImageView
android:id="@+id/idPicture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="9dp"
android:layout_marginBottom="12dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:scaleType="fitCenter"
android:visibility="gone"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/facePicBtn"
android:layout_width="wrap_content"
android:layout_height="183dp"
android:layout_weight="1"
android:background="@drawable/roundrectangle_white_bg"
android:gravity="center"
android:orientation="vertical"
android:layout_marginRight="22dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:translationZ="10dp"
android:layout_marginLeft="15dp"
android:elevation="1dp">
<LinearLayout
android:id="@+id/addFacePicTipFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="40dp"
android:layout_centerHorizontal="true"
android:gravity="center">
<ImageView
android:layout_width="35dp"
android:layout_height="30dp"
android:src="@mipmap/ic_photo"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:text="添加人脸照片"/>
</LinearLayout>
<ImageView
android:id="@+id/facePicture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginBottom="55dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:scaleType="centerCrop"
android:visibility="gone"/>
<TextView
android:id="@+id/uploadFacePicBtn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:textSize="15sp"
android:textColor="#2D506B"
android:layout_alignParentBottom="true"
android:text="重新上传"/>
<TextView
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_above="@id/uploadFacePicBtn"
android:background="@drawable/bottom_to_top_transparent_color"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/idNum"
android:textSize="15sp"
android:textColor="#2D506B"
android:layout_width="match_parent"
android:layout_height="49dp"
android:gravity="center_vertical"
android:background="@drawable/roundrectangle_white_bg"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginBottom="11dp"
android:elevation="1dp"
android:translationZ="5dp"
android:textColorHint="#ABB2B7"
android:paddingLeft="16dp"
android:hint="证件号码:"/>
<TextView
android:textSize="15sp"
android:textColor="#2D506B"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="来访记录(近三条)"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="49dp"
android:background="@drawable/roundrectangle_white_bg"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:translationZ="8dp">
<TextView
android:id="@+id/saveNoteBtn"
android:textSize="17sp"
android:textColor="@color/white"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="33dp"
android:paddingLeft="21dp"
android:paddingRight="21dp"
android:gravity="center"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:text="保存"/>
<EditText
android:id="@+id/noteInput"
android:textSize="14sp"
android:textColor="#2D506B"
android:textColorHint="#ABB2B7"
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_centerVertical="true"
android:background="@drawable/roundrectangle_lightgray_bg"
android:layout_toLeftOf="@id/saveNoteBtn"
android:layout_marginRight="10dp"
android:inputType="text"
android:singleLine="true"
android:lines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:hint="请输入备注"
android:layout_marginLeft="14dp"/>
</RelativeLayout>
<TextView
android:id="@+id/bindBtn"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:translationZ="10dp"
android:elevation="1dp"
android:textColor="@android:color/white"
android:textSize="17sp"
android:gravity="center"
android:textStyle="bold"
android:text="绑定"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"/>
<TextView
android:id="@+id/otherBindBtn"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginBottom="20dp"
android:translationZ="10dp"
android:elevation="1dp"
android:textColor="#2D506B"
android:textSize="17sp"
android:gravity="center"
android:textStyle="bold"
android:text="更新其他证件"
android:background="@drawable/left_right_ring_white_bg"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
<RelativeLayout
android:id="@+id/readSuccessDialogFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_centerInParent="true"
android:background="@drawable/roundrectangle_white_bg">
<RelativeLayout
android:id="@+id/infoFrame1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/idPicInDialog"
android:layout_width="71dp"
android:layout_height="86dp"
android:src="@mipmap/ic_the"
android:layout_marginTop="19dp"
android:layout_marginLeft="19dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="22dp"
android:scaleType="centerCrop"/>
<RelativeLayout
android:id="@+id/titleFrame1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignTop="@id/idPicInDialog"
android:layout_alignBottom="@id/idPicInDialog"
android:layout_toRightOf="@id/idPicInDialog">
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="姓名"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="性别"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentBottom="true"
android:text="身份证"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignTop="@id/idPicInDialog"
android:layout_alignBottom="@id/idPicInDialog"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/nameInDialog"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/genderInDialog"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/idCodeInDialog"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/cancelBtnInDialog"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#2D506B"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/infoFrame1"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_white_bg"
android:text="取消"/>
<TextView
android:id="@+id/bindBtnInDialog"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#ffffff"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/infoFrame1"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"
android:layout_alignParentRight="true"
android:text="绑定"/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/otherBindDialogFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_centerInParent="true"
android:background="@drawable/roundrectangle_white_bg">
<TextView
android:id="@+id/alertTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#2D506B"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:text="提示"/>
<ImageView
android:id="@+id/otherIdPicture"
android:layout_width="194dp"
android:layout_height="139dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:layout_below="@id/alertTitle"
android:src="@mipmap/ic_certificate_in_dialog"/>
<TextView
android:id="@+id/tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/otherIdPicture"
android:text="上传访客证件照片"
android:textColor="#54ACF6"/>
<EditText
android:id="@+id/otherIdInput"
android:layout_width="match_parent"
android:layout_height="33dp"
android:gravity="center_vertical"
android:layout_below="@id/tip"
android:background="@drawable/roundrectangle_lightgray_bg"
android:textColor="#2D506B"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginBottom="17dp"
android:layout_marginTop="20dp"
android:textSize="14sp"
android:hint="证件号码"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:lines="1"
android:singleLine="true"
android:textColorHint="#ABB2B7"/>
<TextView
android:id="@+id/cancelBtn4OtherBind"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#2D506B"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/otherIdInput"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_white_bg"
android:text="取消"/>
<TextView
android:id="@+id/bindBtn4OtherBind"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#ffffff"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/otherIdInput"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"
android:layout_alignParentRight="true"
android:text="绑定"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@color/pageBg"
android:orientation="vertical">
<include layout="@layout/sub_layout_titlebar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 访客布局 -->
<LinearLayout
android:id="@+id/visitorFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="visible">
<ImageView
android:layout_width="91dp"
android:layout_height="107dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_empty"/>
<TextView
android:id="@+id/visitorBtn"
android:layout_width="240dp"
android:layout_height="49dp"
android:layout_marginTop="95dp"
android:textColor="@android:color/white"
android:textSize="17sp"
android:textStyle="bold"
android:gravity="center"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"
android:text="访客"/>
</LinearLayout>
<!-- 搜索布局 -->
<LinearLayout
android:id="@+id/searchPageFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<RelativeLayout
android:id="@+id/searchFrame"
android:layout_width="match_parent"
android:layout_height="52dp"
android:paddingLeft="17dp"
android:paddingRight="21dp"
android:paddingStart="17dp"
android:paddingEnd="21dp"
android:background="@android:color/white">
<TextView
android:id="@+id/searchBtn"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:text="搜索"
android:textSize="15sp"
android:textColor="#28A5FF"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/searchBtn"
android:layout_marginRight="15dp"
android:layout_height="32dp"
android:background="@drawable/left_right_ring_lightgray_bg">
<LinearLayout
android:id="@+id/inputTipFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerInParent="true"
android:orientation="horizontal">
<ImageView
android:layout_width="12dp"
android:layout_height="12dp"
android:src="@mipmap/ic_search"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ABB2B7"
android:textSize="13sp"
android:layout_marginLeft="5dp"
android:text="请输入关键词搜索"/>
</LinearLayout>
<ImageView
android:id="@+id/clearBtn"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="@mipmap/ic_search_delete"
android:visibility="gone"/>
<EditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|left"
android:layout_toLeftOf="@id/clearBtn"
android:layout_marginRight="10dp"
android:layout_marginLeft="15dp"
android:textSize="13dp"
android:singleLine="true"
android:imeOptions="actionSearch"
android:textColor="#2D506B"
android:background="@null"/>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/tip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ABB2B7"
android:textSize="14dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:text="输入姓名、手机号或者读取身份证进行搜索"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/base_loading_circle_background"
android:padding="20dp" >
<!--<ImageView
android:id="@+id/circle_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription=""
android:scaleType="fitXY" />-->
<ProgressBar
android:id="@+id/loadProgressBar"
android:layout_width="20dp"
android:layout_height="20dp"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/circle_trans_black_bg"
android:gravity="center_vertical">
<TextView
android:id="@+id/msg"
style="@style/colorffffffdp14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/left_right_roundrectangle_white_bg"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="14dp"
android:translationZ="20dp">
<TextView
android:id="@+id/tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:textColor="#FFFFFF"
android:text="访\n客"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="@drawable/left_ring_blue_bg"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/nameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tag"
android:layout_marginLeft="13dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginTop="12dp"
android:text="姓名"
/>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginTop="12dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:text="xxxxxx"/>
<TextView
android:id="@+id/staffNameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tag"
android:layout_marginLeft="13dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="邀请人"
android:layout_below="@id/nameTitle"
/>
<TextView
android:id="@+id/staffName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="15dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_below="@id/name"
android:text="xxxxxx"/>
<TextView
android:id="@+id/mobileTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tag"
android:layout_marginLeft="13dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginBottom="8dp"
android:text="手机号码"
android:layout_below="@id/staffNameTitle"
/>
<TextView
android:id="@+id/mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="8dp"
android:layout_marginRight="15dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_below="@id/staffName"
android:text="xxxxxx"/>
<TextView
android:id="@+id/comTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tag"
android:layout_marginLeft="13dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginBottom="12dp"
android:layout_below="@id/mobileTitle"
android:text="拜访企业"
/>
<TextView
android:id="@+id/company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginBottom="12dp"
android:textSize="14sp"
android:layout_below="@id/mobile"
android:textColor="#2D506B"
android:text="xxxxxx"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/left_right_roundrectangle_white_bg"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="10dp"
android:translationZ="8dp">
<TextView
android:id="@+id/nameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginTop="30dp"
android:text="到访企业"
/>
<TextView
android:id="@+id/companyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:text="xxxxxx"/>
<TextView
android:id="@+id/invatePersonTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="邀请人"
android:layout_below="@id/nameTitle"
/>
<TextView
android:id="@+id/invatePerson"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="30dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_below="@id/companyName"
android:text="xxxxxx"/>
<TextView
android:id="@+id/mobileTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginBottom="8dp"
android:text="手机号码"
android:layout_below="@id/invatePersonTitle"
/>
<TextView
android:id="@+id/mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="8dp"
android:layout_marginRight="30dp"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_below="@id/invatePerson"
android:text="xxxxxx"/>
<TextView
android:id="@+id/comTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:textColor="#ABB2B7"
android:textSize="14sp"
android:layout_marginBottom="30dp"
android:layout_below="@id/mobileTitle"
android:text="到访时间"
/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginBottom="30dp"
android:textSize="14sp"
android:layout_below="@id/mobile"
android:textColor="#2D506B"
android:text="xxxxxx"/>
</RelativeLayout>
<TextView
android:id="@+id/topDot1"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="13dp"
android:layout_marginLeft="70dp"
android:background="@drawable/white_dot"
android:translationZ="10dp"/>
<TextView
android:id="@+id/topLine1"
android:layout_width="2dp"
android:layout_height="18dp"
android:layout_marginLeft="75dp"
android:background="#D8D8D8"
android:translationZ="9dp"/>
<TextView
android:id="@+id/topDot2"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="13dp"
android:layout_marginRight="70dp"
android:layout_alignParentRight="true"
android:background="@drawable/white_dot"
android:translationZ="10dp"/>
<TextView
android:id="@+id/topLine2"
android:layout_width="2dp"
android:layout_height="18dp"
android:layout_marginRight="75dp"
android:layout_alignParentRight="true"
android:background="#D8D8D8"
android:translationZ="9dp"/>
<TextView
android:id="@+id/bottomDot1"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginLeft="70dp"
android:layout_alignBottom="@id/mainFrame"
android:background="@drawable/white_dot"
android:layout_marginBottom="3dp"
android:translationZ="10dp"/>
<TextView
android:id="@+id/bottomLine1"
android:layout_width="2dp"
android:layout_height="18dp"
android:layout_marginLeft="75dp"
android:layout_below="@id/bottomDot1"
android:layout_marginTop="-3dp"
android:background="#D8D8D8"
android:translationZ="9dp"/>
<TextView
android:id="@+id/bottomDot2"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginRight="70dp"
android:layout_alignParentRight="true"
android:layout_alignBottom="@id/mainFrame"
android:background="@drawable/white_dot"
android:layout_marginBottom="3dp"
android:translationZ="10dp"/>
<TextView
android:id="@+id/bottomLine2"
android:layout_width="2dp"
android:layout_height="18dp"
android:layout_marginRight="75dp"
android:layout_below="@id/bottomDot2"
android:layout_alignParentRight="true"
android:layout_marginTop="-3dp"
android:background="#D8D8D8"
android:translationZ="9dp"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/roundrectangle_white_bg"
android:padding="20dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="18sp"
android:textColor="#2D506B"
android:text="提示"/>
<TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/title"
android:layout_marginTop="28dp"
android:textSize="16sp"
android:textColor="#2D506B"
android:text="请读取身份证"/>
<TextView
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="48dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="21dp"
android:gravity="center"
android:textSize="17sp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:translationZ="5dp"
android:layout_below="@id/msg"
android:text="确定"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/roundrectangle_white_bg">
<RelativeLayout
android:id="@+id/infoFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/idPic"
android:layout_width="71dp"
android:layout_height="86dp"
android:src="@mipmap/ic_the"
android:layout_marginTop="19dp"
android:layout_marginLeft="19dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="22dp"
android:scaleType="centerCrop"/>
<RelativeLayout
android:id="@+id/titleFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignTop="@id/idPic"
android:layout_alignBottom="@id/idPic"
android:layout_toRightOf="@id/idPic">
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="姓名"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="性别"/>
<TextView
android:textSize="14sp"
android:textColor="#ABB2B7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentBottom="true"
android:text="身份证"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignTop="@id/idPic"
android:layout_alignBottom="@id/idPic"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp">
<TextView
android:id="@+id/name"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/gender"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/idCode"
android:textSize="14sp"
android:textColor="#2D506B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/cancelBtn"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#2D506B"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/infoFrame"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_white_bg"
android:text="取消"/>
<TextView
android:id="@+id/bindBtn"
android:layout_width="130dp"
android:layout_height="39dp"
android:textColor="#ffffff"
android:textSize="17sp"
android:gravity="center"
android:layout_below="@id/infoFrame"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="27dp"
android:translationZ="5dp"
android:background="@drawable/left_right_ring_lightblue_to_blue_bg"
android:layout_alignParentRight="true"
android:text="绑定"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="48dp"
tools:context=".MainActivity"
android:background="@android:color/white">
<TextView
android:id="@+id/titleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="XX"
android:textSize="18sp"
android:textColor="#000000"
android:textStyle="bold"/>
<ImageView
android:id="@+id/backBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp"
android:layout_centerVertical="true"
android:src="@mipmap/ic_return"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#E0E0E0"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CircleImageView">
<attr name="civ_border_width" format="dimension" />
<attr name="civ_border_color" format="color" />
<attr name="civ_border_overlay" format="boolean" />
<attr name="civ_fill_color" format="color" />
</declare-styleable>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#eeeeee</color>
<color name="colorAccent">#666666</color>
<color name="blackTransparentColor">#88000000</color>
<color name="baseTransparentColor">#00000000</color>
<color name="pageBg">#fff7f8fa</color>
</resources>
<resources>
<string name="app_name">MCTower</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#666666</item>
</style>
<style name="Theme.MyAppCompatTheme" parent="@style/AppTheme">
<item name="android:screenOrientation">portrait</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:fitsSystemWindows">true</item>
</style>
<!-- 加载网络数据时loading框的Style -->
<style name="basedDialogStyle" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/baseTransparentColor</item>
</style>
<style name="colorffffffdp14">
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">14sp</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
package cn.mctower.visitor;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://dl.bintray.com/umsdk/release' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.useDeprecatedNdk=true
#Mon Jul 20 11:14:47 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
rootProject.name='MCTower'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment