Commit d0413a515c85ccefceda99065fcc960c96980db6
1 parent
e3d87fb5
1 集成网家家base
Showing
57 changed files
with
4528 additions
and
3 deletions
Too many changes to show.
To preserve performance only 57 of 115 files are displayed.
.idea/gradle.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project version="4"> | 2 | <project version="4"> |
| 3 | + <component name="GradleMigrationSettings" migrationVersion="1" /> | ||
| 3 | <component name="GradleSettings"> | 4 | <component name="GradleSettings"> |
| 4 | <option name="linkedExternalProjectsSettings"> | 5 | <option name="linkedExternalProjectsSettings"> |
| 5 | <GradleProjectSettings> | 6 | <GradleProjectSettings> |
| 7 | + <option name="delegatedBuild" value="true" /> | ||
| 8 | + <option name="testRunner" value="PLATFORM" /> | ||
| 6 | <option name="distributionType" value="DEFAULT_WRAPPED" /> | 9 | <option name="distributionType" value="DEFAULT_WRAPPED" /> |
| 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | 10 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
| 8 | <option name="modules"> | 11 | <option name="modules"> |
| @@ -16,6 +19,7 @@ | @@ -16,6 +19,7 @@ | ||
| 16 | <option value="$PROJECT_DIR$/cloud/third_tool" /> | 19 | <option value="$PROJECT_DIR$/cloud/third_tool" /> |
| 17 | <option value="$PROJECT_DIR$/cloud/user" /> | 20 | <option value="$PROJECT_DIR$/cloud/user" /> |
| 18 | <option value="$PROJECT_DIR$/cloud/video" /> | 21 | <option value="$PROJECT_DIR$/cloud/video" /> |
| 22 | + <option value="$PROJECT_DIR$/cloud/wjj_lib" /> | ||
| 19 | <option value="$PROJECT_DIR$/core" /> | 23 | <option value="$PROJECT_DIR$/core" /> |
| 20 | <option value="$PROJECT_DIR$/core/app_qr" /> | 24 | <option value="$PROJECT_DIR$/core/app_qr" /> |
| 21 | <option value="$PROJECT_DIR$/core/base" /> | 25 | <option value="$PROJECT_DIR$/core/base" /> |
| @@ -31,7 +35,6 @@ | @@ -31,7 +35,6 @@ | ||
| 31 | </set> | 35 | </set> |
| 32 | </option> | 36 | </option> |
| 33 | <option name="resolveModulePerSourceSet" value="false" /> | 37 | <option name="resolveModulePerSourceSet" value="false" /> |
| 34 | - <option name="testRunner" value="PLATFORM" /> | ||
| 35 | </GradleProjectSettings> | 38 | </GradleProjectSettings> |
| 36 | </option> | 39 | </option> |
| 37 | </component> | 40 | </component> |
app/strike/build.gradle
| @@ -186,4 +186,6 @@ dependencies { | @@ -186,4 +186,6 @@ dependencies { | ||
| 186 | // implementation project(path: ':core:util') | 186 | // implementation project(path: ':core:util') |
| 187 | // implementation project(path: ':core:encipher') | 187 | // implementation project(path: ':core:encipher') |
| 188 | // implementation project(path: ':cloud:user') | 188 | // implementation project(path: ':cloud:user') |
| 189 | + implementation project(path: ':cloud:wjj_lib') | ||
| 190 | + | ||
| 189 | } | 191 | } |
build.gradle
| @@ -37,8 +37,8 @@ allprojects { | @@ -37,8 +37,8 @@ allprojects { | ||
| 37 | if (project.parent == null || project.parent == rootProject) return | 37 | if (project.parent == null || project.parent == rootProject) return |
| 38 | 38 | ||
| 39 | android { | 39 | android { |
| 40 | - compileSdkVersion 29 | ||
| 41 | - buildToolsVersion "29.0.0" | 40 | + compileSdkVersion rootProject.ext.compileSdkVersion |
| 41 | + buildToolsVersion rootProject.ext.buildToolsVersion | ||
| 42 | // defaultConfig 闭包:默认配置、应用程序包名、最小sdk版本、目标sdk版本、版本号、版本名称; | 42 | // defaultConfig 闭包:默认配置、应用程序包名、最小sdk版本、目标sdk版本、版本号、版本名称; |
| 43 | defaultConfig { | 43 | defaultConfig { |
| 44 | if (minSdkVersion == null) minSdkVersion 21 | 44 | if (minSdkVersion == null) minSdkVersion 21 |
| @@ -172,6 +172,7 @@ task clean(type: Delete) { | @@ -172,6 +172,7 @@ task clean(type: Delete) { | ||
| 172 | 172 | ||
| 173 | //配置全局变量 | 173 | //配置全局变量 |
| 174 | ext { | 174 | ext { |
| 175 | + buildToolsVersion = '29.0.0' | ||
| 175 | compileSdkVersion = 29 | 176 | compileSdkVersion = 29 |
| 176 | libMediaPicker = '1.6.0' | 177 | libMediaPicker = '1.6.0' |
| 177 | // loading动画 | 178 | // loading动画 |
cloud/wjj_lib/.gitignore
0 → 100644
| 1 | +/build |
cloud/wjj_lib/build.gradle
0 → 100644
| 1 | +apply plugin: 'com.android.library' | ||
| 2 | +//apply from: './maven_push.gradle' | ||
| 3 | + | ||
| 4 | +android { | ||
| 5 | +// compileSdkVersion rootProject.ext.compileSdkVersion | ||
| 6 | +// buildToolsVersion rootProject.ext.buildToolsVersion | ||
| 7 | + | ||
| 8 | + defaultConfig { | ||
| 9 | +// minSdkVersion rootProject.ext.minSdkVersion | ||
| 10 | +// targetSdkVersion rootProject.ext.targetSdkVersion | ||
| 11 | +// versionCode rootProject.ext.versionCode | ||
| 12 | +// versionName rootProject.ext.versionName | ||
| 13 | + | ||
| 14 | + javaCompileOptions { | ||
| 15 | + annotationProcessorOptions { | ||
| 16 | + arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"] | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + //添加java编译指令,防止引用时,形参变成var1 | ||
| 22 | + gradle.projectsEvaluated { | ||
| 23 | + tasks.withType(JavaCompile) { | ||
| 24 | + options.compilerArgs.add('-parameters') | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + compileOptions { | ||
| 28 | + sourceCompatibility JavaVersion.VERSION_1_8 | ||
| 29 | + targetCompatibility JavaVersion.VERSION_1_8 | ||
| 30 | + } | ||
| 31 | + buildTypes { | ||
| 32 | + debug { | ||
| 33 | + resValue("string", "ACCOUNT_LABEL", "网家家 内测") | ||
| 34 | + resValue("string", "ACCOUNT_TYPE", "com.cnlive.strike.debug.AccountType") | ||
| 35 | + resValue("string", "ACCOUNT_PROVIDE", "com.cnlive.strike.debug.AccountProvide") | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + release { | ||
| 39 | + resValue("string", "ACCOUNT_LABEL", "网家家") | ||
| 40 | + resValue("string", "ACCOUNT_TYPE", "com.cnlive.strike.AccountType") | ||
| 41 | + resValue("string", "ACCOUNT_PROVIDE", "com.cnlive.strike.AccountProvide") | ||
| 42 | + minifyEnabled false | ||
| 43 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + dataBinding { | ||
| 47 | + enabled true | ||
| 48 | + } | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +dependencies { | ||
| 52 | + implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
| 53 | +// implementation "com.android.support:support-v4:$rootProject.supportV4" | ||
| 54 | +// implementation "com.android.support:appcompat-v7:$rootProject.appcompatV7" | ||
| 55 | +// implementation "com.android.support:design:$rootProject.design" | ||
| 56 | +// implementation "com.android.support:support-v13:$rootProject.supportV13" | ||
| 57 | +// implementation "com.android.support:recyclerview-v7:$rootProject.recyclerviewV7" | ||
| 58 | +// implementation "com.android.support:cardview-v7:$rootProject.cardviewV7" | ||
| 59 | + //MVP | ||
| 60 | + | ||
| 61 | + //Java8 | ||
| 62 | + implementation 'net.sourceforge.streamsupport:streamsupport:1.5.5' | ||
| 63 | + implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.5.5' | ||
| 64 | + implementation 'net.sourceforge.streamsupport:streamsupport-atomic:1.5.5' | ||
| 65 | + implementation 'net.sourceforge.streamsupport:streamsupport-flow:1.5.5' | ||
| 66 | + implementation 'net.sourceforge.streamsupport:streamsupport-literal:1.5.5' | ||
| 67 | +// //GSON | ||
| 68 | +// implementation "com.google.code.gson:gson:$rootProject.gson" | ||
| 69 | +// //RxJava | ||
| 70 | +// implementation 'io.reactivex.rxjava2:rxjava:2.1.8' | ||
| 71 | +// implementation('io.reactivex.rxjava2:rxandroid:2.0.1') { | ||
| 72 | +// exclude module: 'rxjava'// rxJava | ||
| 73 | +// } | ||
| 74 | +// //EventBus | ||
| 75 | +// implementation "org.greenrobot:eventbus:$rootProject.eventbus" | ||
| 76 | + implementation('com.github.pwittchen:reactivenetwork-rx2:3.0.6') { | ||
| 77 | + exclude module: "rxjava" | ||
| 78 | + } | ||
| 79 | +// //CNLive Encipher | ||
| 80 | +// implementation "com.cnlive:lib-cnencipher:$rootProject.libCnencipher" | ||
| 81 | + implementation "com.cnlive:lib_cnutil:$rootProject.libCnUtil" | ||
| 82 | +// //鲁班 暂时以源码形式引用,因为超大尺寸图片像素无法压缩 | ||
| 83 | +// //implementation 'top.zibin:Luban:1.1.8' | ||
| 84 | +// implementation "com.qmuiteam:qmui:$rootProject.qmui" | ||
| 85 | +// // compile 'top.zibin:Luban-turbo:1.0.0' | ||
| 86 | +// implementation 'com.github.GrenderG:Toasty:1.4.2' | ||
| 87 | +// | ||
| 88 | +// //ARouter | ||
| 89 | +// implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion" | ||
| 90 | +// annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion" | ||
| 91 | +// | ||
| 92 | +// api "com.cnlive.libs:network:$rootProject.libNetwork" | ||
| 93 | +// api files('libs/pinyin4j-2.5.0.jar') | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +//ext { | ||
| 97 | +// bintrayRepo = 'cnliveLibs' //Maven 库名称 | ||
| 98 | +// bintrayName = 'lib-appbase' //Maven 库内Lib包名 | ||
| 99 | +// | ||
| 100 | +// publishedGroupId = 'com.cnlive' | ||
| 101 | +// libraryName = 'base' | ||
| 102 | +// artifact = 'lib_base' //与包名保持一致! | ||
| 103 | +// | ||
| 104 | +// libraryDescription = 'for app libs' | ||
| 105 | +// | ||
| 106 | +// siteUrl = 'http://bj.gitlab.cnlive.com/cnlive-team/CNLiveSDK' | ||
| 107 | +// gitUrl = 'http://bj.gitlab.cnlive.com/cnlive-team/CNLiveSDK.git' | ||
| 108 | +// | ||
| 109 | +// libraryVersion = '1.1.3' | ||
| 110 | +// | ||
| 111 | +// developerId = 'CNlive' | ||
| 112 | +// developerName = 'Granzon' | ||
| 113 | +// developerEmail = 'zhuxiansong@cnlive.com' | ||
| 114 | +// | ||
| 115 | +// licenseName = 'The Apache Software License, Version 2.0' | ||
| 116 | +// licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
| 117 | +// allLicenses = ["Apache-2.0"] | ||
| 118 | +//} | ||
| 119 | +// | ||
| 120 | +//apply from: './from_installv1.gradle' | ||
| 121 | +//apply from: './from_bintrayv1.gradle' | ||
| 122 | + | ||
| 123 | +//ext { | ||
| 124 | +// PUBLISH_GROUP_ID = 'libcnlive' | ||
| 125 | +// PUBLISH_ARTIFACT_ID = 'base' | ||
| 126 | +// PUBLISH_VERSION = android.defaultConfig.versionName | ||
| 127 | +//} | ||
| 128 | +// | ||
| 129 | +//task makeBaseJar(type: Copy) { | ||
| 130 | +// def outJarVersion = project.PUBLISH_GROUP_ID +project.PUBLISH_ARTIFACT_ID + ".jar" | ||
| 131 | +// from('build/intermediates/bundles/release/') | ||
| 132 | +// into('build/libs/') | ||
| 133 | +// include('classes.jar') | ||
| 134 | +// rename('classes.jar', outJarVersion) | ||
| 135 | +//} | ||
| 136 | +// | ||
| 137 | +//makeBaseJar.dependsOn(build) |
cloud/wjj_lib/proguard-rules.pro
0 → 100644
| 1 | +# 通用混淆配置 | ||
| 2 | +#不混淆泛型 -keepattributes SourceFile | ||
| 3 | + -keepattributes Signature,InnerClasses,Exceptions,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod | ||
| 4 | + | ||
| 5 | + -optimizationpasses 5 | ||
| 6 | + -dontusemixedcaseclassnames | ||
| 7 | + -dontskipnonpubliclibraryclasses | ||
| 8 | + -dontpreverify | ||
| 9 | + -verbose | ||
| 10 | + -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
| 11 | + | ||
| 12 | + #忽略警告 也可以用-ignorewarnings | ||
| 13 | + -ignorewarnings | ||
| 14 | + -dontwarn | ||
| 15 | + | ||
| 16 | + -keep public class * extends android.app.Activity | ||
| 17 | + -keep public class * extends android.support.v4.app.Fragment | ||
| 18 | + -keep public class * extends android.app.Application | ||
| 19 | + -keep public class * extends android.app.Service | ||
| 20 | + -keep public class * extends android.content.BroadcastReceiver | ||
| 21 | + -keep public class * extends android.content.ContentProvider | ||
| 22 | + -keep public class * extends android.app.backup.BackupAgentHelper | ||
| 23 | + -keep public class * extends android.preference.Preference | ||
| 24 | + -keep public class com.android.vending.licensing.ILicensingService | ||
| 25 | + | ||
| 26 | + -keepclasseswithmembernames class * { | ||
| 27 | + native <methods>; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + -keepclasseswithmembers class * { | ||
| 31 | + public <init>(android.content.Context, android.util.AttributeSet); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + -keepclasseswithmembers class * { | ||
| 35 | + public <init>(android.content.Context, android.util.AttributeSet, int); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + -keepclassmembers class * extends android.app.Activity { | ||
| 39 | + public void *(android.view.View); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + -keepclassmembers enum * { | ||
| 43 | + public static **[] values(); | ||
| 44 | + public static ** valueOf(java.lang.String); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + -keep class * implements android.os.Parcelable { | ||
| 48 | + public static final android.os.Parcelable$Creator *; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | +-keepclassmembers class **.R$* { | ||
| 52 | + public static <fields>; | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +# 通用混淆配置 End | ||
| 56 | + | ||
| 57 | +#统计SDK | ||
| 58 | +-keep class com.cnlive.libs.base.analytics.CNLiveProbe {*;} | ||
| 59 | +#应用配置信息 | ||
| 60 | +-keep class com.cnlive.libs.base.application.AppConfig {*;} | ||
| 61 | +#基础框架 | ||
| 62 | +-keep class com.cnlive.libs.base.frame.** {*;} | ||
| 63 | +-keep class com.cnlive.libs.base.logic.** {*;} | ||
| 64 | +-keep class com.cnlive.libs.base.recevier.** {*;} | ||
| 65 | +-keep class com.cnlive.libs.base.util.** {*;} | ||
| 66 | + | ||
| 67 | +# If single-type injection is used, that is, no interface is defined to implement IProvider, the following rules need to be added to protect the implementation | ||
| 68 | +-keep class * implements com.alibaba.android.arouter.facade.template.IProvider | ||
| 69 | +# # If you use the byType method to obtain Service, add the following rules to protect the interface: | ||
| 70 | +-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider | ||
| 71 | +-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;} | ||
| 72 | + | ||
| 73 | +-keep interface com.cnlive.libs.base.arouter.user.CNLiveUserService{*;} | ||
| 74 | +-keep interface com.cnlive.libs.base.arouter.pay.CNLivePayService{*;} | ||
| 75 | +-keep interface com.cnlive.libs.base.arouter.share.CNLiveShareService{*;} | ||
| 76 | + | ||
| 77 | + |
cloud/wjj_lib/src/main/AndroidManifest.xml
0 → 100644
| 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + package="com.cnlive.libs.base" > | ||
| 3 | + | ||
| 4 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| 5 | + <uses-permission | ||
| 6 | + android:name="android.permission.AUTHENTICATE_ACCOUNTS" | ||
| 7 | + android:maxSdkVersion="22" /> | ||
| 8 | + <uses-permission | ||
| 9 | + android:name="android.permission.GET_ACCOUNTS" | ||
| 10 | + android:maxSdkVersion="22" /> | ||
| 11 | + <uses-permission | ||
| 12 | + android:name="android.permission.MANAGE_ACCOUNTS" | ||
| 13 | + android:maxSdkVersion="22" /> | ||
| 14 | + <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> | ||
| 15 | +</manifest> |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/application/AppConfig.java
0 → 100644
| 1 | +package com.cnlive.libs.base.application; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.cnlive.libs.base.util.AppUtil; | ||
| 6 | +import com.cnlive.libs.base.util.ChannelUtil; | ||
| 7 | +import com.cnlive.libs.base.util.UUIDUtils; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Created by xiansong on 2018/4/24. | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +public class AppConfig { | ||
| 14 | + private static String APP_ID = ""; | ||
| 15 | + private static String APP_KEY = ""; | ||
| 16 | + private static String APP_SCERET = ""; | ||
| 17 | + private static String APP_UUID = ""; | ||
| 18 | + private static String APP_PACKEG = ""; | ||
| 19 | + private static String APP_VERSION = ""; | ||
| 20 | + private static String APP_CHANNEL = ""; | ||
| 21 | + private static String PROMO_FROM = ""; | ||
| 22 | + private static int APP_SPECIAL_GROUP_MEMBER_LIMIT = 10; | ||
| 23 | + private static String BAIDU_APP_KEY = ""; | ||
| 24 | + private static String BAIDU_APP_SECRET = ""; | ||
| 25 | + private static String SID = ""; | ||
| 26 | + private static String WECHAT_APPID = ""; | ||
| 27 | + private static String PAY_ACCOUNT = ""; | ||
| 28 | + private static float FONT_SCALE = 1.0f; | ||
| 29 | + | ||
| 30 | + private static boolean VERSION_AS_DEBUG = true; | ||
| 31 | + private static String SHARE_DOWNLOAD = "http://apiwjj.cnlive.com/download/index.html"; | ||
| 32 | + private static String SHARE_ICON = "http://wjjh5.cnlive.com/static/logo.png"; | ||
| 33 | + private static String SHARE_LINK = "http://wjjh5.cnlive.com/static/tab_link.png"; | ||
| 34 | + private static String SHOP_PATH = "wjjshop.cnlive.com"; | ||
| 35 | + private static String SHARE_TITLE = "快来加入中国网家家,优享美好生活!"; | ||
| 36 | + private static String SHARE_SUBTITLE = "中国网家家 让生活更美好!"; | ||
| 37 | + private static String USER_PHONE = ""; | ||
| 38 | + private static String COUNTRY_CODE = ""; | ||
| 39 | + | ||
| 40 | + private static String COUNTRY_NAME = ""; | ||
| 41 | + private static String VERIFICATION_CODE = ""; | ||
| 42 | + private static String REPORT_URL = ""; | ||
| 43 | + private static boolean IS_TRTC_TALKING = false;//是否在进行音视频通话 | ||
| 44 | + private static String BAIDU_MAP_APP_KEY = "";//百度地图key | ||
| 45 | + | ||
| 46 | + | ||
| 47 | + public static void init(Context context, String id, String key, String sceret, | ||
| 48 | + int special_group_member_limit, boolean debug, String baidu_app_key, | ||
| 49 | + String baidu_app_secret, String loginSid, String wechatAppId, | ||
| 50 | + String shareDownload, String shareIcon, String pay_account, | ||
| 51 | + String shareTitle, String shareSubTitle, String reportUrl, | ||
| 52 | + String baidu_map_app_key, String shopPath) { | ||
| 53 | + APP_UUID = UUIDUtils.getUUID(context); | ||
| 54 | + APP_PACKEG = context.getPackageName(); | ||
| 55 | + APP_VERSION = AppUtil.getVersionName(context); | ||
| 56 | + APP_CHANNEL = ChannelUtil.getChannelFromApk(context); | ||
| 57 | + APP_SPECIAL_GROUP_MEMBER_LIMIT = special_group_member_limit; | ||
| 58 | + APP_ID = id; | ||
| 59 | + APP_KEY = key; | ||
| 60 | + APP_SCERET = sceret; | ||
| 61 | + VERSION_AS_DEBUG = debug; | ||
| 62 | + BAIDU_APP_KEY = baidu_app_key; | ||
| 63 | + BAIDU_APP_SECRET = baidu_app_secret; | ||
| 64 | + SID = loginSid; | ||
| 65 | + WECHAT_APPID = wechatAppId; | ||
| 66 | + SHARE_DOWNLOAD = shareDownload; | ||
| 67 | + SHARE_ICON = shareIcon; | ||
| 68 | + PAY_ACCOUNT = pay_account; | ||
| 69 | + SHARE_TITLE = shareTitle; | ||
| 70 | + SHARE_SUBTITLE = shareSubTitle; | ||
| 71 | + REPORT_URL = reportUrl; | ||
| 72 | + BAIDU_MAP_APP_KEY = baidu_map_app_key; | ||
| 73 | + SHOP_PATH = shopPath; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public static String getBaiduMapAppKey() { | ||
| 77 | + return BAIDU_MAP_APP_KEY; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public static void setBaiduMapAppKey(String baiduMapAppKey) { | ||
| 81 | + BAIDU_MAP_APP_KEY = baiduMapAppKey; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public static String getAppUUID() { | ||
| 85 | + return APP_UUID; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public static String getAppPackeg() { | ||
| 89 | + return APP_PACKEG; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public static String getAppVersion() { | ||
| 93 | + return APP_VERSION; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public static String getAppId() { | ||
| 97 | + return APP_ID; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public static String getAppKey() { | ||
| 101 | + return APP_KEY; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public static String getAppSceret() { | ||
| 105 | + return APP_SCERET; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public static String getAppChannel() { | ||
| 109 | + return APP_CHANNEL; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public static void setAppChannel(String channel) { | ||
| 113 | + APP_CHANNEL = channel == null ? "" : channel; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public static boolean isDebug() { | ||
| 117 | + return VERSION_AS_DEBUG; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public static int getAppSpecialGroupMemberLimit() { | ||
| 121 | + return APP_SPECIAL_GROUP_MEMBER_LIMIT; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public static String getPromoFrom() { | ||
| 125 | + return PROMO_FROM; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public static void setPromoFrom(String promoFrom) { | ||
| 129 | + PROMO_FROM = promoFrom; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public static String getBaiduAppKey() { | ||
| 133 | + return BAIDU_APP_KEY; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public static String getBaiduAppSecret() { | ||
| 137 | + return BAIDU_APP_SECRET; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public static void setAppSpecialGroupMemberLimit(int appSpecialGroupMemberLimit) { | ||
| 141 | + APP_SPECIAL_GROUP_MEMBER_LIMIT = appSpecialGroupMemberLimit; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public static String getSid() { | ||
| 145 | + return SID; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public static void setSid(String sid) { | ||
| 149 | + SID = sid; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public static String getWechatAppid() { | ||
| 153 | + return WECHAT_APPID; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public static float getFontScale() { | ||
| 157 | + return FONT_SCALE; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public static void setFontScale(float fontScale) { | ||
| 161 | + FONT_SCALE = fontScale; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public static String getShareDownload() { | ||
| 165 | + return SHARE_DOWNLOAD; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public static String getShareIcon() { | ||
| 169 | + return SHARE_ICON; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + public static String getShareLink() { | ||
| 173 | + return SHARE_LINK; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + public static String getPayAccount() { | ||
| 177 | + return PAY_ACCOUNT; | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + public static void setPayAccount(String payAccount) { | ||
| 181 | + PAY_ACCOUNT = payAccount; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + public static void setShareDownload(String shareDownload) { | ||
| 185 | + SHARE_DOWNLOAD = shareDownload; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public static void setShareIcon(String shareIcon) { | ||
| 189 | + SHARE_ICON = shareIcon; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public static String getShareTitle() { | ||
| 193 | + return SHARE_TITLE; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public static void setShareTitle(String shareTitle) { | ||
| 197 | + SHARE_TITLE = shareTitle; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + public static String getShareSubtitle() { | ||
| 201 | + return SHARE_SUBTITLE; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + public static void setShareSubtitle(String shareSubtitle) { | ||
| 205 | + SHARE_SUBTITLE = shareSubtitle; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + public static String getUserPhone() { | ||
| 209 | + return USER_PHONE; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + public static void setUserPhone(String userPhone) { | ||
| 213 | + USER_PHONE = userPhone; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + | ||
| 217 | + public static String getCountryCode() { | ||
| 218 | + return COUNTRY_CODE; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + public static void setCountryCode(String countryCode) { | ||
| 222 | + COUNTRY_CODE = countryCode; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + public static String getVerificationCode() { | ||
| 226 | + return VERIFICATION_CODE; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + public static void setVerificationCode(String verificationCode) { | ||
| 230 | + VERIFICATION_CODE = verificationCode; | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + public static void setReportUrl(String reportUrl) { | ||
| 234 | + REPORT_URL = reportUrl; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + public static String getReportUrl() { | ||
| 238 | + return REPORT_URL; | ||
| 239 | + } | ||
| 240 | + | ||
| 241 | + public static boolean isIsTrtcTalking() { | ||
| 242 | + return IS_TRTC_TALKING; | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + public static void setIsTrtcTalking(boolean isTrtcTalking) { | ||
| 246 | + IS_TRTC_TALKING = isTrtcTalking; | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + public static String getCountryName() { | ||
| 250 | + return COUNTRY_NAME; | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + public static void setCountryName(String countryName) { | ||
| 254 | + COUNTRY_NAME = countryName; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + public static String getShopPath() { | ||
| 258 | + return SHOP_PATH; | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + public static void setShopPath(String shopPath) { | ||
| 262 | + SHOP_PATH = shopPath; | ||
| 263 | + } | ||
| 264 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/IJumpToView.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.Uri; | ||
| 5 | + | ||
| 6 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 7 | + | ||
| 8 | +public interface IJumpToView extends IProvider { | ||
| 9 | + public static final String PATH_JUMP_TO_VIEW = "/cnStrike/cnJumpToViewService"; | ||
| 10 | + | ||
| 11 | + void jumpToView(Context context, String url); | ||
| 12 | + | ||
| 13 | + void jumpToView(Context context, Uri uri); | ||
| 14 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/IUpdateBtnStatus.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter; | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 4 | + | ||
| 5 | +public interface IUpdateBtnStatus extends IProvider { | ||
| 6 | + public static final String PATH_UPDATE_BTN_STATUS = "/cnStrike/cnUpdateBtnStatusService"; | ||
| 7 | + | ||
| 8 | + void changeCommentStatus(String pid, boolean selected, String model); | ||
| 9 | + | ||
| 10 | + void changeLikeStatus(String pid, boolean selected, String model); | ||
| 11 | + | ||
| 12 | + void changeCollectStatus(String pid, boolean selected, String model); | ||
| 13 | + | ||
| 14 | + void changeWitnessGraphicFocus(String spId, boolean focused); | ||
| 15 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/QrService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter; | ||
| 2 | + | ||
| 3 | +import android.graphics.Bitmap; | ||
| 4 | + | ||
| 5 | +import androidx.annotation.Nullable; | ||
| 6 | + | ||
| 7 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 作者: 吴奎庆 | ||
| 11 | + * <p> | ||
| 12 | + * 时间: 2019/6/18 | ||
| 13 | + * <p> | ||
| 14 | + * 简介: 生成二维码调用的服务 | ||
| 15 | + */ | ||
| 16 | +public interface QrService extends IProvider { | ||
| 17 | + String PATH = "/app/qrservice"; | ||
| 18 | + String NAME = "app_qrservice"; | ||
| 19 | + String GROUP = "appqr"; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 生成二维码的逻辑(带图标) | ||
| 23 | + * | ||
| 24 | + * @param content | ||
| 25 | + * @param size 宽高 | ||
| 26 | + * @param logoBitmap 图标的bitmap | ||
| 27 | + * @param logoPercent 百分比 | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + Bitmap createQrIconBitMap(String content, int size, @Nullable Bitmap logoBitmap, float logoPercent); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 生成不带图标的二维码 | ||
| 34 | + * | ||
| 35 | + * @param content 内容 | ||
| 36 | + * @param size 二维码大小 单位px | ||
| 37 | + * @return | ||
| 38 | + */ | ||
| 39 | + Bitmap createQRNoIconBitmap(@Nullable String content, int size); | ||
| 40 | + | ||
| 41 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/ar/CNLiveArService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.ar; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 6 | + | ||
| 7 | +public interface CNLiveArService extends IProvider { | ||
| 8 | + static final String PATH = "/openService/CNLiveArService"; | ||
| 9 | + static final String NAME = "开放AR识别的服务接口"; | ||
| 10 | + | ||
| 11 | + /**跳转到AR识别页面 | ||
| 12 | + * @param context | ||
| 13 | + */ | ||
| 14 | + void jumpToArPage(Context context); | ||
| 15 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/classify/IClassifyJump.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.classify; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 6 | + | ||
| 7 | +public interface IClassifyJump extends IProvider { | ||
| 8 | + void classifyJumpToView(Context context, String programDataStr, String channelName); | ||
| 9 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/im/CheckFriendsResult.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +public class CheckFriendsResult { | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * 不是好友 | ||
| 7 | + */ | ||
| 8 | + public static final int TIM_FRIEND_RELATION_TYPE_NONE = 0; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 对方在我的好友列表中 | ||
| 12 | + */ | ||
| 13 | + public static final int TIM_FRIEND_RELATION_TYPE_MY_UNI = 1; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 我在对方的好友列表中 | ||
| 17 | + */ | ||
| 18 | + public static final int TIM_FRIEND_RELATION_TYPE_OTHER_UNI = 2; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 互为好友 | ||
| 22 | + */ | ||
| 23 | + public static final int TIM_FRIEND_RELATION_TYPE_BOTH_WAY = 3; | ||
| 24 | + | ||
| 25 | + private String identifier = ""; | ||
| 26 | + private int resultCode; | ||
| 27 | + private String resultInfo = ""; | ||
| 28 | + private int resultType; | ||
| 29 | + | ||
| 30 | + public CheckFriendsResult(String identifier, int resultCode, String resultInfo, int resultType) { | ||
| 31 | + this.identifier = identifier; | ||
| 32 | + this.resultCode = resultCode; | ||
| 33 | + this.resultInfo = resultInfo; | ||
| 34 | + this.resultType = resultType; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public String getIdentifier() { | ||
| 38 | + return identifier; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setIdentifier(String identifier) { | ||
| 42 | + this.identifier = identifier; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public int getResultCode() { | ||
| 46 | + return resultCode; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setResultCode(int resultCode) { | ||
| 50 | + this.resultCode = resultCode; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getResultInfo() { | ||
| 54 | + return resultInfo; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setResultInfo(String resultInfo) { | ||
| 58 | + this.resultInfo = resultInfo; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public int getResultType() { | ||
| 62 | + return resultType; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setResultType(int resultType) { | ||
| 66 | + this.resultType = resultType; | ||
| 67 | + } | ||
| 68 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/im/FriendListData.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +public class FriendListData { | ||
| 4 | + | ||
| 5 | + private String friendId; | ||
| 6 | + private String friendFaceUrl; | ||
| 7 | + private String friendNickName; | ||
| 8 | + private String friendRemark; | ||
| 9 | + private String friendCustomInfoJson; | ||
| 10 | + | ||
| 11 | + public String getFriendId() { | ||
| 12 | + return friendId; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public void setFriendId(String friendId) { | ||
| 16 | + this.friendId = friendId; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public String getFriendFaceUrl() { | ||
| 20 | + return friendFaceUrl; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setFriendFaceUrl(String friendFaceUrl) { | ||
| 24 | + this.friendFaceUrl = friendFaceUrl; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getFriendNickName() { | ||
| 28 | + return friendNickName; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setFriendNickName(String friendNickName) { | ||
| 32 | + this.friendNickName = friendNickName; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public String getFriendRemark() { | ||
| 36 | + return friendRemark; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setFriendRemark(String friendRemark) { | ||
| 40 | + this.friendRemark = friendRemark; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getFriendCustomInfoJson() { | ||
| 44 | + return friendCustomInfoJson; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setFriendCustomInfoJson(String friendCustomInfoJson) { | ||
| 48 | + this.friendCustomInfoJson = friendCustomInfoJson; | ||
| 49 | + } | ||
| 50 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/im/ImOpenService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * IM相关的对外接口 | ||
| 9 | + */ | ||
| 10 | +public interface ImOpenService extends IProvider { | ||
| 11 | + //获取好友列表 | ||
| 12 | + void getFriendList(CNValueCallBack<List<FriendListData>> callBack); | ||
| 13 | + | ||
| 14 | + //是否已经加入了群组,注:本地数据判断 | ||
| 15 | + boolean hasJoinGroup(String groupId); | ||
| 16 | + | ||
| 17 | + //获取自己在群内的信息,注:网络获取 | ||
| 18 | + void getSelfInfoInGroup(String groupId, CNValueCallBack<JoinGroupState> callBack); | ||
| 19 | + | ||
| 20 | + //检测好友的状态 | ||
| 21 | + void checkFriends(String friendId, CNValueCallBack<CheckFriendsResult> callBack); | ||
| 22 | + | ||
| 23 | + interface CNCallBack { | ||
| 24 | + void onError(int errorCode, String errorMsg); | ||
| 25 | + | ||
| 26 | + void onSuccess(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + interface CNValueCallBack<T> { | ||
| 30 | + void onError(int var1, String var2); | ||
| 31 | + | ||
| 32 | + void onSuccess(T var1); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + String getFriendRemarkName(String userId); | ||
| 36 | + | ||
| 37 | + String getUserName(String userId, String nickName); | ||
| 38 | + | ||
| 39 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/im/JoinGroupState.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * author : gujun | ||
| 5 | + * date : 2019/11/5 15:53 | ||
| 6 | + * desc : 获取自己在群内的角色和消息接收状态 | ||
| 7 | + */ | ||
| 8 | +public class JoinGroupState { | ||
| 9 | + | ||
| 10 | + public static final int ROLE_TYPE_OWNER = 0x1001; | ||
| 11 | + public static final int ROLE_TYPE_ADMIN = 0x1002; | ||
| 12 | + public static final int ROLE_TYPE_NORMAL = 0x1003; | ||
| 13 | + public static final int ROLE_TYPE_NOT_MEMBER = 0x1004; | ||
| 14 | + | ||
| 15 | + public static final int ReceiveAndNotify = 0x2001; | ||
| 16 | + public static final int NotReceive = 0x2002; | ||
| 17 | + public static final int ReceiveNotNotify = 0x2003; | ||
| 18 | + | ||
| 19 | + private String groupId; | ||
| 20 | + private long recvOpt; | ||
| 21 | + private int role = ROLE_TYPE_NOT_MEMBER; | ||
| 22 | + | ||
| 23 | + public JoinGroupState(String groupId, long recvOpt, int role) { | ||
| 24 | + this.groupId = groupId; | ||
| 25 | + this.recvOpt = recvOpt; | ||
| 26 | + this.role = role; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public String getGroupId() { | ||
| 30 | + return groupId; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setGroupId(String groupId) { | ||
| 34 | + this.groupId = groupId; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public long getRecvOpt() { | ||
| 38 | + return recvOpt; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setRecvOpt(long recvOpt) { | ||
| 42 | + this.recvOpt = recvOpt; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public int getRole() { | ||
| 46 | + return role; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setRole(int role) { | ||
| 50 | + this.role = role; | ||
| 51 | + } | ||
| 52 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/input/ICommentInputLayoutService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.input; | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 评论输入窗 | ||
| 7 | + */ | ||
| 8 | +public interface ICommentInputLayoutService extends IProvider { | ||
| 9 | + /** | ||
| 10 | + * 隐藏输入框 | ||
| 11 | + * | ||
| 12 | + * @param content 输入框内文本 | ||
| 13 | + */ | ||
| 14 | + void hideInput(String content,String currentPage); | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 发送内容 | ||
| 18 | + * | ||
| 19 | + * @param content 输入框内文本 | ||
| 20 | + */ | ||
| 21 | + void sendContent(String content,String currentPage); | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 发送内容给某人 | ||
| 26 | + * | ||
| 27 | + * @param toSid 接收者ID | ||
| 28 | + * @param toName 接收者昵称 | ||
| 29 | + * @param content 输入框内文本内容 | ||
| 30 | + */ | ||
| 31 | + void sendContent(String toSid, String toName, String content,String currentPage); | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + void onClickEmoji(String currentPage); | ||
| 35 | + void onClickInput(String currentPage); | ||
| 36 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/input/InputEventData.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.input; | ||
| 2 | + | ||
| 3 | +public class InputEventData { | ||
| 4 | + | ||
| 5 | + public static final int send = 1; | ||
| 6 | + public static final int save = 2; | ||
| 7 | + public static final int clickEmoji = 3; | ||
| 8 | + public static final int clickInput = 4; | ||
| 9 | + private int type; | ||
| 10 | + private String userId; | ||
| 11 | + private String userName; | ||
| 12 | + private String content; | ||
| 13 | + private String currentPage; | ||
| 14 | + | ||
| 15 | + public String getCurrentPage() { | ||
| 16 | + return currentPage; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public void setCurrentPage(String currentPage) { | ||
| 20 | + this.currentPage = currentPage; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public InputEventData(int type, String content,String currentPage) { | ||
| 24 | + this.content = content; | ||
| 25 | + this.type = type; | ||
| 26 | + this.currentPage=currentPage; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public InputEventData(int type, String userId, String userName, String content, String currentPage) { | ||
| 30 | + this.userId = userId; | ||
| 31 | + this.userName = userName; | ||
| 32 | + this.content = content; | ||
| 33 | + this.type = type; | ||
| 34 | + this.currentPage = currentPage; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public int getType() { | ||
| 38 | + return type; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setType(int type) { | ||
| 42 | + this.type = type; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public String getUserId() { | ||
| 46 | + return userId; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setUserId(String userId) { | ||
| 50 | + this.userId = userId; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getUserName() { | ||
| 54 | + return userName; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setUserName(String userName) { | ||
| 58 | + this.userName = userName; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public String getContent() { | ||
| 62 | + return content; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setContent(String content) { | ||
| 66 | + this.content = content; | ||
| 67 | + } | ||
| 68 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/input/InputEventObservable.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.input; | ||
| 2 | + | ||
| 3 | +import java.util.Observable; | ||
| 4 | + | ||
| 5 | +public class InputEventObservable extends Observable { | ||
| 6 | + | ||
| 7 | + private static InputEventObservable instance = new InputEventObservable(); | ||
| 8 | + | ||
| 9 | + public static InputEventObservable getInstance() { | ||
| 10 | + return instance; | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + public void sendMessage(String content, String currentPage) { | ||
| 14 | + sendMessage("", "", content, currentPage); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public void sendMessage(String userId, String userName, String content, String currentPage) { | ||
| 18 | + InputEventData data = new InputEventData( | ||
| 19 | + InputEventData.send, userId, userName, content, currentPage); | ||
| 20 | + | ||
| 21 | + setChanged(); | ||
| 22 | + notifyObservers(data); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + public void saveCommentMessage(String content, String currentPage) { | ||
| 27 | + InputEventData data = new InputEventData( | ||
| 28 | + InputEventData.save, content, currentPage); | ||
| 29 | + | ||
| 30 | + setChanged(); | ||
| 31 | + notifyObservers(data); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public void onClickEmoji(String currentPage) { | ||
| 35 | + InputEventData data = new InputEventData( | ||
| 36 | + InputEventData.clickEmoji, "", "", "", currentPage); | ||
| 37 | + | ||
| 38 | + setChanged(); | ||
| 39 | + notifyObservers(data); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void onClickInput(String currentPage) { | ||
| 43 | + InputEventData data = new InputEventData( | ||
| 44 | + InputEventData.clickInput, "", "", "", currentPage); | ||
| 45 | + | ||
| 46 | + setChanged(); | ||
| 47 | + notifyObservers(data); | ||
| 48 | + } | ||
| 49 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/pay/CNLivePayService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.pay; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 6 | + | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 给上海电商 支付 | ||
| 11 | + */ | ||
| 12 | +public interface CNLivePayService extends IProvider { | ||
| 13 | + static final String PATH = "/openService/CNLivePayService"; | ||
| 14 | + static final String NAME = "开放支付的服务接口"; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 跳转到支付页面 | ||
| 19 | + * | ||
| 20 | + * @param context 上下文 | ||
| 21 | + * @param orderId 订单id | ||
| 22 | + * @param title 订单标题/订单描述/订单简介 | ||
| 23 | + * @param price 订单金额(单位:分) | ||
| 24 | + * @param notifyUrl 订单状态回调地址 | ||
| 25 | + * @param extraParamsMap 订单扩展字段 | ||
| 26 | + * @param fromId 支付方id | ||
| 27 | + * @param sellerId 收款方id | ||
| 28 | + * @param sellerName 收款方名称/店铺名称/商家名称(支付成功页面展示) | ||
| 29 | + * @param sellerFaceUrl 收款方头像/店铺头像/商家头像(支付成功页面展示) | ||
| 30 | + * @param remark 备注/描述(支付成功页面展示,付款页面不负责上传) | ||
| 31 | + * @param commodityId 商品ID(网家家付费节目-商品ID)(没有请填null) | ||
| 32 | + * @param isShowWjjPay 是否显示网家家支付 | ||
| 33 | + * @param isShowWeChatPay 是否显示微信支付 | ||
| 34 | + * @param isShowAliPay 是否显示支付宝支付 | ||
| 35 | + * @param isShowUnionPay 是否显示银联支付 | ||
| 36 | + */ | ||
| 37 | + void jumpToPayPage(Context context, String orderId, String title, double price, String notifyUrl, Map<String, String> extraParamsMap, String fromId, String sellerId, String sellerName, String sellerFaceUrl, String remark, String commodityId, boolean isShowWjjPay, boolean isShowWeChatPay, boolean isShowAliPay, boolean isShowUnionPay); | ||
| 38 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/share/CNLiveShareService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.share; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.graphics.Bitmap; | ||
| 5 | + | ||
| 6 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 7 | + | ||
| 8 | +public interface CNLiveShareService extends IProvider { | ||
| 9 | + static final String PATH = "/openService/CNLiveShareService"; | ||
| 10 | + static final String NAME = "开放分享的服务接口"; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 分享链接 | ||
| 14 | + * | ||
| 15 | + * @param context 上下文 | ||
| 16 | + * @param title 主标题 | ||
| 17 | + * @param subTitle 副标题 | ||
| 18 | + * @param shareUrl 分享的链接 | ||
| 19 | + * @param shareImgUrl 分享的图片的链接 | ||
| 20 | + * @param isShowWjjLife 是否显示网家家生活圈 | ||
| 21 | + * @param isShowWjjFriend 是否显示网家家好友 | ||
| 22 | + * @param isShowOther 是否显示更多 | ||
| 23 | + */ | ||
| 24 | + void shareLink(Context context, String title, String subTitle, String shareUrl, String shareImgUrl, boolean isShowWjjLife, boolean isShowWjjFriend, boolean isShowOther); | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 分享图片 | ||
| 29 | + * | ||
| 30 | + * @param context 上下文 | ||
| 31 | + * @param base64Img 图片转成base64 | ||
| 32 | + */ | ||
| 33 | + void shareImg(Context context, String base64Img); | ||
| 34 | +} | ||
| 35 | + |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/user/CNLiveUserService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.user; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 给上海电商 用户库 | ||
| 9 | + */ | ||
| 10 | +public interface CNLiveUserService extends IProvider { | ||
| 11 | + public static final String PATH = "/openService/CNLiveUserService"; | ||
| 12 | + public static final String NAME = "开放用户信息的服务接口"; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 跳转到登录页 | ||
| 16 | + * | ||
| 17 | + * @param tagUrl 跳转地址 | ||
| 18 | + */ | ||
| 19 | + void jumpToLoginActivity(Context context, String tagUrl); | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 跳转到登录对话框 | ||
| 23 | + * | ||
| 24 | + * @param tagUrl 跳转地址 | ||
| 25 | + */ | ||
| 26 | + void jumpToLoginDialog(Context context, String tagUrl); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 跳转到登录页 | ||
| 30 | + */ | ||
| 31 | + void jumpToLoginActivity(Context context); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 跳转到登录对话框 | ||
| 35 | + */ | ||
| 36 | + void jumpToLoginDialog(Context context); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 判断用户是否在线 | ||
| 40 | + * author ys | ||
| 41 | + * | ||
| 42 | + * @param context | ||
| 43 | + * @return | ||
| 44 | + */ | ||
| 45 | + boolean isUserOnline(Context context); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 判断用户是否登录 | ||
| 49 | + * author ys | ||
| 50 | + * | ||
| 51 | + * @param context | ||
| 52 | + * @return | ||
| 53 | + */ | ||
| 54 | + boolean isUserLogin(Context context); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 获取用户信息 | ||
| 58 | + * author ys | ||
| 59 | + * | ||
| 60 | + * @param context | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 63 | + OpenUserInfo getUserInfo(Context context); | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 获取用户id | ||
| 67 | + * author ys | ||
| 68 | + * | ||
| 69 | + * @param context | ||
| 70 | + * @return | ||
| 71 | + */ | ||
| 72 | + String getUid(Context context); | ||
| 73 | + | ||
| 74 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/user/OpenUserInfo.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.user; | ||
| 2 | + | ||
| 3 | +import android.text.TextUtils; | ||
| 4 | + | ||
| 5 | +import java.io.Serializable; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 开放平台-用户信息 | ||
| 9 | + * | ||
| 10 | + * @author ys | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +public class OpenUserInfo implements Serializable { | ||
| 14 | + //用户id | ||
| 15 | + private String uid; | ||
| 16 | + //昵称 | ||
| 17 | + private String nickName; | ||
| 18 | + //性别 | ||
| 19 | + private String gender; | ||
| 20 | + //地址 | ||
| 21 | + private String location; | ||
| 22 | + //详细地址 | ||
| 23 | + private String locationDesc; | ||
| 24 | + //头像 | ||
| 25 | + private String faceUrl; | ||
| 26 | + //手机号 | ||
| 27 | + private String mobile; | ||
| 28 | + //邮箱 | ||
| 29 | + private String email; | ||
| 30 | + //平台TOKEN | ||
| 31 | + private String token; | ||
| 32 | + //新用户 | ||
| 33 | + private boolean isNewUser; | ||
| 34 | + //个性签名 | ||
| 35 | + private String userSign; | ||
| 36 | + //用户头像大图 | ||
| 37 | + private String bigFaceUrl; | ||
| 38 | + //手机号国家码 | ||
| 39 | + private String countryCode; | ||
| 40 | + //qqid | ||
| 41 | + private String qqUid; | ||
| 42 | + //微信id | ||
| 43 | + private String wxUid; | ||
| 44 | + //微博id | ||
| 45 | + private String sinaUid; | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + public String getUid() { | ||
| 49 | + return uid == null ? "" : uid; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setUid(String uid) { | ||
| 53 | + this.uid = uid; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getNickName() { | ||
| 57 | + return nickName; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setNickName(String nickName) { | ||
| 61 | + this.nickName = nickName; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public String getGender() { | ||
| 65 | + return gender; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setGender(String gender) { | ||
| 69 | + this.gender = gender; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public String getLocation() { | ||
| 73 | + return location; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setLocation(String location) { | ||
| 77 | + this.location = location; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public String getLocationDesc() { | ||
| 81 | + return locationDesc; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setLocationDesc(String locationDesc) { | ||
| 85 | + this.locationDesc = locationDesc; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public String getFaceUrl() { | ||
| 89 | + return faceUrl; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setFaceUrl(String faceUrl) { | ||
| 93 | + this.faceUrl = faceUrl; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public String getBigFaceUrl() { | ||
| 97 | + if (TextUtils.isEmpty(bigFaceUrl)) return faceUrl; | ||
| 98 | + return bigFaceUrl; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setBigFaceUrl(String bigFaceUrl) { | ||
| 102 | + this.bigFaceUrl = bigFaceUrl; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public String getMobile() { | ||
| 106 | + return mobile; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setMobile(String mobile) { | ||
| 110 | + this.mobile = mobile; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public String getEmail() { | ||
| 114 | + return email; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void setEmail(String email) { | ||
| 118 | + this.email = email; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public String getToken() { | ||
| 122 | + return token; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setToken(String token) { | ||
| 126 | + this.token = token; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public boolean isNewUser() { | ||
| 130 | + return isNewUser; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void setNewUser(boolean newUser) { | ||
| 134 | + isNewUser = newUser; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public String getQqUid() { | ||
| 138 | + return qqUid; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setQqUid(String qqUid) { | ||
| 142 | + this.qqUid = qqUid; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public String getWxUid() { | ||
| 146 | + return wxUid; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public void setWxUid(String wxUid) { | ||
| 150 | + this.wxUid = wxUid; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public String getSinaUid() { | ||
| 154 | + return sinaUid; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public void setSinaUid(String sinaUid) { | ||
| 158 | + this.sinaUid = sinaUid; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public String getUserSign() { | ||
| 162 | + return userSign; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public void setUserSign(String userSign) { | ||
| 166 | + this.userSign = userSign; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public String getCountryCode() { | ||
| 170 | + return countryCode; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public void setCountryCode(String countryCode) { | ||
| 174 | + this.countryCode = countryCode; | ||
| 175 | + } | ||
| 176 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/arouter/user/OpenUserService.java
0 → 100644
| 1 | +package com.cnlive.libs.base.arouter.user; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.Uri; | ||
| 5 | + | ||
| 6 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * author : gujun | ||
| 10 | + * date : 2019/11/9 10:32 | ||
| 11 | + * desc : | ||
| 12 | + */ | ||
| 13 | +public interface OpenUserService extends IProvider { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 检测用户是否登录,未登录弹出登录框返回false,已登录返回true, | ||
| 17 | + * | ||
| 18 | + * @param userId 当前用户id | ||
| 19 | + * @param tagurl 跳转目标页面的分享地址 | ||
| 20 | + * @param isLoginDialog 登陆页面是弹框还是页面 | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + boolean userHasLogin(String userId, String tagurl, boolean isLoginDialog); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 此方式只是验证是否登录,不进行跳转 | ||
| 27 | + * | ||
| 28 | + * @param userId | ||
| 29 | + * @return | ||
| 30 | + */ | ||
| 31 | + boolean userHasLogin(String userId); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 检测用户是否登录,未登录弹出登录框返回false,已登录返回true, | ||
| 35 | + * | ||
| 36 | + * @param userId 当前用户id | ||
| 37 | + * @param tagurl 跳转目标页面的分享地址 | ||
| 38 | + * @param isClickAd 是否点击了广告 | ||
| 39 | + * @param isLoginDialog 登陆页面是弹框还是页面 | ||
| 40 | + * @return | ||
| 41 | + */ | ||
| 42 | + boolean userHasLogin(String userId, String tagurl, boolean isClickAd, boolean isLoginDialog, Uri uri); | ||
| 43 | + | ||
| 44 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/frame/ReflectUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.frame; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import java.lang.reflect.Constructor; | ||
| 5 | +import java.lang.reflect.Method; | ||
| 6 | +import java.lang.reflect.ParameterizedType; | ||
| 7 | + | ||
| 8 | +public class ReflectUtil { | ||
| 9 | + | ||
| 10 | + private static final String TAG = "ReflectUtil"; | ||
| 11 | + | ||
| 12 | + public static Object invoke(Object obj, String methodName, Object data, Class clazz) { | ||
| 13 | + Object result = null; | ||
| 14 | + try { | ||
| 15 | + Method method = obj.getClass().getMethod(methodName, clazz); | ||
| 16 | + result = method.invoke(obj, data); | ||
| 17 | + } catch (Exception ignored) { | ||
| 18 | + } | ||
| 19 | + return result; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public static Object invoke(Object obj, String methodName, Object data) { | ||
| 23 | + Object result = null; | ||
| 24 | + try { | ||
| 25 | + Method method = obj.getClass().getMethod(methodName, new Class[]{data.getClass()}); | ||
| 26 | + result = method.invoke(obj, data); | ||
| 27 | + } catch (Exception ignored) { | ||
| 28 | + } | ||
| 29 | + return result; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public static Object invoke(Object obj, String methodName) { | ||
| 33 | + Object result = null; | ||
| 34 | + try { | ||
| 35 | + Method method = obj.getClass().getMethod(methodName); | ||
| 36 | + result = method.invoke(obj); | ||
| 37 | + } catch (Exception ignored) { | ||
| 38 | + } | ||
| 39 | + return result; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public static <R> R instance(int position, Class type, Object data) { | ||
| 43 | + R result = null; | ||
| 44 | + try { | ||
| 45 | + ParameterizedType pt = (ParameterizedType) type.getGenericSuperclass(); | ||
| 46 | + Class<R> clazz = (Class<R>) pt.getActualTypeArguments()[position]; | ||
| 47 | + Constructor constructor = clazz.getConstructor(new Class[]{data.getClass()}); | ||
| 48 | + result = (R) constructor.newInstance(data); | ||
| 49 | + } catch (Exception ignored) { | ||
| 50 | + } | ||
| 51 | + return result; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public static <R> R instance(int position, Object object) { | ||
| 55 | + R result = null; | ||
| 56 | + try { | ||
| 57 | + ParameterizedType pt = (ParameterizedType) object.getClass().getGenericSuperclass(); | ||
| 58 | + Class<R> clazz = (Class<R>) pt.getActualTypeArguments()[position]; | ||
| 59 | + result = clazz.newInstance(); | ||
| 60 | + } catch (Exception ignored) { | ||
| 61 | + } | ||
| 62 | + return result; | ||
| 63 | + } | ||
| 64 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/frame/adapter/DataBindingRecyclerAdapter.java
0 → 100644
| 1 | +package com.cnlive.libs.base.frame.adapter; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by xiansong on 2017/9/1. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +import android.view.LayoutInflater; | ||
| 8 | +import android.view.View; | ||
| 9 | +import android.view.ViewGroup; | ||
| 10 | + | ||
| 11 | +import androidx.annotation.NonNull; | ||
| 12 | +import androidx.databinding.DataBindingUtil; | ||
| 13 | +import androidx.databinding.ViewDataBinding; | ||
| 14 | +import androidx.recyclerview.widget.RecyclerView; | ||
| 15 | + | ||
| 16 | +import com.cnlive.libs.base.frame.ReflectUtil; | ||
| 17 | + | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +public abstract class DataBindingRecyclerAdapter<D, T extends ViewDataBinding> extends RecyclerView.Adapter<DataBindingRecyclerAdapter<D, T>.DataBindingViewHolder> { | ||
| 22 | + | ||
| 23 | + class DataBindingViewHolder extends RecyclerView.ViewHolder { | ||
| 24 | + | ||
| 25 | + private ViewDataBinding binding; | ||
| 26 | + | ||
| 27 | + private DataBindingViewHolder(View itemView) { | ||
| 28 | + super(itemView); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setBinding(ViewDataBinding binding) { | ||
| 32 | + this.binding = binding; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public ViewDataBinding getBinding() { | ||
| 36 | + return binding; | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + abstract class Click implements View.OnClickListener { | ||
| 41 | + int position; | ||
| 42 | + | ||
| 43 | + Click(int position) { | ||
| 44 | + this.position = position; | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public interface OnItemClickListener<D> { | ||
| 49 | + void onItemClick(int id, D item); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public abstract int getLayoutId(); | ||
| 53 | + | ||
| 54 | + public abstract List<D> getList(); | ||
| 55 | + | ||
| 56 | + private OnItemClickListener<D> listener; | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public DataBindingViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
| 60 | + T binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), getLayoutId(), parent, false); | ||
| 61 | + DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot()); | ||
| 62 | + viewHolder.setBinding(binding); | ||
| 63 | + return viewHolder; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public void onBindViewHolder(@NonNull final DataBindingViewHolder holder, int position) { | ||
| 68 | + ReflectUtil.invoke(holder.binding, "setData", getList().get(position)); | ||
| 69 | + ReflectUtil.invoke(holder.binding, "setClick", new Click(position) { | ||
| 70 | + @Override | ||
| 71 | + public void onClick(View v) { | ||
| 72 | +// if (listener != null) listener.onItemClick(v.getId(), getList().get(position)); | ||
| 73 | + if (listener != null) | ||
| 74 | + listener.onItemClick(v.getId(), (D) ReflectUtil.invoke(holder.binding, "getData")); | ||
| 75 | + } | ||
| 76 | + }, View.OnClickListener.class); | ||
| 77 | + holder.binding.executePendingBindings(); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public D getItem(int location) { | ||
| 81 | + return getList().get(location); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Override | ||
| 85 | + public int getItemCount() { | ||
| 86 | + return getList() == null ? 0 : getList().size(); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setItemClickListener(OnItemClickListener<D> listener) { | ||
| 90 | + this.listener = listener; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void addItem(int position, D item) { | ||
| 94 | + if (item == null) return; | ||
| 95 | + getList().add(position, item); | ||
| 96 | + notifyItemInserted(position); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public void addItem(D item) { | ||
| 100 | + if (item == null) return; | ||
| 101 | + getList().add(getList().size(), item); | ||
| 102 | + notifyItemInserted(getList().size()); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void addItems(List<D> items) { | ||
| 106 | + if (items == null) return; | ||
| 107 | + this.getList().addAll(items); | ||
| 108 | + notifyDataSetChanged(); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public boolean containsAll(List<D> items) { | ||
| 112 | + return getList().containsAll(items); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + public void updateItem(D tasks, int position) { | ||
| 116 | + if (tasks == null) return; | ||
| 117 | + getList().set(position, tasks); | ||
| 118 | + notifyItemChanged(position); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void updateItems(List<D> items) { | ||
| 122 | + if (items == null) return; | ||
| 123 | + this.getList().clear(); | ||
| 124 | + this.getList().addAll(items); | ||
| 125 | + notifyDataSetChanged(); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public void removeItem(int index) { | ||
| 129 | + getList().remove(index); | ||
| 130 | + notifyItemRemoved(index); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void removeAllItems() { | ||
| 134 | + getList().clear(); | ||
| 135 | + notifyDataSetChanged(); | ||
| 136 | + } | ||
| 137 | +} | ||
| 0 | \ No newline at end of file | 138 | \ No newline at end of file |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/frame/model/ViewStateListData.java
0 → 100644
| 1 | +package com.cnlive.libs.base.frame.model; | ||
| 2 | + | ||
| 3 | +import android.os.Parcel; | ||
| 4 | +import android.os.Parcelable; | ||
| 5 | +import android.util.Log; | ||
| 6 | + | ||
| 7 | +import androidx.databinding.BaseObservable; | ||
| 8 | +import androidx.databinding.Bindable; | ||
| 9 | +import androidx.databinding.ViewDataBinding; | ||
| 10 | +import androidx.recyclerview.widget.RecyclerView; | ||
| 11 | + | ||
| 12 | +import com.cnlive.libs.base.frame.adapter.DataBindingRecyclerAdapter; | ||
| 13 | + | ||
| 14 | +import java.util.ArrayList; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Created by xiansong on 2017/9/1. | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | +public abstract class ViewStateListData<ITEM extends BaseObservable, BINDING extends ViewDataBinding> extends BaseObservable implements Parcelable { | ||
| 22 | + | ||
| 23 | + private static final String TAG = "PageListData"; | ||
| 24 | + | ||
| 25 | + public static <T extends ViewStateListData<ITEM, BINDING>, ITEM extends BaseObservable, BINDING extends ViewDataBinding> T newInstance(Class<T> clazz, Parcel in) { | ||
| 26 | + T data = null; | ||
| 27 | + try { | ||
| 28 | + data = clazz.newInstance(); | ||
| 29 | + data.createFromParcel(in); | ||
| 30 | + } catch (Exception e) { | ||
| 31 | + Log.e(TAG, "Presenter or data need to implement the default constructor: constructor ()", e); | ||
| 32 | + } | ||
| 33 | + return data; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public abstract int getLayoutId(); | ||
| 37 | + | ||
| 38 | + public abstract RecyclerView.LayoutManager getLayoutManager(); | ||
| 39 | + | ||
| 40 | + private List<ITEM> list = new ArrayList<>(); | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + private DataBindingRecyclerAdapter<ITEM, BINDING> adapter = new DataBindingRecyclerAdapter<ITEM, BINDING>() { | ||
| 44 | + @Override | ||
| 45 | + public int getLayoutId() { | ||
| 46 | + return ViewStateListData.this.getLayoutId(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public List<ITEM> getList() { | ||
| 51 | + return list; | ||
| 52 | + } | ||
| 53 | + }; | ||
| 54 | + | ||
| 55 | + @Bindable | ||
| 56 | + public DataBindingRecyclerAdapter<ITEM, BINDING> getAdapter() { | ||
| 57 | + return adapter; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setAdapter(DataBindingRecyclerAdapter<ITEM, BINDING> adapter) { | ||
| 61 | + this.adapter = adapter; | ||
| 62 | + notifyPropertyChanged(com.cnlive.libs.base.BR.adapter); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public int describeContents() { | ||
| 68 | + return 0; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public void writeToParcel(Parcel parcel, int i) { | ||
| 73 | + parcel.writeList(this.list); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void createFromParcel(Parcel in) { | ||
| 77 | + in.readList(list, getClass().getClassLoader()); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/frame/view/MvpStateView.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/Config.java
0 → 100644
| 1 | +package com.cnlive.libs.base.logic; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by xiansong on 2018/1/4. | ||
| 5 | + */ | ||
| 6 | + | ||
| 7 | +public class Config { | ||
| 8 | + | ||
| 9 | + //成功状态 | ||
| 10 | + public static final int SUCCESS = 0; | ||
| 11 | + //失败状态 | ||
| 12 | + public static final int FAIL = -1; | ||
| 13 | + //系统错误 | ||
| 14 | + public static final int ERROR_SYSTEM = 2003; | ||
| 15 | + //上传/下载错误 | ||
| 16 | + public static final int ERROR_UPLOAD = 2004; | ||
| 17 | + //空闲状态 | ||
| 18 | + public static final int STATE_IDLE = 3001; | ||
| 19 | + //加载状态 | ||
| 20 | + public static final int STATE_LOAD = 3002; | ||
| 21 | + | ||
| 22 | + public static final String ERROR_DEF = "%S_ERROR_%s code:%s message:%s"; | ||
| 23 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/Event.java
0 → 100644
| 1 | +package com.cnlive.libs.base.logic; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.cnlive.libs.base.logic.callback.Callback; | ||
| 5 | +import com.cnlive.libs.base.logic.callback.CancelCallback; | ||
| 6 | +import com.cnlive.libs.base.logic.callback.FailureCallback; | ||
| 7 | +import com.cnlive.libs.base.logic.callback.ProgressCallback; | ||
| 8 | +import com.cnlive.libs.base.logic.callback.StateCallback; | ||
| 9 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | ||
| 10 | + | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | +import java.util.HashMap; | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Map; | ||
| 15 | + | ||
| 16 | +import io.reactivex.disposables.Disposable; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by xiansong on 2018/1/8. | ||
| 20 | + */ | ||
| 21 | + | ||
| 22 | +public class Event<T> { | ||
| 23 | + | ||
| 24 | + private static final int success_call = 1; | ||
| 25 | + private static final int failure_call = 2; | ||
| 26 | + private static final int state_call = 3; | ||
| 27 | + private static final int cancel_call = 4; | ||
| 28 | + private static final int progress_call = 5; | ||
| 29 | + | ||
| 30 | + public boolean active = true; | ||
| 31 | + private Logic logic; | ||
| 32 | + private List<Disposable> disposables = new ArrayList<>(); | ||
| 33 | + private Map<Integer, Callback> callbackArray; | ||
| 34 | + | ||
| 35 | + public Event() { | ||
| 36 | + this.callbackArray = new HashMap<>(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setLogic(Logic logic) { | ||
| 40 | + this.logic = logic; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public Event<T> setSuccessCallback(SuccessCallback<T> callback) { | ||
| 44 | + callbackArray.put(success_call, callback); | ||
| 45 | + return this; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public Event<T> setFailureCallback(FailureCallback callback) { | ||
| 49 | + callbackArray.put(failure_call, callback); | ||
| 50 | + return this; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public Event<T> setStateCallback(StateCallback callback) { | ||
| 54 | + callbackArray.put(state_call, callback); | ||
| 55 | + return this; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public Event<T> setCancelCallback(CancelCallback callback) { | ||
| 59 | + callbackArray.put(cancel_call, callback); | ||
| 60 | + return this; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public Event<T> setProgressCallback(ProgressCallback callback) { | ||
| 64 | + callbackArray.put(progress_call, callback); | ||
| 65 | + return this; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public Event<T> addDisposable(Disposable disposable) { | ||
| 69 | + if (disposable != null) disposables.add(disposable); | ||
| 70 | + return this; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void onSuccess(T data) { | ||
| 74 | + active = false; | ||
| 75 | + SuccessCallback<T> callback = (SuccessCallback<T>) callbackArray.get(success_call); | ||
| 76 | + if (callback != null) callback.onSuccess(data); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void onFailure(int state, String message) { | ||
| 80 | + active = false; | ||
| 81 | + FailureCallback callback = (FailureCallback) callbackArray.get(failure_call); | ||
| 82 | + if (callback != null) callback.onFailure(state, message); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void onState(int state) { | ||
| 86 | + StateCallback callback = (StateCallback) callbackArray.get(state_call); | ||
| 87 | + if (callback != null) callback.onState(state); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public void onCancle() { | ||
| 91 | + CancelCallback callback = (CancelCallback) callbackArray.get(cancel_call); | ||
| 92 | + if (callback != null) callback.onCancel(); | ||
| 93 | + destroy(); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void onProgress(double progress) { | ||
| 97 | + ProgressCallback callback = (ProgressCallback) callbackArray.get(progress_call); | ||
| 98 | + if (callback != null) callback.onProgress(progress); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void cencel() { | ||
| 102 | + onCancle(); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + private void destroy() { | ||
| 106 | + active = false; | ||
| 107 | + callbackArray.clear(); | ||
| 108 | + if (disposables != null) for (Disposable disposable : disposables) disposable.dispose(); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public Event<T> start() { | ||
| 112 | + if (logic != null) logic.start(this); | ||
| 113 | + return this; | ||
| 114 | + } | ||
| 115 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/Logic.java
0 → 100644
| 1 | +package com.cnlive.libs.base.logic; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import android.util.Log; | ||
| 5 | + | ||
| 6 | +import com.cnlive.libs.base.logic.callback.DataCallback; | ||
| 7 | + | ||
| 8 | +import java.util.ArrayList; | ||
| 9 | +import java.util.HashMap; | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +import io.reactivex.Observable; | ||
| 14 | +import io.reactivex.ObservableOnSubscribe; | ||
| 15 | +import io.reactivex.android.schedulers.AndroidSchedulers; | ||
| 16 | +import io.reactivex.disposables.Disposable; | ||
| 17 | +import io.reactivex.functions.Consumer; | ||
| 18 | +import io.reactivex.schedulers.Schedulers; | ||
| 19 | + | ||
| 20 | +import static com.cnlive.libs.base.logic.Config.FAIL; | ||
| 21 | +import static com.cnlive.libs.base.logic.Config.SUCCESS; | ||
| 22 | + | ||
| 23 | +public class Logic { | ||
| 24 | + private Event event; | ||
| 25 | + | ||
| 26 | + protected List<BaseAction> actions; | ||
| 27 | + | ||
| 28 | + private Object startParem; | ||
| 29 | + | ||
| 30 | + private Paramer paramer = new Paramer(); | ||
| 31 | + | ||
| 32 | + protected Logic(Object startParem) { | ||
| 33 | + this.startParem = startParem; | ||
| 34 | + actions = new ArrayList<>(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public static Logic create(Object startParem) { | ||
| 38 | + return new Logic(startParem); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static Logic create() { | ||
| 42 | + return new Logic(null); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public <param, result> Logic action(Action<param, result> action) { | ||
| 46 | + if (action == null) return this; | ||
| 47 | + actions.add(action); | ||
| 48 | + return this; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public <param, result> Logic action(ActionMerge<param, result> action) { | ||
| 52 | + if (action == null) return this; | ||
| 53 | + actions.add(action); | ||
| 54 | + return this; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + private int action_index = -1; | ||
| 58 | + | ||
| 59 | + private boolean inStart() { | ||
| 60 | + return action_index != -1; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + private <Data, Return> void next(Data data) { | ||
| 64 | + BaseAction action = actions.get(action_index++); | ||
| 65 | + BaseAction newAction = action_index < actions.size() ? actions.get(action_index) : null; | ||
| 66 | + LogicCallback<Return> callback = new LogicCallback<>(event, newAction); | ||
| 67 | + Disposable disposable = null; | ||
| 68 | + Exception exception = null; | ||
| 69 | + try { | ||
| 70 | + if (action == null) return; | ||
| 71 | + if (action instanceof Action) disposable = ((Action) action).action(data, callback); | ||
| 72 | + if (action instanceof ActionMerge) disposable = ((ActionMerge) action).action(data, paramer, callback); | ||
| 73 | + } catch (Exception e) { | ||
| 74 | + exception = e; | ||
| 75 | + Log.e("Logic", "页面逻辑出错!", e); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + if (disposable != null) event.addDisposable(disposable); | ||
| 79 | + else if (exception != null) onError(FAIL, exception.getMessage(), event); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public <T> Event<T> event() { | ||
| 83 | + if (event != null) return event; | ||
| 84 | + event = new Event<T>(); | ||
| 85 | + event.setLogic(this); | ||
| 86 | + return event; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + // | ||
| 90 | + public void start(Event event) { | ||
| 91 | + if (event == null) return; | ||
| 92 | + if (inStart()) return; | ||
| 93 | + | ||
| 94 | + this.action_index = 0; | ||
| 95 | + this.event = event; | ||
| 96 | + | ||
| 97 | + if (event.active) { | ||
| 98 | + event.onState(Config.STATE_LOAD); | ||
| 99 | + next(startParem); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public interface Execute<T> { | ||
| 104 | + T execute(); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + private static String getErrorMessage(Throwable throwable) { | ||
| 108 | + return throwable != null ? throwable.getMessage() : ""; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public static <T> Disposable process(Execute<T> exce, DataCallback<T> callback) { | ||
| 112 | + Consumer<T> successEV = data -> { | ||
| 113 | + if (callback != null) callback.callback(SUCCESS, "", data); | ||
| 114 | + }; | ||
| 115 | + Consumer<Throwable> errorEV = throwable -> { | ||
| 116 | + if (callback != null) callback.callback(FAIL, getErrorMessage(throwable), null); | ||
| 117 | + }; | ||
| 118 | + return Observable | ||
| 119 | + .create((ObservableOnSubscribe<T>) emitter -> emitter.onNext(exce.execute())) | ||
| 120 | + .subscribeOn(Schedulers.io()) | ||
| 121 | + .observeOn(AndroidSchedulers.mainThread()) | ||
| 122 | + .subscribe(successEV, errorEV); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + private interface BaseAction { | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public interface Action<param, result> extends BaseAction { | ||
| 129 | + Disposable action(param data, DataCallback<result> callback); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public interface ActionMerge<param, result> extends BaseAction { | ||
| 133 | + Disposable action(param data, Paramer paramer, DataCallback<result> callback); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public class LogicCallback<T> implements DataCallback<T> { | ||
| 137 | + private BaseAction action; | ||
| 138 | + private Event event; | ||
| 139 | + | ||
| 140 | + private LogicCallback(Event event, BaseAction action) { | ||
| 141 | + this.event = event; | ||
| 142 | + this.action = action; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + @Override | ||
| 146 | + public void callback(int code, String message, T data) { | ||
| 147 | + if (code == Config.SUCCESS) { | ||
| 148 | + if (event.active) { | ||
| 149 | + if (action != null) next(data); | ||
| 150 | + else { | ||
| 151 | + event.onState(Config.STATE_IDLE); | ||
| 152 | + event.onSuccess(data); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + } else onError(code, message, event); | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + private void onError(int code, String message, Event event) { | ||
| 160 | + if (event.active) { | ||
| 161 | + event.onState(Config.STATE_IDLE); | ||
| 162 | + event.onFailure(code, message); | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public static class Paramer { | ||
| 167 | + private Map<String, Object> map = new HashMap<>(); | ||
| 168 | + | ||
| 169 | + public void addParamer(String key, Object value) { | ||
| 170 | + map.put(key, value); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public <T> T getParamer(String key) { | ||
| 174 | + return (T) map.get(key); | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/Callback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/CancelCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/DataCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/FailureCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/ProgressCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/StateCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/logic/callback/SuccessCallback.java
0 → 100644
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/observable/ShareStateInfo.java
0 → 100644
| 1 | +package com.cnlive.libs.base.observable; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 作者: 吴奎庆 | ||
| 5 | + * <p> | ||
| 6 | + * 时间: 2019/10/23 | ||
| 7 | + * <p> | ||
| 8 | + * 简介: | ||
| 9 | + */ | ||
| 10 | +public class ShareStateInfo { | ||
| 11 | + | ||
| 12 | + // 1 网家家好友 2 网家家生活圈 3 微信好友 4 微信朋友圈 5 qq 6 微博 7 外部 8 举报 9 其他 | ||
| 13 | + String type; | ||
| 14 | + //商城的分享的类型 | ||
| 15 | + String shopShareType; | ||
| 16 | + //是否分享成功 | ||
| 17 | + boolean isShareSuccess; | ||
| 18 | + | ||
| 19 | + public String getType() { | ||
| 20 | + return type; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setType(String type) { | ||
| 24 | + this.type = type; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getShopShareType() { | ||
| 28 | + return shopShareType; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setShopShareType(String shopShareType) { | ||
| 32 | + this.shopShareType = shopShareType; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public boolean isShareSuccess() { | ||
| 36 | + return isShareSuccess; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setShareSuccess(boolean shareSuccess) { | ||
| 40 | + isShareSuccess = shareSuccess; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + | ||
| 45 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/observable/ShareStateObservable.java
0 → 100644
| 1 | +package com.cnlive.libs.base.observable; | ||
| 2 | + | ||
| 3 | +import java.util.Observable; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 作者: 吴奎庆 | ||
| 7 | + * <p> | ||
| 8 | + * 时间: 2019/10/23 | ||
| 9 | + * <p> | ||
| 10 | + * 简介: 三方分享的状态回调 | ||
| 11 | + */ | ||
| 12 | +public class ShareStateObservable extends Observable { | ||
| 13 | + | ||
| 14 | + static ShareStateObservable instance; | ||
| 15 | + | ||
| 16 | + public static ShareStateObservable newInstance() { | ||
| 17 | + | ||
| 18 | + synchronized (ShareStateObservable.class) { | ||
| 19 | + if (instance == null) { | ||
| 20 | + instance = new ShareStateObservable(); | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + return instance; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新分享的状态 | ||
| 28 | + * @param info | ||
| 29 | + */ | ||
| 30 | + public void update(ShareStateInfo info) { | ||
| 31 | + setChanged(); | ||
| 32 | + notifyObservers(info); | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/observable/ShareWjjStateObservable.java
0 → 100644
| 1 | +package com.cnlive.libs.base.observable; | ||
| 2 | + | ||
| 3 | +import java.util.Observable; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 作者: 吴奎庆 | ||
| 7 | + * <p> | ||
| 8 | + * 时间: 2019/10/23 | ||
| 9 | + * <p> | ||
| 10 | + * 简介: 网++分享成功的状态 | ||
| 11 | + */ | ||
| 12 | +public class ShareWjjStateObservable extends Observable { | ||
| 13 | + | ||
| 14 | + static ShareWjjStateObservable instance; | ||
| 15 | + | ||
| 16 | + public static ShareWjjStateObservable newInstance() { | ||
| 17 | + | ||
| 18 | + synchronized (ShareWjjStateObservable.class) { | ||
| 19 | + if (instance == null) { | ||
| 20 | + instance = new ShareWjjStateObservable(); | ||
| 21 | + } | ||
| 22 | + return instance; | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public void update(boolean isSuccessed){ | ||
| 27 | + setChanged(); | ||
| 28 | + notifyObservers(isSuccessed); | ||
| 29 | + } | ||
| 30 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/observable/sp/SpFollowObservable.java
0 → 100644
| 1 | +package com.cnlive.libs.base.observable.sp; | ||
| 2 | + | ||
| 3 | +import java.util.Observable; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Created by Lynn on 2019/4/3. | ||
| 7 | + * 订阅号主页点击关注后,更新播放、H5详情页面关注按钮状态 | ||
| 8 | + */ | ||
| 9 | +public class SpFollowObservable extends Observable { | ||
| 10 | + private static SpFollowObservable instance; | ||
| 11 | + | ||
| 12 | + public static SpFollowObservable getInstance() { | ||
| 13 | + if (instance == null) { | ||
| 14 | + synchronized (SpFollowObservable.class) { | ||
| 15 | + if (instance == null) { | ||
| 16 | + instance = new SpFollowObservable(); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + return instance; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void changeAttentionStatus(String spId, boolean attention, String fansCount) { | ||
| 24 | + setChanged(); | ||
| 25 | + notifyObservers(new SubscribeInfo(spId, attention, fansCount)); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void changeAttentionStatus(String spId, boolean attention) { | ||
| 29 | + setChanged(); | ||
| 30 | + notifyObservers(new SubscribeInfo(spId, attention)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public static class SubscribeInfo { | ||
| 34 | + private String spId; | ||
| 35 | + private boolean attention; | ||
| 36 | + private String fansCount; | ||
| 37 | + | ||
| 38 | + public SubscribeInfo(String spId, boolean attention) { | ||
| 39 | + this.spId = spId; | ||
| 40 | + this.attention = attention; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public SubscribeInfo(String spId, boolean attention, String fansCount) { | ||
| 44 | + this.spId = spId; | ||
| 45 | + this.attention = attention; | ||
| 46 | + this.fansCount = fansCount; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public String getSpId() { | ||
| 50 | + return spId; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public void setSpId(String spId) { | ||
| 54 | + this.spId = spId; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public boolean isAttention() { | ||
| 58 | + return attention; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void setAttention(boolean attention) { | ||
| 62 | + this.attention = attention; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public String getFansCount() { | ||
| 66 | + return getFansNum(fansCount); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void setFansCount(String fansCount) { | ||
| 70 | + this.fansCount = fansCount; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + private String getFansNum(String fansCount) { | ||
| 74 | + int fansNum; | ||
| 75 | + try { | ||
| 76 | + fansNum = Integer.parseInt(fansCount); | ||
| 77 | + } catch (Exception e) { | ||
| 78 | + fansNum = 0; | ||
| 79 | + } | ||
| 80 | + return fansNum + ""; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/recevier/IMReconnectReceive.java
0 → 100644
| 1 | +package com.cnlive.libs.base.recevier; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import org.greenrobot.eventbus.EventBus; | ||
| 5 | + | ||
| 6 | +public class IMReconnectReceive { | ||
| 7 | + | ||
| 8 | + public static class IMConnectState { | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + public interface IMReconnectCallback { | ||
| 12 | + void onIMReconnectEvent(IMConnectState state); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public static void register(IMReconnectCallback subscriber) { | ||
| 16 | + if (EventBus.getDefault().isRegistered(subscriber)) return; | ||
| 17 | + EventBus.getDefault().register(subscriber); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public static void unregister(IMReconnectCallback subscriber) { | ||
| 21 | + EventBus.getDefault().unregister(subscriber); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public static void reconnect() { | ||
| 25 | + EventBus.getDefault().post(new IMConnectState()); | ||
| 26 | + } | ||
| 27 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/recevier/NetworkChangeReceive.java
0 → 100644
| 1 | +package com.cnlive.libs.base.recevier; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.ConnectivityManager; | ||
| 5 | +import android.net.NetworkInfo; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +import com.github.pwittchen.reactivenetwork.library.rx2.Connectivity; | ||
| 9 | +import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork; | ||
| 10 | + | ||
| 11 | +import org.greenrobot.eventbus.EventBus; | ||
| 12 | + | ||
| 13 | +import io.reactivex.android.schedulers.AndroidSchedulers; | ||
| 14 | +import io.reactivex.disposables.Disposable; | ||
| 15 | +import io.reactivex.schedulers.Schedulers; | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by gujun on 2017/6/23. | ||
| 20 | + */ | ||
| 21 | + | ||
| 22 | +public class NetworkChangeReceive { | ||
| 23 | + | ||
| 24 | + private static Disposable disposable; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + public interface NetworkChangeCallback { | ||
| 28 | + void onNetworkChangeEvent(Connectivity connectivity); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public static void register(NetworkChangeCallback subscriber) { | ||
| 32 | + if (EventBus.getDefault().isRegistered(subscriber)) return; | ||
| 33 | + EventBus.getDefault().register(subscriber); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public static void unregister(NetworkChangeCallback subscriber) { | ||
| 37 | + EventBus.getDefault().unregister(subscriber); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 启用网络通知 | ||
| 42 | + * | ||
| 43 | + * @param context 上下文 | ||
| 44 | + */ | ||
| 45 | + public static void enabled(Context context) { | ||
| 46 | + if (disposable == null) | ||
| 47 | + disposable = ReactiveNetwork.observeNetworkConnectivity(context) | ||
| 48 | + .subscribeOn(Schedulers.io()) | ||
| 49 | + .observeOn(AndroidSchedulers.mainThread()) | ||
| 50 | + .subscribe(connectivity -> EventBus.getDefault().post(connectivity)); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 禁用网络通知 | ||
| 55 | + */ | ||
| 56 | + public static void disabled() { | ||
| 57 | + if (disposable != null) { | ||
| 58 | + disposable.dispose(); | ||
| 59 | + disposable = null; | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public static boolean isNetworkConnect(Context context) { | ||
| 64 | + if(context == null) return true; | ||
| 65 | + //判断是否有网络连接 | ||
| 66 | + ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
| 67 | + NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); | ||
| 68 | + NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||
| 69 | + | ||
| 70 | + if (mobileInfo != null && mobileInfo.isConnected()) { | ||
| 71 | + return true; | ||
| 72 | + } else if (wifiInfo != null && wifiInfo.isConnected()) { | ||
| 73 | + return true; | ||
| 74 | + } else { | ||
| 75 | + return false; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/AlertUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.view.Gravity; | ||
| 5 | + | ||
| 6 | +import com.cnlive.libs.base.R; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by xiansong on 2017/9/11. | ||
| 10 | + */ | ||
| 11 | + | ||
| 12 | +public class AlertUtil { | ||
| 13 | + /** | ||
| 14 | + * 声明全局ToastUtil.Build对象 | ||
| 15 | + * 通过.build()获得ToastUtil对象 | ||
| 16 | + */ | ||
| 17 | + private static final ToastUtil.Build mainToast = ToastUtil.newBuild() | ||
| 18 | + //对齐参数设置 | ||
| 19 | + .setGravity(Gravity.CENTER, 0, 0) | ||
| 20 | + //设置布局 Layout Id 文本视图 View Id | ||
| 21 | + .setView(R.layout.layout_toast_1, R.id.text); | ||
| 22 | + | ||
| 23 | + public static void showDeftToast(Context context, int messageRes) { | ||
| 24 | + mainToast.build(context).showToast(context.getString(messageRes)); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public static void showDeftToast(Context context, String message) { | ||
| 28 | + mainToast.build(context).showToast(message); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public static void showLongToast(Context context, String message,int duration){ | ||
| 32 | + mainToast.build(context).showToast(message,duration); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 成功的提示 | ||
| 37 | + * | ||
| 38 | + * @param context | ||
| 39 | + * @param message | ||
| 40 | + */ | ||
| 41 | + public static void showSuccessToast(Context context, String message) { | ||
| 42 | + ToastUtil.Build successToast = ToastUtil.newBuild() | ||
| 43 | + //对齐参数设置 | ||
| 44 | + .setGravity(Gravity.CENTER, 0, 0) | ||
| 45 | + //设置布局 Layout Id 文本视图 View Id | ||
| 46 | + .setView(R.layout.layout_toast_success, R.id.text); | ||
| 47 | + successToast.build(context).showToast(message); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 失败的提示 | ||
| 52 | + * | ||
| 53 | + * @param context | ||
| 54 | + * @param message | ||
| 55 | + */ | ||
| 56 | + public static void showFailedToast(Context context, String message) { | ||
| 57 | + ToastUtil.Build failedToast = ToastUtil.newBuild() | ||
| 58 | + .setGravity(Gravity.CENTER, 0, 0) | ||
| 59 | + .setView(R.layout.layout_toast_failed, R.id.text); | ||
| 60 | + failedToast.build(context).showToast(message); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 不比较吐司内容是否相同提示 | ||
| 65 | + * | ||
| 66 | + * @param context | ||
| 67 | + * @param message | ||
| 68 | + */ | ||
| 69 | + public static void showNoEqulesToast(Context context, String message) { | ||
| 70 | + ToastUtil.Build failedToast = ToastUtil.newBuild() | ||
| 71 | + .setGravity(Gravity.CENTER, 0, 0) | ||
| 72 | + .setView(R.layout.layout_toast_1, R.id.text); | ||
| 73 | + failedToast.build(context).showNoEqulesToast(message); | ||
| 74 | + } | ||
| 75 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/AppProbeUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.Uri; | ||
| 5 | +import android.text.TextUtils; | ||
| 6 | +import android.util.Log; | ||
| 7 | + | ||
| 8 | +import com.cnlive.libs.base.application.AppConfig; | ||
| 9 | + | ||
| 10 | +import java.lang.reflect.Method; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 统计已经迁移到新的module | ||
| 14 | + */ | ||
| 15 | +@Deprecated | ||
| 16 | +public class AppProbeUtil { | ||
| 17 | + private static String COUNT_TYPE = "type__count"; | ||
| 18 | + private static String DURATION_TYPE = "type__duration"; | ||
| 19 | + private static String SHARE_TYPE = "type__share"; | ||
| 20 | + private static String CHANNEL = "-channel__";//频道 | ||
| 21 | + private static String SID = "-sid__";//用户id | ||
| 22 | + private static String UID = "-uid__";//uuid | ||
| 23 | + private static String PID = "-pid__";//节目id | ||
| 24 | + private static String TITLE = "-title__";//节目名 | ||
| 25 | + private static String TO = "-to__";//分享到哪 | ||
| 26 | + private static String DATA = "-data_"; | ||
| 27 | + | ||
| 28 | + public static String TYPE_WJJ_FRIEND = "wjj_friend"; | ||
| 29 | + public static String TYPE_WJJ_MOMENT = "wjj_moment"; | ||
| 30 | + public static String TYPE_WX_FRIEND = "wx_friend"; | ||
| 31 | + public static String TYPE_WX_MOMENT = "wx_moment"; | ||
| 32 | + public static String TYPE_QQ_FRIEND = "qq_friend"; | ||
| 33 | + public static String TYPE_BROWSER = "browser"; | ||
| 34 | + | ||
| 35 | + public static String DAREN_HOME = "daren"; | ||
| 36 | + public static String APP = "app"; | ||
| 37 | + | ||
| 38 | + private static String shareEventIdBase; | ||
| 39 | + | ||
| 40 | + @Deprecated | ||
| 41 | + public static void Probe_ContentTimes(Context context, String type, String sid, String contentId, String title) { | ||
| 42 | + if (TextUtils.isEmpty(type)) | ||
| 43 | + return; | ||
| 44 | + String eventId = COUNT_TYPE.concat(CHANNEL).concat(type).concat(SID).concat(sid == null ? "" : sid).concat(UID).concat(AppConfig.getAppUUID()).concat(PID).concat(TextUtils.isEmpty(contentId) ? "" : contentId).concat(TITLE).concat(Uri.encode(TextUtils.isEmpty(title) ? "" : title)).concat(DATA); | ||
| 45 | + onEvent(context, eventId); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Deprecated | ||
| 49 | + public static void Probe_ContentDuration(Context context, String type, String sid, String contentId, String title, boolean start) { | ||
| 50 | + if (TextUtils.isEmpty(type)) | ||
| 51 | + return; | ||
| 52 | + String eventId = DURATION_TYPE.concat(CHANNEL).concat(type).concat(SID).concat(sid == null ? "" : sid).concat(UID).concat(AppConfig.getAppUUID()).concat(PID).concat(TextUtils.isEmpty(contentId) ? "" : contentId).concat(TITLE).concat(Uri.encode(TextUtils.isEmpty(title) ? "" : title)).concat(DATA); | ||
| 53 | + if (start) { | ||
| 54 | + onEventBegin(eventId); | ||
| 55 | + } else { | ||
| 56 | + onEventEnd(context, eventId); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Deprecated | ||
| 61 | + public static void Probe_ShareTimes(Context context, String type, String sid, String contentId, String title) { | ||
| 62 | + if (TextUtils.isEmpty(type)) | ||
| 63 | + return; | ||
| 64 | + String eventIdBaseId = SHARE_TYPE.concat(CHANNEL).concat(type).concat(SID).concat(sid == null ? "" : sid).concat(UID).concat(AppConfig.getAppUUID()).concat(PID).concat(TextUtils.isEmpty(contentId) ? "" : contentId).concat(TITLE).concat(Uri.encode(TextUtils.isEmpty(title) ? "" : title)); | ||
| 65 | + setShareEventIdBase(eventIdBaseId); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Deprecated | ||
| 69 | + public static void Probe_ShareTimes_To(Context context, String toType) { | ||
| 70 | + if (TextUtils.isEmpty(getShareEventIdBase())) | ||
| 71 | + return; | ||
| 72 | + String eventId = getShareEventIdBase().concat(TO).concat(TextUtils.isEmpty(toType) ? "" : toType).concat(DATA); | ||
| 73 | + onEvent(context, eventId); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + private static void onEvent(Context context, String eventId) { | ||
| 77 | + try { | ||
| 78 | + Class<?> clazz = Class.forName("com.cnlive.libs.base.analytics.CNLiveProbe"); | ||
| 79 | + Method method = clazz.getMethod("onEvent", Context.class, String.class); | ||
| 80 | + method.invoke(clazz, context, eventId); | ||
| 81 | + } catch (Exception ex) { | ||
| 82 | + Log.d("DebugEvent", "", ex); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + private static void onEventBegin(String eventId) { | ||
| 87 | + try { | ||
| 88 | + Class<?> clazz = Class.forName("com.cnlive.libs.base.analytics.CNLiveProbe"); | ||
| 89 | + Method method = clazz.getMethod("onEventBegin", String.class); | ||
| 90 | + method.invoke(clazz, eventId); | ||
| 91 | + } catch (Exception ex) { | ||
| 92 | + Log.d("DebugEvent", "", ex); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + private static void onEventEnd(Context context, String eventId) { | ||
| 97 | + try { | ||
| 98 | + Class<?> clazz = Class.forName("com.cnlive.libs.base.analytics.CNLiveProbe"); | ||
| 99 | + Method method = clazz.getMethod("onEventEnd", Context.class, String.class); | ||
| 100 | + method.invoke(clazz, context, eventId); | ||
| 101 | + } catch (Exception ex) { | ||
| 102 | + Log.d("DebugEvent", "", ex); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + private static void setShareEventIdBase(String eventIdBase) { | ||
| 108 | + AppProbeUtil.shareEventIdBase = eventIdBase; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + private static String getShareEventIdBase() { | ||
| 112 | + return shareEventIdBase; | ||
| 113 | + } | ||
| 114 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/AppUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.app.ActivityManager; | ||
| 5 | +import android.content.ComponentName; | ||
| 6 | +import android.content.Context; | ||
| 7 | +import android.content.pm.ApplicationInfo; | ||
| 8 | +import android.content.pm.PackageInfo; | ||
| 9 | +import android.content.pm.PackageManager; | ||
| 10 | +import android.text.TextUtils; | ||
| 11 | +import android.util.Log; | ||
| 12 | + | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by gujun on 2017/10/9. | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +public class AppUtil { | ||
| 20 | + | ||
| 21 | + private static final String TAG = "vlion AppUtil"; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 判断某个界面是否在前台 | ||
| 25 | + * | ||
| 26 | + * @param activity 要判断的Activity | ||
| 27 | + * @return 是否在前台显示 | ||
| 28 | + */ | ||
| 29 | + public static boolean isForeground(Activity activity) { | ||
| 30 | + return isForeground(activity, activity.getClass().getName()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 判断某个界面是否在前台 | ||
| 35 | + * | ||
| 36 | + * @param context Context | ||
| 37 | + * @param className 界面的类名 | ||
| 38 | + * @return 是否在前台显示 | ||
| 39 | + */ | ||
| 40 | + public static boolean isForeground(Context context, String className) { | ||
| 41 | + if (context == null || TextUtils.isEmpty(className)) | ||
| 42 | + return false; | ||
| 43 | + ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | ||
| 44 | + List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(1); | ||
| 45 | + if (list != null && list.size() > 0) { | ||
| 46 | + ComponentName cpn = list.get(0).topActivity; | ||
| 47 | + if (className.equals(cpn.getClassName())) | ||
| 48 | + return true; | ||
| 49 | + } | ||
| 50 | + return false; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 获取包名 | ||
| 55 | + * | ||
| 56 | + * @param context | ||
| 57 | + * @return | ||
| 58 | + */ | ||
| 59 | + public static String getPackageName(Context context) { | ||
| 60 | + return context.getPackageName(); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * get App versionName | ||
| 65 | + * | ||
| 66 | + * @param context | ||
| 67 | + * @return | ||
| 68 | + */ | ||
| 69 | + public static String getVersionName(Context context) { | ||
| 70 | + PackageManager packageManager = context.getPackageManager(); | ||
| 71 | + PackageInfo packageInfo; | ||
| 72 | + String versionName = ""; | ||
| 73 | + try { | ||
| 74 | + packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); | ||
| 75 | + versionName = packageInfo.versionName; | ||
| 76 | + } catch (PackageManager.NameNotFoundException e) { | ||
| 77 | + e.printStackTrace(); | ||
| 78 | + } | ||
| 79 | + if (TextUtils.isEmpty(versionName)) { | ||
| 80 | + Log.e(TAG, "getVersionNameError: version name is null"); | ||
| 81 | + } | ||
| 82 | + return versionName; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 判断当前应用是否是debug状态 | ||
| 87 | + */ | ||
| 88 | + public static boolean isApkInDebug(Context context) { | ||
| 89 | + try { | ||
| 90 | + ApplicationInfo info = context.getApplicationInfo(); | ||
| 91 | + return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; | ||
| 92 | + } catch (Exception e) { | ||
| 93 | + return false; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * get App versionName | ||
| 101 | + * | ||
| 102 | + * @param context | ||
| 103 | + * @return | ||
| 104 | + */ | ||
| 105 | + public static int getVersionCode(Context context) { | ||
| 106 | + PackageManager packageManager = context.getPackageManager(); | ||
| 107 | + PackageInfo packageInfo; | ||
| 108 | + int versionCode =-1; | ||
| 109 | + try { | ||
| 110 | + packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); | ||
| 111 | + versionCode = packageInfo.versionCode; | ||
| 112 | + } catch (PackageManager.NameNotFoundException e) { | ||
| 113 | + e.printStackTrace(); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + return versionCode; | ||
| 117 | + } | ||
| 118 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/BaseActivityLifecycle.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.app.Application; | ||
| 5 | +import android.os.Bundle; | ||
| 6 | + | ||
| 7 | +public class BaseActivityLifecycle implements Application.ActivityLifecycleCallbacks { | ||
| 8 | + | ||
| 9 | + private static boolean active = false; | ||
| 10 | + private static int activeCount;//activity的count数 | ||
| 11 | + private static int numRunning; | ||
| 12 | + private static String currentActivityName; | ||
| 13 | + | ||
| 14 | + @Override | ||
| 15 | + public void onActivityCreated(Activity activity, Bundle savedInstanceState) { | ||
| 16 | + currentActivityName = activity.getClass().getName(); | ||
| 17 | + numRunning++; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + @Override | ||
| 21 | + public void onActivityStarted(Activity activity) { | ||
| 22 | + currentActivityName = activity.getClass().getName(); | ||
| 23 | + activeCount++; | ||
| 24 | + if (!active) { | ||
| 25 | + active = true; | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public void onActivityResumed(Activity activity) { | ||
| 31 | + currentActivityName = activity.getClass().getName(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public void onActivityPaused(Activity activity) { | ||
| 36 | +// currentActivity = activity; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void onActivityStopped(Activity activity) { | ||
| 41 | + activeCount--; | ||
| 42 | + if (activeCount == 0 && active) { | ||
| 43 | + active = false; | ||
| 44 | + } | ||
| 45 | +// AnalyticsUtil.appOnStop(activity); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public void onActivitySaveInstanceState(Activity activity, Bundle outState) { | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public void onActivityDestroyed(Activity activity) { | ||
| 54 | +// currentActivity = activity; | ||
| 55 | + numRunning--; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public static int getNumRunning() { | ||
| 59 | + return numRunning; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public static boolean isActive() { | ||
| 63 | + return active; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public static String getCurrentActivityName() { | ||
| 67 | + return currentActivityName; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | +} | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/ChannelUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.content.pm.ApplicationInfo; | ||
| 5 | +import android.content.pm.PackageManager; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.util.Log; | ||
| 8 | + | ||
| 9 | +import com.cnlive.libs.base.application.AppConfig; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Created by xiansong on 2014/12/26. | ||
| 13 | + */ | ||
| 14 | +public class ChannelUtil { | ||
| 15 | + | ||
| 16 | + public static void setChannel(Context context, String channel) { | ||
| 17 | + if (TextUtils.isEmpty(channel)) return; | ||
| 18 | + try { | ||
| 19 | + SharedPreferencesHelper.getInstance(context).setValue("UMENG_CHANNEL", channel); | ||
| 20 | + } catch (Exception ignored) { | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public static String getChannelFromApk(Context context) { | ||
| 25 | + String channel = ""; | ||
| 26 | + String defaultChannel = AppConfig.isDebug() ? "debug" : "release"; | ||
| 27 | + | ||
| 28 | + try { | ||
| 29 | + SharedPreferencesHelper sp = SharedPreferencesHelper.getInstance(context); | ||
| 30 | + String channel_sp = sp.getValue("UMENG_CHANNEL"); | ||
| 31 | + | ||
| 32 | + if (!TextUtils.isEmpty(channel_sp)) return channel_sp; | ||
| 33 | + } catch (Exception e) { | ||
| 34 | + Log.e("ChannelUtil", "", e); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + try { | ||
| 38 | + ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); | ||
| 39 | + channel = appInfo.metaData.getString("UMENG_CHANNEL"); | ||
| 40 | + } catch (Exception e) { | ||
| 41 | + Log.e("ChannelUtil", "", e); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + channel = TextUtils.isEmpty(channel) ? defaultChannel : channel; | ||
| 45 | + Log.e("ChannelUtil", channel); | ||
| 46 | + return channel; | ||
| 47 | + } | ||
| 48 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/DoublePressed.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +public class DoublePressed { | ||
| 4 | + private static long time_pressed; | ||
| 5 | + private static long upload_time; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * 连续点击处理 | ||
| 9 | + * | ||
| 10 | + * @return | ||
| 11 | + */ | ||
| 12 | + public static boolean onDoublePressed() { | ||
| 13 | + return onDoublePressed(false, 2000L); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public static boolean onLongDoublePressed() { | ||
| 17 | + return onDoublePressed(true, 2000L); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public static boolean onDoublePressed(boolean isLong, long time) { | ||
| 21 | + long timeMillis = System.currentTimeMillis(); | ||
| 22 | + boolean doublePressed = time_pressed + time > timeMillis; | ||
| 23 | + | ||
| 24 | + if (isLong) { | ||
| 25 | + time_pressed = timeMillis; | ||
| 26 | + } else if (upload_time < timeMillis) { | ||
| 27 | + upload_time = timeMillis + time; | ||
| 28 | + time_pressed = timeMillis; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + return doublePressed; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public static void onRestart() { | ||
| 35 | + time_pressed = 0; | ||
| 36 | + upload_time = 0; | ||
| 37 | + } | ||
| 38 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/FileUtils.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.os.Environment; | ||
| 5 | + | ||
| 6 | +import java.io.BufferedInputStream; | ||
| 7 | +import java.io.BufferedOutputStream; | ||
| 8 | +import java.io.File; | ||
| 9 | +import java.io.FileFilter; | ||
| 10 | +import java.io.FileInputStream; | ||
| 11 | +import java.io.FileNotFoundException; | ||
| 12 | +import java.io.FileOutputStream; | ||
| 13 | +import java.io.IOException; | ||
| 14 | +import java.io.InputStream; | ||
| 15 | +import java.io.OutputStream; | ||
| 16 | +import java.net.HttpURLConnection; | ||
| 17 | +import java.net.URL; | ||
| 18 | +import java.security.DigestInputStream; | ||
| 19 | +import java.security.MessageDigest; | ||
| 20 | +import java.security.NoSuchAlgorithmException; | ||
| 21 | +import java.util.ArrayList; | ||
| 22 | +import java.util.List; | ||
| 23 | +import java.util.Locale; | ||
| 24 | +/** | ||
| 25 | + * 作者: 吴奎庆 | ||
| 26 | + * <p> | ||
| 27 | + * 时间: 2018/9/11 | ||
| 28 | + * <p> | ||
| 29 | + * 简介: | ||
| 30 | + */ | ||
| 31 | + | ||
| 32 | +public class FileUtils { | ||
| 33 | + | ||
| 34 | + private static final String LINE_SEP = System.getProperty("line.separator"); | ||
| 35 | + | ||
| 36 | + private FileUtils() { | ||
| 37 | + throw new UnsupportedOperationException("u can't instantiate me..."); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Return the file by path. | ||
| 42 | + * | ||
| 43 | + * @param filePath The path of file. | ||
| 44 | + * @return the file | ||
| 45 | + */ | ||
| 46 | + public static File getFileByPath(final String filePath) { | ||
| 47 | + return isSpace(filePath) ? null : new File(filePath); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Return whether the file exists. | ||
| 52 | + * | ||
| 53 | + * @param filePath The path of file. | ||
| 54 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 55 | + */ | ||
| 56 | + public static boolean isFileExists(final String filePath) { | ||
| 57 | + return isFileExists(getFileByPath(filePath)); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Return whether the file exists. | ||
| 62 | + * | ||
| 63 | + * @param file The file. | ||
| 64 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 65 | + */ | ||
| 66 | + public static boolean isFileExists(final File file) { | ||
| 67 | + return file != null && file.exists(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * Rename the file. | ||
| 72 | + * | ||
| 73 | + * @param filePath The path of file. | ||
| 74 | + * @param newName The new name of file. | ||
| 75 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 76 | + */ | ||
| 77 | + public static boolean rename(final String filePath, final String newName) { | ||
| 78 | + return rename(getFileByPath(filePath), newName); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * Rename the file. | ||
| 83 | + * | ||
| 84 | + * @param file The file. | ||
| 85 | + * @param newName The new name of file. | ||
| 86 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 87 | + */ | ||
| 88 | + public static boolean rename(final File file, final String newName) { | ||
| 89 | + // file is null then return false | ||
| 90 | + if (file == null) return false; | ||
| 91 | + // file doesn't exist then return false | ||
| 92 | + if (!file.exists()) return false; | ||
| 93 | + // the new name is space then return false | ||
| 94 | + if (isSpace(newName)) return false; | ||
| 95 | + // the new name equals old name then return true | ||
| 96 | + if (newName.equals(file.getName())) return true; | ||
| 97 | + File newFile = new File(file.getParent() + File.separator + newName); | ||
| 98 | + // the new name of file exists then return false | ||
| 99 | + return !newFile.exists() | ||
| 100 | + && file.renameTo(newFile); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * Return whether it is a directory. | ||
| 105 | + * | ||
| 106 | + * @param dirPath The path of directory. | ||
| 107 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 108 | + */ | ||
| 109 | + public static boolean isDir(final String dirPath) { | ||
| 110 | + return isDir(getFileByPath(dirPath)); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * Return whether it is a directory. | ||
| 115 | + * | ||
| 116 | + * @param file The file. | ||
| 117 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 118 | + */ | ||
| 119 | + public static boolean isDir(final File file) { | ||
| 120 | + return file != null && file.exists() && file.isDirectory(); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * Return whether it is a file. | ||
| 125 | + * | ||
| 126 | + * @param filePath The path of file. | ||
| 127 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 128 | + */ | ||
| 129 | + public static boolean isFile(final String filePath) { | ||
| 130 | + return isFile(getFileByPath(filePath)); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * Return whether it is a file. | ||
| 135 | + * | ||
| 136 | + * @param file The file. | ||
| 137 | + * @return {@code true}: yes<br>{@code false}: no | ||
| 138 | + */ | ||
| 139 | + public static boolean isFile(final File file) { | ||
| 140 | + return file != null && file.exists() && file.isFile(); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Create a directory if it doesn't exist, otherwise do nothing. | ||
| 145 | + * 如果不存在创建文件夹 存在就不处理 | ||
| 146 | + * @param dirPath The path of directory. | ||
| 147 | + * @return {@code true}: exists or creates successfully<br>{@code false}: otherwise | ||
| 148 | + */ | ||
| 149 | + public static boolean createOrExistsDir(final String dirPath) { | ||
| 150 | + return createOrExistsDir(getFileByPath(dirPath)); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * Create a directory if it doesn't exist, otherwise do nothing. | ||
| 155 | + * | ||
| 156 | + * @param file The file. | ||
| 157 | + * @return {@code true}: exists or creates successfully<br>{@code false}: otherwise | ||
| 158 | + */ | ||
| 159 | + public static boolean createOrExistsDir(final File file) { | ||
| 160 | + return file != null && (file.exists() ? file.isDirectory() : file.mkdirs()); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * Create a file if it doesn't exist, otherwise do nothing. | ||
| 165 | + * | ||
| 166 | + * @param filePath The path of file. | ||
| 167 | + * @return {@code true}: exists or creates successfully<br>{@code false}: otherwise | ||
| 168 | + */ | ||
| 169 | + public static boolean createOrExistsFile(final String filePath) { | ||
| 170 | + return createOrExistsFile(getFileByPath(filePath)); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * Create a file if it doesn't exist, otherwise do nothing. | ||
| 175 | + * | ||
| 176 | + * @param file The file. | ||
| 177 | + * @return {@code true}: exists or creates successfully<br>{@code false}: otherwise | ||
| 178 | + */ | ||
| 179 | + public static boolean createOrExistsFile(final File file) { | ||
| 180 | + if (file == null) return false; | ||
| 181 | + if (file.exists()) return file.isFile(); | ||
| 182 | + if (!createOrExistsDir(file.getParentFile())) return false; | ||
| 183 | + try { | ||
| 184 | + return file.createNewFile(); | ||
| 185 | + } catch (IOException e) { | ||
| 186 | + e.printStackTrace(); | ||
| 187 | + return false; | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + /** | ||
| 192 | + * Create a file if it doesn't exist, otherwise delete old file before creating. | ||
| 193 | + * | ||
| 194 | + * @param filePath The path of file. | ||
| 195 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 196 | + */ | ||
| 197 | + public static boolean createFileByDeleteOldFile(final String filePath) { | ||
| 198 | + return createFileByDeleteOldFile(getFileByPath(filePath)); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + * Create a file if it doesn't exist, otherwise delete old file before creating. | ||
| 203 | + * | ||
| 204 | + * @param file The file. | ||
| 205 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 206 | + */ | ||
| 207 | + public static boolean createFileByDeleteOldFile(final File file) { | ||
| 208 | + if (file == null) return false; | ||
| 209 | + // file exists and unsuccessfully delete then return false | ||
| 210 | + if (file.exists() && !file.delete()) return false; | ||
| 211 | + if (!createOrExistsDir(file.getParentFile())) return false; | ||
| 212 | + try { | ||
| 213 | + return file.createNewFile(); | ||
| 214 | + } catch (IOException e) { | ||
| 215 | + e.printStackTrace(); | ||
| 216 | + return false; | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + /** | ||
| 221 | + * Copy the directory. | ||
| 222 | + * | ||
| 223 | + * @param srcDirPath The path of source directory. | ||
| 224 | + * @param destDirPath The path of destination directory. | ||
| 225 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 226 | + */ | ||
| 227 | + public static boolean copyDir(final String srcDirPath, | ||
| 228 | + final String destDirPath) { | ||
| 229 | + return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath)); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + /** | ||
| 233 | + * Copy the directory. | ||
| 234 | + * | ||
| 235 | + * @param srcDirPath The path of source directory. | ||
| 236 | + * @param destDirPath The path of destination directory. | ||
| 237 | + * @param listener The replace listener. | ||
| 238 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 239 | + */ | ||
| 240 | + public static boolean copyDir(final String srcDirPath, | ||
| 241 | + final String destDirPath, | ||
| 242 | + final OnReplaceListener listener) { | ||
| 243 | + return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), listener); | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + /** | ||
| 247 | + * Copy the directory. | ||
| 248 | + * | ||
| 249 | + * @param srcDir The source directory. | ||
| 250 | + * @param destDir The destination directory. | ||
| 251 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 252 | + */ | ||
| 253 | + public static boolean copyDir(final File srcDir, | ||
| 254 | + final File destDir) { | ||
| 255 | + return copyOrMoveDir(srcDir, destDir, false); | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + /** | ||
| 259 | + * Copy the directory. | ||
| 260 | + * | ||
| 261 | + * @param srcDir The source directory. | ||
| 262 | + * @param destDir The destination directory. | ||
| 263 | + * @param listener The replace listener. | ||
| 264 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 265 | + */ | ||
| 266 | + public static boolean copyDir(final File srcDir, | ||
| 267 | + final File destDir, | ||
| 268 | + final OnReplaceListener listener) { | ||
| 269 | + return copyOrMoveDir(srcDir, destDir, listener, false); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * Copy the file. | ||
| 274 | + * | ||
| 275 | + * @param srcFilePath The path of source file. | ||
| 276 | + * @param destFilePath The path of destination file. | ||
| 277 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 278 | + */ | ||
| 279 | + public static boolean copyFile(final String srcFilePath, | ||
| 280 | + final String destFilePath) { | ||
| 281 | + return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath)); | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + /** | ||
| 285 | + * Copy the file. | ||
| 286 | + * | ||
| 287 | + * @param srcFilePath The path of source file. | ||
| 288 | + * @param destFilePath The path of destination file. | ||
| 289 | + * @param listener The replace listener. | ||
| 290 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 291 | + */ | ||
| 292 | + public static boolean copyFile(final String srcFilePath, | ||
| 293 | + final String destFilePath, | ||
| 294 | + final OnReplaceListener listener) { | ||
| 295 | + return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), listener); | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + /** | ||
| 299 | + * Copy the file. | ||
| 300 | + * | ||
| 301 | + * @param srcFile The source file. | ||
| 302 | + * @param destFile The destination file. | ||
| 303 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 304 | + */ | ||
| 305 | + public static boolean copyFile(final File srcFile, | ||
| 306 | + final File destFile) { | ||
| 307 | + return copyOrMoveFile(srcFile, destFile, false); | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + | ||
| 311 | + public static File getSaveFile(Context context, String fileName) { | ||
| 312 | + File file = new File(context.getFilesDir(), fileName + ".jpg"); | ||
| 313 | + return file; | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + /** | ||
| 317 | + * Copy the file. | ||
| 318 | + * | ||
| 319 | + * @param srcFile The source file. | ||
| 320 | + * @param destFile The destination file. | ||
| 321 | + * @param listener The replace listener. | ||
| 322 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 323 | + */ | ||
| 324 | + public static boolean copyFile(final File srcFile, | ||
| 325 | + final File destFile, | ||
| 326 | + final OnReplaceListener listener) { | ||
| 327 | + return copyOrMoveFile(srcFile, destFile, listener, false); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + /** | ||
| 331 | + * Move the directory. | ||
| 332 | + * | ||
| 333 | + * @param srcDirPath The path of source directory. | ||
| 334 | + * @param destDirPath The path of destination directory. | ||
| 335 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 336 | + */ | ||
| 337 | + public static boolean moveDir(final String srcDirPath, | ||
| 338 | + final String destDirPath) { | ||
| 339 | + return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath)); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + /** | ||
| 343 | + * Move the directory. | ||
| 344 | + * | ||
| 345 | + * @param srcDirPath The path of source directory. | ||
| 346 | + * @param destDirPath The path of destination directory. | ||
| 347 | + * @param listener The replace listener. | ||
| 348 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 349 | + */ | ||
| 350 | + public static boolean moveDir(final String srcDirPath, | ||
| 351 | + final String destDirPath, | ||
| 352 | + final OnReplaceListener listener) { | ||
| 353 | + return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), listener); | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + /** | ||
| 357 | + * Move the directory. | ||
| 358 | + * | ||
| 359 | + * @param srcDir The source directory. | ||
| 360 | + * @param destDir The destination directory. | ||
| 361 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 362 | + */ | ||
| 363 | + public static boolean moveDir(final File srcDir, | ||
| 364 | + final File destDir) { | ||
| 365 | + return copyOrMoveDir(srcDir, destDir, true); | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + /** | ||
| 369 | + * Move the directory. | ||
| 370 | + * | ||
| 371 | + * @param srcDir The source directory. | ||
| 372 | + * @param destDir The destination directory. | ||
| 373 | + * @param listener The replace listener. | ||
| 374 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 375 | + */ | ||
| 376 | + public static boolean moveDir(final File srcDir, | ||
| 377 | + final File destDir, | ||
| 378 | + final OnReplaceListener listener) { | ||
| 379 | + return copyOrMoveDir(srcDir, destDir, listener, true); | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + /** | ||
| 383 | + * Move the file. | ||
| 384 | + * | ||
| 385 | + * @param srcFilePath The path of source file. | ||
| 386 | + * @param destFilePath The path of destination file. | ||
| 387 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 388 | + */ | ||
| 389 | + public static boolean moveFile(final String srcFilePath, | ||
| 390 | + final String destFilePath) { | ||
| 391 | + return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath)); | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + /** | ||
| 395 | + * Move the file. | ||
| 396 | + * | ||
| 397 | + * @param srcFilePath The path of source file. | ||
| 398 | + * @param destFilePath The path of destination file. | ||
| 399 | + * @param listener The replace listener. | ||
| 400 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 401 | + */ | ||
| 402 | + public static boolean moveFile(final String srcFilePath, | ||
| 403 | + final String destFilePath, | ||
| 404 | + final OnReplaceListener listener) { | ||
| 405 | + return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), listener); | ||
| 406 | + } | ||
| 407 | + | ||
| 408 | + /** | ||
| 409 | + * Move the file. | ||
| 410 | + * | ||
| 411 | + * @param srcFile The source file. | ||
| 412 | + * @param destFile The destination file. | ||
| 413 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 414 | + */ | ||
| 415 | + public static boolean moveFile(final File srcFile, | ||
| 416 | + final File destFile) { | ||
| 417 | + return copyOrMoveFile(srcFile, destFile, true); | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + /** | ||
| 421 | + * Move the file. | ||
| 422 | + * | ||
| 423 | + * @param srcFile The source file. | ||
| 424 | + * @param destFile The destination file. | ||
| 425 | + * @param listener The replace listener. | ||
| 426 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 427 | + */ | ||
| 428 | + public static boolean moveFile(final File srcFile, | ||
| 429 | + final File destFile, | ||
| 430 | + final OnReplaceListener listener) { | ||
| 431 | + return copyOrMoveFile(srcFile, destFile, listener, true); | ||
| 432 | + } | ||
| 433 | + | ||
| 434 | + private static boolean copyOrMoveDir(final File srcDir, | ||
| 435 | + final File destDir, | ||
| 436 | + final boolean isMove) { | ||
| 437 | + return copyOrMoveDir(srcDir, destDir, new OnReplaceListener() { | ||
| 438 | + @Override | ||
| 439 | + public boolean onReplace() { | ||
| 440 | + return true; | ||
| 441 | + } | ||
| 442 | + }, isMove); | ||
| 443 | + } | ||
| 444 | + | ||
| 445 | + private static boolean copyOrMoveDir(final File srcDir, | ||
| 446 | + final File destDir, | ||
| 447 | + final OnReplaceListener listener, | ||
| 448 | + final boolean isMove) { | ||
| 449 | + if (srcDir == null || destDir == null) return false; | ||
| 450 | + // destDir's path locate in srcDir's path then return false | ||
| 451 | + String srcPath = srcDir.getPath() + File.separator; | ||
| 452 | + String destPath = destDir.getPath() + File.separator; | ||
| 453 | + if (destPath.contains(srcPath)) return false; | ||
| 454 | + if (!srcDir.exists() || !srcDir.isDirectory()) return false; | ||
| 455 | + if (destDir.exists()) { | ||
| 456 | + if (listener == null || listener.onReplace()) {// require delete the old directory | ||
| 457 | + if (!deleteAllInDir(destDir)) {// unsuccessfully delete then return false | ||
| 458 | + return false; | ||
| 459 | + } | ||
| 460 | + } else { | ||
| 461 | + return true; | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + if (!createOrExistsDir(destDir)) return false; | ||
| 465 | + File[] files = srcDir.listFiles(); | ||
| 466 | + for (File file : files) { | ||
| 467 | + File oneDestFile = new File(destPath + file.getName()); | ||
| 468 | + if (file.isFile()) { | ||
| 469 | + if (!copyOrMoveFile(file, oneDestFile, listener, isMove)) return false; | ||
| 470 | + } else if (file.isDirectory()) { | ||
| 471 | + if (!copyOrMoveDir(file, oneDestFile, listener, isMove)) return false; | ||
| 472 | + } | ||
| 473 | + } | ||
| 474 | + return !isMove || deleteDir(srcDir); | ||
| 475 | + } | ||
| 476 | + | ||
| 477 | + private static boolean copyOrMoveFile(final File srcFile, | ||
| 478 | + final File destFile, | ||
| 479 | + final boolean isMove) { | ||
| 480 | + return copyOrMoveFile(srcFile, destFile, new OnReplaceListener() { | ||
| 481 | + @Override | ||
| 482 | + public boolean onReplace() { | ||
| 483 | + return true; | ||
| 484 | + } | ||
| 485 | + }, isMove); | ||
| 486 | + } | ||
| 487 | + | ||
| 488 | + private static boolean copyOrMoveFile(final File srcFile, | ||
| 489 | + final File destFile, | ||
| 490 | + final OnReplaceListener listener, | ||
| 491 | + final boolean isMove) { | ||
| 492 | + if (srcFile == null || destFile == null) return false; | ||
| 493 | + // srcFile equals destFile then return false | ||
| 494 | + if (srcFile.equals(destFile)) return false; | ||
| 495 | + // srcFile doesn't exist or isn't a file then return false | ||
| 496 | + if (!srcFile.exists() || !srcFile.isFile()) return false; | ||
| 497 | + if (destFile.exists()) { | ||
| 498 | + if (listener == null || listener.onReplace()) {// require delete the old file | ||
| 499 | + if (!destFile.delete()) {// unsuccessfully delete then return false | ||
| 500 | + return false; | ||
| 501 | + } | ||
| 502 | + } else { | ||
| 503 | + return true; | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + if (!createOrExistsDir(destFile.getParentFile())) return false; | ||
| 507 | + try { | ||
| 508 | + return writeFileFromIS(destFile, new FileInputStream(srcFile)) | ||
| 509 | + && !(isMove && !deleteFile(srcFile)); | ||
| 510 | + } catch (FileNotFoundException e) { | ||
| 511 | + e.printStackTrace(); | ||
| 512 | + return false; | ||
| 513 | + } | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + /** | ||
| 517 | + * Delete the directory. | ||
| 518 | + * | ||
| 519 | + * @param dirPath The path of directory. | ||
| 520 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 521 | + */ | ||
| 522 | + public static boolean deleteDir(final String dirPath) { | ||
| 523 | + return deleteDir(getFileByPath(dirPath)); | ||
| 524 | + } | ||
| 525 | + | ||
| 526 | + /** | ||
| 527 | + * Delete the directory. | ||
| 528 | + * | ||
| 529 | + * @param dir The directory. | ||
| 530 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 531 | + */ | ||
| 532 | + public static boolean deleteDir(final File dir) { | ||
| 533 | + if (dir == null) return false; | ||
| 534 | + // dir doesn't exist then return true | ||
| 535 | + if (!dir.exists()) return true; | ||
| 536 | + // dir isn't a directory then return false | ||
| 537 | + if (!dir.isDirectory()) return false; | ||
| 538 | + File[] files = dir.listFiles(); | ||
| 539 | + if (files != null && files.length != 0) { | ||
| 540 | + for (File file : files) { | ||
| 541 | + if (file.isFile()) { | ||
| 542 | + if (!file.delete()) return false; | ||
| 543 | + } else if (file.isDirectory()) { | ||
| 544 | + if (!deleteDir(file)) return false; | ||
| 545 | + } | ||
| 546 | + } | ||
| 547 | + } | ||
| 548 | + return dir.delete(); | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + /** | ||
| 552 | + * Delete the file. | ||
| 553 | + * | ||
| 554 | + * @param srcFilePath The path of source file. | ||
| 555 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 556 | + */ | ||
| 557 | + public static boolean deleteFile(final String srcFilePath) { | ||
| 558 | + return deleteFile(getFileByPath(srcFilePath)); | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + /** | ||
| 562 | + * Delete the file. | ||
| 563 | + * | ||
| 564 | + * @param file The file. | ||
| 565 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 566 | + */ | ||
| 567 | + public static boolean deleteFile(final File file) { | ||
| 568 | + return file != null && (!file.exists() || file.isFile() && file.delete()); | ||
| 569 | + } | ||
| 570 | + | ||
| 571 | + /** | ||
| 572 | + * Delete the all in directory. | ||
| 573 | + * | ||
| 574 | + * @param dirPath The path of directory. | ||
| 575 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 576 | + */ | ||
| 577 | + public static boolean deleteAllInDir(final String dirPath) { | ||
| 578 | + return deleteAllInDir(getFileByPath(dirPath)); | ||
| 579 | + } | ||
| 580 | + | ||
| 581 | + /** | ||
| 582 | + * Delete the all in directory. | ||
| 583 | + * | ||
| 584 | + * @param dir The directory. | ||
| 585 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 586 | + */ | ||
| 587 | + public static boolean deleteAllInDir(final File dir) { | ||
| 588 | + return deleteFilesInDirWithFilter(dir, new FileFilter() { | ||
| 589 | + @Override | ||
| 590 | + public boolean accept(File pathname) { | ||
| 591 | + return true; | ||
| 592 | + } | ||
| 593 | + }); | ||
| 594 | + } | ||
| 595 | + | ||
| 596 | + /** | ||
| 597 | + * Delete all files in directory. | ||
| 598 | + * | ||
| 599 | + * @param dirPath The path of directory. | ||
| 600 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 601 | + */ | ||
| 602 | + public static boolean deleteFilesInDir(final String dirPath) { | ||
| 603 | + return deleteFilesInDir(getFileByPath(dirPath)); | ||
| 604 | + } | ||
| 605 | + | ||
| 606 | + /** | ||
| 607 | + * Delete all files in directory. | ||
| 608 | + * | ||
| 609 | + * @param dir The directory. | ||
| 610 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 611 | + */ | ||
| 612 | + public static boolean deleteFilesInDir(final File dir) { | ||
| 613 | + return deleteFilesInDirWithFilter(dir, new FileFilter() { | ||
| 614 | + @Override | ||
| 615 | + public boolean accept(File pathname) { | ||
| 616 | + return pathname.isFile(); | ||
| 617 | + } | ||
| 618 | + }); | ||
| 619 | + } | ||
| 620 | + | ||
| 621 | + /** | ||
| 622 | + * Delete all files that satisfy the filter in directory. | ||
| 623 | + * | ||
| 624 | + * @param dirPath The path of directory. | ||
| 625 | + * @param filter The filter. | ||
| 626 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 627 | + */ | ||
| 628 | + public static boolean deleteFilesInDirWithFilter(final String dirPath, | ||
| 629 | + final FileFilter filter) { | ||
| 630 | + return deleteFilesInDirWithFilter(getFileByPath(dirPath), filter); | ||
| 631 | + } | ||
| 632 | + | ||
| 633 | + /** | ||
| 634 | + * Delete all files that satisfy the filter in directory. | ||
| 635 | + * | ||
| 636 | + * @param dir The directory. | ||
| 637 | + * @param filter The filter. | ||
| 638 | + * @return {@code true}: success<br>{@code false}: fail | ||
| 639 | + */ | ||
| 640 | + public static boolean deleteFilesInDirWithFilter(final File dir, final FileFilter filter) { | ||
| 641 | + if (dir == null) return false; | ||
| 642 | + // dir doesn't exist then return true | ||
| 643 | + if (!dir.exists()) return true; | ||
| 644 | + // dir isn't a directory then return false | ||
| 645 | + if (!dir.isDirectory()) return false; | ||
| 646 | + File[] files = dir.listFiles(); | ||
| 647 | + if (files != null && files.length != 0) { | ||
| 648 | + for (File file : files) { | ||
| 649 | + if (filter.accept(file)) { | ||
| 650 | + if (file.isFile()) { | ||
| 651 | + if (!file.delete()) return false; | ||
| 652 | + } else if (file.isDirectory()) { | ||
| 653 | + if (!deleteDir(file)) return false; | ||
| 654 | + } | ||
| 655 | + } | ||
| 656 | + } | ||
| 657 | + } | ||
| 658 | + return true; | ||
| 659 | + } | ||
| 660 | + | ||
| 661 | + /** | ||
| 662 | + * Return the files in directory. | ||
| 663 | + * <p>Doesn't traverse subdirectories</p> | ||
| 664 | + * | ||
| 665 | + * @param dirPath The path of directory. | ||
| 666 | + * @return the files in directory | ||
| 667 | + */ | ||
| 668 | + public static List<File> listFilesInDir(final String dirPath) { | ||
| 669 | + return listFilesInDir(dirPath, false); | ||
| 670 | + } | ||
| 671 | + | ||
| 672 | + /** | ||
| 673 | + * Return the files in directory. | ||
| 674 | + * <p>Doesn't traverse subdirectories</p> | ||
| 675 | + * | ||
| 676 | + * @param dir The directory. | ||
| 677 | + * @return the files in directory | ||
| 678 | + */ | ||
| 679 | + public static List<File> listFilesInDir(final File dir) { | ||
| 680 | + return listFilesInDir(dir, false); | ||
| 681 | + } | ||
| 682 | + | ||
| 683 | + /** | ||
| 684 | + * Return the files in directory. | ||
| 685 | + * | ||
| 686 | + * @param dirPath The path of directory. | ||
| 687 | + * @param isRecursive True to traverse subdirectories, false otherwise. | ||
| 688 | + * @return the files in directory | ||
| 689 | + */ | ||
| 690 | + public static List<File> listFilesInDir(final String dirPath, final boolean isRecursive) { | ||
| 691 | + return listFilesInDir(getFileByPath(dirPath), isRecursive); | ||
| 692 | + } | ||
| 693 | + | ||
| 694 | + /** | ||
| 695 | + * Return the files in directory. | ||
| 696 | + * | ||
| 697 | + * @param dir The directory. | ||
| 698 | + * @param isRecursive True to traverse subdirectories, false otherwise. | ||
| 699 | + * @return the files in directory | ||
| 700 | + */ | ||
| 701 | + public static List<File> listFilesInDir(final File dir, final boolean isRecursive) { | ||
| 702 | + return listFilesInDirWithFilter(dir, new FileFilter() { | ||
| 703 | + @Override | ||
| 704 | + public boolean accept(File pathname) { | ||
| 705 | + return true; | ||
| 706 | + } | ||
| 707 | + }, isRecursive); | ||
| 708 | + } | ||
| 709 | + | ||
| 710 | + /** | ||
| 711 | + * Return the files that satisfy the filter in directory. | ||
| 712 | + * <p>Doesn't traverse subdirectories</p> | ||
| 713 | + * | ||
| 714 | + * @param dirPath The path of directory. | ||
| 715 | + * @param filter The filter. | ||
| 716 | + * @return the files that satisfy the filter in directory | ||
| 717 | + */ | ||
| 718 | + public static List<File> listFilesInDirWithFilter(final String dirPath, | ||
| 719 | + final FileFilter filter) { | ||
| 720 | + return listFilesInDirWithFilter(getFileByPath(dirPath), filter, false); | ||
| 721 | + } | ||
| 722 | + | ||
| 723 | + /** | ||
| 724 | + * Return the files that satisfy the filter in directory. | ||
| 725 | + * <p>Doesn't traverse subdirectories</p> | ||
| 726 | + * | ||
| 727 | + * @param dir The directory. | ||
| 728 | + * @param filter The filter. | ||
| 729 | + * @return the files that satisfy the filter in directory | ||
| 730 | + */ | ||
| 731 | + public static List<File> listFilesInDirWithFilter(final File dir, | ||
| 732 | + final FileFilter filter) { | ||
| 733 | + return listFilesInDirWithFilter(dir, filter, false); | ||
| 734 | + } | ||
| 735 | + | ||
| 736 | + /** | ||
| 737 | + * Return the files that satisfy the filter in directory. | ||
| 738 | + * | ||
| 739 | + * @param dirPath The path of directory. | ||
| 740 | + * @param filter The filter. | ||
| 741 | + * @param isRecursive True to traverse subdirectories, false otherwise. | ||
| 742 | + * @return the files that satisfy the filter in directory | ||
| 743 | + */ | ||
| 744 | + public static List<File> listFilesInDirWithFilter(final String dirPath, | ||
| 745 | + final FileFilter filter, | ||
| 746 | + final boolean isRecursive) { | ||
| 747 | + return listFilesInDirWithFilter(getFileByPath(dirPath), filter, isRecursive); | ||
| 748 | + } | ||
| 749 | + | ||
| 750 | + /** | ||
| 751 | + * Return the files that satisfy the filter in directory. | ||
| 752 | + * | ||
| 753 | + * @param dir The directory. | ||
| 754 | + * @param filter The filter. | ||
| 755 | + * @param isRecursive True to traverse subdirectories, false otherwise. | ||
| 756 | + * @return the files that satisfy the filter in directory | ||
| 757 | + */ | ||
| 758 | + public static List<File> listFilesInDirWithFilter(final File dir, | ||
| 759 | + final FileFilter filter, | ||
| 760 | + final boolean isRecursive) { | ||
| 761 | + if (!isDir(dir)) return null; | ||
| 762 | + List<File> list = new ArrayList<>(); | ||
| 763 | + File[] files = dir.listFiles(); | ||
| 764 | + if (files != null && files.length != 0) { | ||
| 765 | + for (File file : files) { | ||
| 766 | + if (filter.accept(file)) { | ||
| 767 | + list.add(file); | ||
| 768 | + } | ||
| 769 | + if (isRecursive && file.isDirectory()) { | ||
| 770 | + //noinspection ConstantConditions | ||
| 771 | + list.addAll(listFilesInDirWithFilter(file, filter, true)); | ||
| 772 | + } | ||
| 773 | + } | ||
| 774 | + } | ||
| 775 | + return list; | ||
| 776 | + } | ||
| 777 | + | ||
| 778 | + /** | ||
| 779 | + * Return the time that the file was last modified. | ||
| 780 | + * | ||
| 781 | + * @param filePath The path of file. | ||
| 782 | + * @return the time that the file was last modified | ||
| 783 | + */ | ||
| 784 | + | ||
| 785 | + public static long getFileLastModified(final String filePath) { | ||
| 786 | + return getFileLastModified(getFileByPath(filePath)); | ||
| 787 | + } | ||
| 788 | + | ||
| 789 | + /** | ||
| 790 | + * Return the time that the file was last modified. | ||
| 791 | + * | ||
| 792 | + * @param file The file. | ||
| 793 | + * @return the time that the file was last modified | ||
| 794 | + */ | ||
| 795 | + public static long getFileLastModified(final File file) { | ||
| 796 | + if (file == null) return -1; | ||
| 797 | + return file.lastModified(); | ||
| 798 | + } | ||
| 799 | + | ||
| 800 | + /** | ||
| 801 | + * Return the charset of file simply. | ||
| 802 | + * | ||
| 803 | + * @param filePath The path of file. | ||
| 804 | + * @return the charset of file simply | ||
| 805 | + */ | ||
| 806 | + public static String getFileCharsetSimple(final String filePath) { | ||
| 807 | + return getFileCharsetSimple(getFileByPath(filePath)); | ||
| 808 | + } | ||
| 809 | + | ||
| 810 | + /** | ||
| 811 | + * Return the charset of file simply. | ||
| 812 | + * | ||
| 813 | + * @param file The file. | ||
| 814 | + * @return the charset of file simply | ||
| 815 | + */ | ||
| 816 | + public static String getFileCharsetSimple(final File file) { | ||
| 817 | + int p = 0; | ||
| 818 | + InputStream is = null; | ||
| 819 | + try { | ||
| 820 | + is = new BufferedInputStream(new FileInputStream(file)); | ||
| 821 | + p = (is.read() << 8) + is.read(); | ||
| 822 | + } catch (IOException e) { | ||
| 823 | + e.printStackTrace(); | ||
| 824 | + } finally { | ||
| 825 | + try { | ||
| 826 | + if (is != null) { | ||
| 827 | + is.close(); | ||
| 828 | + } | ||
| 829 | + } catch (IOException e) { | ||
| 830 | + e.printStackTrace(); | ||
| 831 | + } | ||
| 832 | + } | ||
| 833 | + switch (p) { | ||
| 834 | + case 0xefbb: | ||
| 835 | + return "UTF-8"; | ||
| 836 | + case 0xfffe: | ||
| 837 | + return "Unicode"; | ||
| 838 | + case 0xfeff: | ||
| 839 | + return "UTF-16BE"; | ||
| 840 | + default: | ||
| 841 | + return "GBK"; | ||
| 842 | + } | ||
| 843 | + } | ||
| 844 | + | ||
| 845 | + /** | ||
| 846 | + * Return the number of lines of file. | ||
| 847 | + * | ||
| 848 | + * @param filePath The path of file. | ||
| 849 | + * @return the number of lines of file | ||
| 850 | + */ | ||
| 851 | + public static int getFileLines(final String filePath) { | ||
| 852 | + return getFileLines(getFileByPath(filePath)); | ||
| 853 | + } | ||
| 854 | + | ||
| 855 | + /** | ||
| 856 | + * Return the number of lines of file. | ||
| 857 | + * | ||
| 858 | + * @param file The file. | ||
| 859 | + * @return the number of lines of file | ||
| 860 | + */ | ||
| 861 | + public static int getFileLines(final File file) { | ||
| 862 | + int count = 1; | ||
| 863 | + InputStream is = null; | ||
| 864 | + try { | ||
| 865 | + is = new BufferedInputStream(new FileInputStream(file)); | ||
| 866 | + byte[] buffer = new byte[1024]; | ||
| 867 | + int readChars; | ||
| 868 | + if (LINE_SEP.endsWith("\n")) { | ||
| 869 | + while ((readChars = is.read(buffer, 0, 1024)) != -1) { | ||
| 870 | + for (int i = 0; i < readChars; ++i) { | ||
| 871 | + if (buffer[i] == '\n') ++count; | ||
| 872 | + } | ||
| 873 | + } | ||
| 874 | + } else { | ||
| 875 | + while ((readChars = is.read(buffer, 0, 1024)) != -1) { | ||
| 876 | + for (int i = 0; i < readChars; ++i) { | ||
| 877 | + if (buffer[i] == '\r') ++count; | ||
| 878 | + } | ||
| 879 | + } | ||
| 880 | + } | ||
| 881 | + } catch (IOException e) { | ||
| 882 | + e.printStackTrace(); | ||
| 883 | + } finally { | ||
| 884 | + try { | ||
| 885 | + if (is != null) { | ||
| 886 | + is.close(); | ||
| 887 | + } | ||
| 888 | + } catch (IOException e) { | ||
| 889 | + e.printStackTrace(); | ||
| 890 | + } | ||
| 891 | + } | ||
| 892 | + return count; | ||
| 893 | + } | ||
| 894 | + | ||
| 895 | + /** | ||
| 896 | + * Return the size of directory. | ||
| 897 | + * | ||
| 898 | + * @param dirPath The path of directory. | ||
| 899 | + * @return the size of directory | ||
| 900 | + */ | ||
| 901 | + public static String getDirSize(final String dirPath) { | ||
| 902 | + return getDirSize(getFileByPath(dirPath)); | ||
| 903 | + } | ||
| 904 | + | ||
| 905 | + /** | ||
| 906 | + * Return the size of directory. | ||
| 907 | + * | ||
| 908 | + * @param dir The directory. | ||
| 909 | + * @return the size of directory | ||
| 910 | + */ | ||
| 911 | + public static String getDirSize(final File dir) { | ||
| 912 | + long len = getDirLength(dir); | ||
| 913 | + return len == -1 ? "" : byte2FitMemorySize(len); | ||
| 914 | + } | ||
| 915 | + | ||
| 916 | + /** | ||
| 917 | + * Return the length of file. | ||
| 918 | + * | ||
| 919 | + * @param filePath The path of file. | ||
| 920 | + * @return the length of file | ||
| 921 | + */ | ||
| 922 | + public static String getFileSize(final String filePath) { | ||
| 923 | + long len = getFileLength(filePath); | ||
| 924 | + return len == -1 ? "" : byte2FitMemorySize(len); | ||
| 925 | + } | ||
| 926 | + | ||
| 927 | + /** | ||
| 928 | + * Return the length of file. | ||
| 929 | + * | ||
| 930 | + * @param file The file. | ||
| 931 | + * @return the length of file | ||
| 932 | + */ | ||
| 933 | + public static String getFileSize(final File file) { | ||
| 934 | + long len = getFileLength(file); | ||
| 935 | + return len == -1 ? "" : byte2FitMemorySize(len); | ||
| 936 | + } | ||
| 937 | + | ||
| 938 | + /** | ||
| 939 | + * Return the length of directory. | ||
| 940 | + * | ||
| 941 | + * @param dirPath The path of directory. | ||
| 942 | + * @return the length of directory | ||
| 943 | + */ | ||
| 944 | + public static long getDirLength(final String dirPath) { | ||
| 945 | + return getDirLength(getFileByPath(dirPath)); | ||
| 946 | + } | ||
| 947 | + | ||
| 948 | + /** | ||
| 949 | + * Return the length of directory. | ||
| 950 | + * | ||
| 951 | + * @param dir The directory. | ||
| 952 | + * @return the length of directory | ||
| 953 | + */ | ||
| 954 | + public static long getDirLength(final File dir) { | ||
| 955 | + if (!isDir(dir)) return -1; | ||
| 956 | + long len = 0; | ||
| 957 | + File[] files = dir.listFiles(); | ||
| 958 | + if (files != null && files.length != 0) { | ||
| 959 | + for (File file : files) { | ||
| 960 | + if (file.isDirectory()) { | ||
| 961 | + len += getDirLength(file); | ||
| 962 | + } else { | ||
| 963 | + len += file.length(); | ||
| 964 | + } | ||
| 965 | + } | ||
| 966 | + } | ||
| 967 | + return len; | ||
| 968 | + } | ||
| 969 | + | ||
| 970 | + /** | ||
| 971 | + * Return the length of file. | ||
| 972 | + * | ||
| 973 | + * @param filePath The path of file. | ||
| 974 | + * @return the length of file | ||
| 975 | + */ | ||
| 976 | + public static long getFileLength(final String filePath) { | ||
| 977 | + boolean isURL = filePath.matches("[a-zA-z]+://[^\\s]*"); | ||
| 978 | + if (isURL) { | ||
| 979 | + try { | ||
| 980 | + HttpURLConnection conn = (HttpURLConnection) new URL(filePath).openConnection(); | ||
| 981 | + conn.setRequestProperty("Accept-Encoding", "identity"); | ||
| 982 | + conn.connect(); | ||
| 983 | + if (conn.getResponseCode() == 200) { | ||
| 984 | + return conn.getContentLength(); | ||
| 985 | + } | ||
| 986 | + return -1; | ||
| 987 | + } catch (IOException e) { | ||
| 988 | + e.printStackTrace(); | ||
| 989 | + } | ||
| 990 | + } | ||
| 991 | + return getFileLength(getFileByPath(filePath)); | ||
| 992 | + } | ||
| 993 | + | ||
| 994 | + /** | ||
| 995 | + * Return the length of file. | ||
| 996 | + * | ||
| 997 | + * @param file The file. | ||
| 998 | + * @return the length of file | ||
| 999 | + */ | ||
| 1000 | + public static long getFileLength(final File file) { | ||
| 1001 | + if (!isFile(file)) return -1; | ||
| 1002 | + return file.length(); | ||
| 1003 | + } | ||
| 1004 | + | ||
| 1005 | + /** | ||
| 1006 | + * Return the MD5 of file. | ||
| 1007 | + * | ||
| 1008 | + * @param filePath The path of file. | ||
| 1009 | + * @return the md5 of file | ||
| 1010 | + */ | ||
| 1011 | + public static String getFileMD5ToString(final String filePath) { | ||
| 1012 | + File file = isSpace(filePath) ? null : new File(filePath); | ||
| 1013 | + return getFileMD5ToString(file); | ||
| 1014 | + } | ||
| 1015 | + | ||
| 1016 | + /** | ||
| 1017 | + * Return the MD5 of file. | ||
| 1018 | + * | ||
| 1019 | + * @param file The file. | ||
| 1020 | + * @return the md5 of file | ||
| 1021 | + */ | ||
| 1022 | + public static String getFileMD5ToString(final File file) { | ||
| 1023 | + return bytes2HexString(getFileMD5(file)); | ||
| 1024 | + } | ||
| 1025 | + | ||
| 1026 | + /** | ||
| 1027 | + * Return the MD5 of file. | ||
| 1028 | + * | ||
| 1029 | + * @param filePath The path of file. | ||
| 1030 | + * @return the md5 of file | ||
| 1031 | + */ | ||
| 1032 | + public static byte[] getFileMD5(final String filePath) { | ||
| 1033 | + return getFileMD5(getFileByPath(filePath)); | ||
| 1034 | + } | ||
| 1035 | + | ||
| 1036 | + /** | ||
| 1037 | + * Return the MD5 of file. | ||
| 1038 | + * | ||
| 1039 | + * @param file The file. | ||
| 1040 | + * @return the md5 of file | ||
| 1041 | + */ | ||
| 1042 | + public static byte[] getFileMD5(final File file) { | ||
| 1043 | + if (file == null) return null; | ||
| 1044 | + DigestInputStream dis = null; | ||
| 1045 | + try { | ||
| 1046 | + FileInputStream fis = new FileInputStream(file); | ||
| 1047 | + MessageDigest md = MessageDigest.getInstance("MD5"); | ||
| 1048 | + dis = new DigestInputStream(fis, md); | ||
| 1049 | + byte[] buffer = new byte[1024 * 256]; | ||
| 1050 | + while (true) { | ||
| 1051 | + if (!(dis.read(buffer) > 0)) break; | ||
| 1052 | + } | ||
| 1053 | + md = dis.getMessageDigest(); | ||
| 1054 | + return md.digest(); | ||
| 1055 | + } catch (NoSuchAlgorithmException | IOException e) { | ||
| 1056 | + e.printStackTrace(); | ||
| 1057 | + } finally { | ||
| 1058 | + try { | ||
| 1059 | + if (dis != null) { | ||
| 1060 | + dis.close(); | ||
| 1061 | + } | ||
| 1062 | + } catch (IOException e) { | ||
| 1063 | + e.printStackTrace(); | ||
| 1064 | + } | ||
| 1065 | + } | ||
| 1066 | + return null; | ||
| 1067 | + } | ||
| 1068 | + | ||
| 1069 | + /** | ||
| 1070 | + * Return the file's path of directory. | ||
| 1071 | + * | ||
| 1072 | + * @param file The file. | ||
| 1073 | + * @return the file's path of directory | ||
| 1074 | + */ | ||
| 1075 | + public static String getDirName(final File file) { | ||
| 1076 | + if (file == null) return ""; | ||
| 1077 | + return getDirName(file.getAbsolutePath()); | ||
| 1078 | + } | ||
| 1079 | + | ||
| 1080 | + /** | ||
| 1081 | + * Return the file's path of directory. | ||
| 1082 | + * | ||
| 1083 | + * @param filePath The path of file. | ||
| 1084 | + * @return the file's path of directory | ||
| 1085 | + */ | ||
| 1086 | + public static String getDirName(final String filePath) { | ||
| 1087 | + if (isSpace(filePath)) return ""; | ||
| 1088 | + int lastSep = filePath.lastIndexOf(File.separator); | ||
| 1089 | + return lastSep == -1 ? "" : filePath.substring(0, lastSep + 1); | ||
| 1090 | + } | ||
| 1091 | + | ||
| 1092 | + /** | ||
| 1093 | + * Return the name of file. | ||
| 1094 | + * | ||
| 1095 | + * @param file The file. | ||
| 1096 | + * @return the name of file | ||
| 1097 | + */ | ||
| 1098 | + public static String getFileName(final File file) { | ||
| 1099 | + if (file == null) return ""; | ||
| 1100 | + return getFileName(file.getAbsolutePath()); | ||
| 1101 | + } | ||
| 1102 | + | ||
| 1103 | + /** | ||
| 1104 | + * Return the name of file. | ||
| 1105 | + * | ||
| 1106 | + * @param filePath The path of file. | ||
| 1107 | + * @return the name of file | ||
| 1108 | + */ | ||
| 1109 | + public static String getFileName(final String filePath) { | ||
| 1110 | + if (isSpace(filePath)) return ""; | ||
| 1111 | + int lastSep = filePath.lastIndexOf(File.separator); | ||
| 1112 | + return lastSep == -1 ? filePath : filePath.substring(lastSep + 1); | ||
| 1113 | + } | ||
| 1114 | + | ||
| 1115 | + /** | ||
| 1116 | + * Return the name of file without extension. | ||
| 1117 | + * | ||
| 1118 | + * @param file The file. | ||
| 1119 | + * @return the name of file without extension | ||
| 1120 | + */ | ||
| 1121 | + public static String getFileNameNoExtension(final File file) { | ||
| 1122 | + if (file == null) return ""; | ||
| 1123 | + return getFileNameNoExtension(file.getPath()); | ||
| 1124 | + } | ||
| 1125 | + | ||
| 1126 | + /** | ||
| 1127 | + * Return the name of file without extension. | ||
| 1128 | + * | ||
| 1129 | + * @param filePath The path of file. | ||
| 1130 | + * @return the name of file without extension | ||
| 1131 | + */ | ||
| 1132 | + public static String getFileNameNoExtension(final String filePath) { | ||
| 1133 | + if (isSpace(filePath)) return ""; | ||
| 1134 | + int lastPoi = filePath.lastIndexOf('.'); | ||
| 1135 | + int lastSep = filePath.lastIndexOf(File.separator); | ||
| 1136 | + if (lastSep == -1) { | ||
| 1137 | + return (lastPoi == -1 ? filePath : filePath.substring(0, lastPoi)); | ||
| 1138 | + } | ||
| 1139 | + if (lastPoi == -1 || lastSep > lastPoi) { | ||
| 1140 | + return filePath.substring(lastSep + 1); | ||
| 1141 | + } | ||
| 1142 | + return filePath.substring(lastSep + 1, lastPoi); | ||
| 1143 | + } | ||
| 1144 | + | ||
| 1145 | + /** | ||
| 1146 | + * Return the extension of file. | ||
| 1147 | + * | ||
| 1148 | + * @param file The file. | ||
| 1149 | + * @return the extension of file | ||
| 1150 | + */ | ||
| 1151 | + public static String getFileExtension(final File file) { | ||
| 1152 | + if (file == null) return ""; | ||
| 1153 | + return getFileExtension(file.getPath()); | ||
| 1154 | + } | ||
| 1155 | + | ||
| 1156 | + /** | ||
| 1157 | + * Return the extension of file. | ||
| 1158 | + * | ||
| 1159 | + * @param filePath The path of file. | ||
| 1160 | + * @return the extension of file | ||
| 1161 | + */ | ||
| 1162 | + public static String getFileExtension(final String filePath) { | ||
| 1163 | + if (isSpace(filePath)) return ""; | ||
| 1164 | + int lastPoi = filePath.lastIndexOf('.'); | ||
| 1165 | + int lastSep = filePath.lastIndexOf(File.separator); | ||
| 1166 | + if (lastPoi == -1 || lastSep >= lastPoi) return ""; | ||
| 1167 | + return filePath.substring(lastPoi + 1); | ||
| 1168 | + } | ||
| 1169 | + | ||
| 1170 | + /////////////////////////////////////////////////////////////////////////// | ||
| 1171 | + // interface | ||
| 1172 | + /////////////////////////////////////////////////////////////////////////// | ||
| 1173 | + | ||
| 1174 | + public interface OnReplaceListener { | ||
| 1175 | + boolean onReplace(); | ||
| 1176 | + } | ||
| 1177 | + | ||
| 1178 | + /////////////////////////////////////////////////////////////////////////// | ||
| 1179 | + // other utils methods | ||
| 1180 | + /////////////////////////////////////////////////////////////////////////// | ||
| 1181 | + | ||
| 1182 | + private static final char HEX_DIGITS[] = | ||
| 1183 | + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; | ||
| 1184 | + | ||
| 1185 | + private static String bytes2HexString(final byte[] bytes) { | ||
| 1186 | + if (bytes == null) return ""; | ||
| 1187 | + int len = bytes.length; | ||
| 1188 | + if (len <= 0) return ""; | ||
| 1189 | + char[] ret = new char[len << 1]; | ||
| 1190 | + for (int i = 0, j = 0; i < len; i++) { | ||
| 1191 | + ret[j++] = HEX_DIGITS[bytes[i] >> 4 & 0x0f]; | ||
| 1192 | + ret[j++] = HEX_DIGITS[bytes[i] & 0x0f]; | ||
| 1193 | + } | ||
| 1194 | + return new String(ret); | ||
| 1195 | + } | ||
| 1196 | + | ||
| 1197 | + private static String byte2FitMemorySize(final long byteNum) { | ||
| 1198 | + if (byteNum < 0) { | ||
| 1199 | + return "shouldn't be less than zero!"; | ||
| 1200 | + } else if (byteNum < 1024) { | ||
| 1201 | + return String.format(Locale.getDefault(), "%.3fB", (double) byteNum); | ||
| 1202 | + } else if (byteNum < 1048576) { | ||
| 1203 | + return String.format(Locale.getDefault(), "%.3fKB", (double) byteNum / 1024); | ||
| 1204 | + } else if (byteNum < 1073741824) { | ||
| 1205 | + return String.format(Locale.getDefault(), "%.3fMB", (double) byteNum / 1048576); | ||
| 1206 | + } else { | ||
| 1207 | + return String.format(Locale.getDefault(), "%.3fGB", (double) byteNum / 1073741824); | ||
| 1208 | + } | ||
| 1209 | + } | ||
| 1210 | + | ||
| 1211 | + private static boolean isSpace(final String s) { | ||
| 1212 | + if (s == null) return true; | ||
| 1213 | + for (int i = 0, len = s.length(); i < len; ++i) { | ||
| 1214 | + if (!Character.isWhitespace(s.charAt(i))) { | ||
| 1215 | + return false; | ||
| 1216 | + } | ||
| 1217 | + } | ||
| 1218 | + return true; | ||
| 1219 | + } | ||
| 1220 | + | ||
| 1221 | + private static boolean writeFileFromIS(final File file, | ||
| 1222 | + final InputStream is) { | ||
| 1223 | + OutputStream os = null; | ||
| 1224 | + try { | ||
| 1225 | + os = new BufferedOutputStream(new FileOutputStream(file)); | ||
| 1226 | + byte data[] = new byte[8192]; | ||
| 1227 | + int len; | ||
| 1228 | + while ((len = is.read(data, 0, 8192)) != -1) { | ||
| 1229 | + os.write(data, 0, len); | ||
| 1230 | + } | ||
| 1231 | + return true; | ||
| 1232 | + } catch (IOException e) { | ||
| 1233 | + e.printStackTrace(); | ||
| 1234 | + return false; | ||
| 1235 | + } finally { | ||
| 1236 | + try { | ||
| 1237 | + is.close(); | ||
| 1238 | + } catch (IOException e) { | ||
| 1239 | + e.printStackTrace(); | ||
| 1240 | + } | ||
| 1241 | + try { | ||
| 1242 | + if (os != null) { | ||
| 1243 | + os.close(); | ||
| 1244 | + } | ||
| 1245 | + } catch (IOException e) { | ||
| 1246 | + e.printStackTrace(); | ||
| 1247 | + } | ||
| 1248 | + } | ||
| 1249 | + } | ||
| 1250 | + | ||
| 1251 | + public static boolean isExternalStorageWritable() { | ||
| 1252 | + String state = Environment.getExternalStorageState(); | ||
| 1253 | + if (Environment.MEDIA_MOUNTED.equals(state)) { | ||
| 1254 | + return true; | ||
| 1255 | + } | ||
| 1256 | + return false; | ||
| 1257 | + } | ||
| 1258 | + | ||
| 1259 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/ImageUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.graphics.Bitmap; | ||
| 5 | +import android.graphics.Canvas; | ||
| 6 | +import android.graphics.Color; | ||
| 7 | +import android.graphics.Matrix; | ||
| 8 | +import android.graphics.Paint; | ||
| 9 | +import android.graphics.Path; | ||
| 10 | +import android.graphics.Rect; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 图片添加水印工具类 | ||
| 14 | + * | ||
| 15 | + * @author Lynn | ||
| 16 | + * @date 2018/1/29 | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +public class ImageUtil { | ||
| 20 | + /** | ||
| 21 | + * 设置水印图片在左上角 | ||
| 22 | + * | ||
| 23 | + * @param context | ||
| 24 | + * @param src | ||
| 25 | + * @param watermark | ||
| 26 | + * @param paddingLeft | ||
| 27 | + * @param paddingTop | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + public static Bitmap createWaterMaskLeftTop( | ||
| 31 | + Context context, Bitmap src, Bitmap watermark, | ||
| 32 | + int paddingLeft, int paddingTop) { | ||
| 33 | + return createWaterMaskBitmap(src, watermark, | ||
| 34 | + dp2px(context, paddingLeft), dp2px(context, paddingTop)); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + private static Bitmap createWaterMaskBitmap(Bitmap src, Bitmap watermark, | ||
| 38 | + int paddingLeft, int paddingTop) { | ||
| 39 | + if (src == null) { | ||
| 40 | + return null; | ||
| 41 | + } | ||
| 42 | + int width = src.getWidth(); | ||
| 43 | + int height = src.getHeight(); | ||
| 44 | + //创建一个bitmap | ||
| 45 | + Bitmap newb = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图 | ||
| 46 | + //将该图片作为画布 | ||
| 47 | + Canvas canvas = new Canvas(newb); | ||
| 48 | + //在画布 0,0坐标上开始绘制原始图片 | ||
| 49 | + canvas.drawBitmap(src, 0, 0, null); | ||
| 50 | + //在画布上绘制水印图片 | ||
| 51 | + canvas.drawBitmap(watermark, paddingLeft, paddingTop, null); | ||
| 52 | + // 保存 | ||
| 53 | +// canvas.save(Canvas.ALL_SAVE_FLAG); | ||
| 54 | + canvas.save(); | ||
| 55 | + // 存储 | ||
| 56 | + canvas.restore(); | ||
| 57 | + return newb; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 设置水印图片在右下角 | ||
| 62 | + * | ||
| 63 | + * @param context | ||
| 64 | + * @param src | ||
| 65 | + * @param watermark | ||
| 66 | + * @param paddingRight | ||
| 67 | + * @param paddingBottom | ||
| 68 | + * @return | ||
| 69 | + */ | ||
| 70 | + public static Bitmap createWaterMaskRightBottom( | ||
| 71 | + Context context, Bitmap src, Bitmap watermark, | ||
| 72 | + int paddingRight, int paddingBottom) { | ||
| 73 | + return createWaterMaskBitmap(src, watermark, | ||
| 74 | + src.getWidth() - watermark.getWidth() - dp2px(context, paddingRight), | ||
| 75 | + src.getHeight() - watermark.getHeight() - dp2px(context, paddingBottom)); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 设置水印图片到右上角 | ||
| 80 | + * | ||
| 81 | + * @param context | ||
| 82 | + * @param src | ||
| 83 | + * @param watermark | ||
| 84 | + * @param paddingRight | ||
| 85 | + * @param paddingTop | ||
| 86 | + * @return | ||
| 87 | + */ | ||
| 88 | + public static Bitmap createWaterMaskRightTop( | ||
| 89 | + Context context, Bitmap src, Bitmap watermark, | ||
| 90 | + int paddingRight, int paddingTop) { | ||
| 91 | + return createWaterMaskBitmap(src, watermark, | ||
| 92 | + src.getWidth() - watermark.getWidth() - dp2px(context, paddingRight), | ||
| 93 | + dp2px(context, paddingTop)); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** | ||
| 97 | + * 设置水印图片到左下角 | ||
| 98 | + * | ||
| 99 | + * @param context | ||
| 100 | + * @param src | ||
| 101 | + * @param watermark | ||
| 102 | + * @param paddingLeft | ||
| 103 | + * @param paddingBottom | ||
| 104 | + * @return | ||
| 105 | + */ | ||
| 106 | + public static Bitmap createWaterMaskLeftBottom( | ||
| 107 | + Context context, Bitmap src, Bitmap watermark, | ||
| 108 | + int paddingLeft, int paddingBottom) { | ||
| 109 | + return createWaterMaskBitmap(src, watermark, dp2px(context, paddingLeft), | ||
| 110 | + src.getHeight() - watermark.getHeight() - dp2px(context, paddingBottom)); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * 设置水印图片到中间 | ||
| 115 | + * | ||
| 116 | + * @param src | ||
| 117 | + * @param watermark | ||
| 118 | + * @return | ||
| 119 | + */ | ||
| 120 | + public static Bitmap createWaterMaskCenter(Bitmap src, Bitmap watermark) { | ||
| 121 | + return createWaterMaskBitmap(src, watermark, | ||
| 122 | + (src.getWidth() - watermark.getWidth()) / 2, | ||
| 123 | + (src.getHeight() - watermark.getHeight()) / 2); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * 给图片添加文字到左上角 | ||
| 128 | + * | ||
| 129 | + * @param context | ||
| 130 | + * @param bitmap | ||
| 131 | + * @param text | ||
| 132 | + * @return | ||
| 133 | + */ | ||
| 134 | + public static Bitmap drawTextToLeftTop(Context context, Bitmap bitmap, String text, | ||
| 135 | + int size, int color, int paddingLeft, int paddingTop) { | ||
| 136 | + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 137 | + paint.setColor(color); | ||
| 138 | + paint.setTextSize(dp2px(context, size)); | ||
| 139 | + Rect bounds = new Rect(); | ||
| 140 | + paint.getTextBounds(text, 0, text.length(), bounds); | ||
| 141 | + return drawTextToBitmap(context, bitmap, text, paint, bounds, | ||
| 142 | + dp2px(context, paddingLeft), | ||
| 143 | + dp2px(context, paddingTop) + bounds.height()); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * 绘制文字到右下角 | ||
| 148 | + * | ||
| 149 | + * @param context | ||
| 150 | + * @param bitmap | ||
| 151 | + * @param text | ||
| 152 | + * @param size | ||
| 153 | + * @param color | ||
| 154 | + * @param paddingRight | ||
| 155 | + * @param paddingBottom | ||
| 156 | + * @return | ||
| 157 | + */ | ||
| 158 | + public static Bitmap drawTextToRightBottom(Context context, Bitmap bitmap, String text, | ||
| 159 | + int size, int color, int paddingRight, int paddingBottom) { | ||
| 160 | + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 161 | + paint.setColor(color); | ||
| 162 | + paint.setTextSize(dp2px(context, size)); | ||
| 163 | + Rect bounds = new Rect(); | ||
| 164 | + paint.getTextBounds(text, 0, text.length(), bounds); | ||
| 165 | + return drawTextToBitmap(context, bitmap, text, paint, bounds, | ||
| 166 | + bitmap.getWidth() - bounds.width() - dp2px(context, paddingRight), | ||
| 167 | + bitmap.getHeight() - dp2px(context, paddingBottom)); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * 绘制文字到右上方 | ||
| 172 | + * | ||
| 173 | + * @param context | ||
| 174 | + * @param bitmap | ||
| 175 | + * @param text | ||
| 176 | + * @param size | ||
| 177 | + * @param color | ||
| 178 | + * @param paddingRight | ||
| 179 | + * @param paddingTop | ||
| 180 | + * @return | ||
| 181 | + */ | ||
| 182 | + public static Bitmap drawTextToRightTop(Context context, Bitmap bitmap, String text, | ||
| 183 | + int size, int color, int paddingRight, int paddingTop) { | ||
| 184 | + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 185 | + paint.setColor(color); | ||
| 186 | + paint.setTextSize(dp2px(context, size)); | ||
| 187 | + Rect bounds = new Rect(); | ||
| 188 | + paint.getTextBounds(text, 0, text.length(), bounds); | ||
| 189 | + return drawTextToBitmap(context, bitmap, text, paint, bounds, | ||
| 190 | + bitmap.getWidth() - bounds.width() - dp2px(context, paddingRight), | ||
| 191 | + dp2px(context, paddingTop) + bounds.height()); | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + /** | ||
| 195 | + * 绘制文字到左下方 | ||
| 196 | + * | ||
| 197 | + * @param context | ||
| 198 | + * @param bitmap | ||
| 199 | + * @param text | ||
| 200 | + * @param size | ||
| 201 | + * @param color | ||
| 202 | + * @param paddingLeft | ||
| 203 | + * @param paddingBottom | ||
| 204 | + * @return | ||
| 205 | + */ | ||
| 206 | + public static Bitmap drawTextToLeftBottom(Context context, Bitmap bitmap, String text, | ||
| 207 | + int size, int color, int paddingLeft, int paddingBottom) { | ||
| 208 | + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 209 | + paint.setColor(color); | ||
| 210 | + paint.setTextSize(dp2px(context, size)); | ||
| 211 | + Rect bounds = new Rect(); | ||
| 212 | + paint.getTextBounds(text, 0, text.length(), bounds); | ||
| 213 | + return drawTextToBitmap(context, bitmap, text, paint, bounds, | ||
| 214 | + dp2px(context, paddingLeft), | ||
| 215 | + bitmap.getHeight() - dp2px(context, paddingBottom)); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + /** | ||
| 219 | + * 绘制文字到中间 | ||
| 220 | + * | ||
| 221 | + * @param context | ||
| 222 | + * @param bitmap | ||
| 223 | + * @param text | ||
| 224 | + * @param size | ||
| 225 | + * @param color | ||
| 226 | + * @return | ||
| 227 | + */ | ||
| 228 | + public static Bitmap drawTextToCenter(Context context, Bitmap bitmap, String text, | ||
| 229 | + int size, int color) { | ||
| 230 | + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 231 | + paint.setColor(color); | ||
| 232 | + paint.setTextSize(dp2px(context, size)); | ||
| 233 | + Rect bounds = new Rect(); | ||
| 234 | + paint.getTextBounds(text, 0, text.length(), bounds); | ||
| 235 | + return drawTextToBitmap(context, bitmap, text, paint, bounds, | ||
| 236 | + (bitmap.getWidth() - bounds.width()) / 2, | ||
| 237 | + (bitmap.getHeight() + bounds.height()) / 2); | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + //图片上绘制文字 | ||
| 241 | + private static Bitmap drawTextToBitmap(Context context, Bitmap bitmap, String text, | ||
| 242 | + Paint paint, Rect bounds, int paddingLeft, int paddingTop) { | ||
| 243 | + Bitmap.Config bitmapConfig = bitmap.getConfig(); | ||
| 244 | + | ||
| 245 | + paint.setDither(true); // 获取跟清晰的图像采样 | ||
| 246 | + paint.setFilterBitmap(true);// 过滤一些 | ||
| 247 | + if (bitmapConfig == null) { | ||
| 248 | + bitmapConfig = Bitmap.Config.ARGB_8888; | ||
| 249 | + } | ||
| 250 | + bitmap = bitmap.copy(bitmapConfig, true); | ||
| 251 | + Canvas canvas = new Canvas(bitmap); | ||
| 252 | +// canvas.rotate(-45); | ||
| 253 | +// canvas.drawText(text, paddingLeft, paddingTop, paint); | ||
| 254 | + | ||
| 255 | + Path path = new Path(); | ||
| 256 | + path.moveTo(bitmap.getWidth() / 2, bitmap.getHeight()); | ||
| 257 | + path.lineTo(bitmap.getWidth(), 50); | ||
| 258 | + | ||
| 259 | + canvas.drawTextOnPath(text, path, 20, 20, paint); | ||
| 260 | + | ||
| 261 | + return bitmap; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + public static void addBitmap(String gText) { | ||
| 265 | + Bitmap bitmap = Bitmap.createBitmap(420, 240, Bitmap.Config.ARGB_8888); | ||
| 266 | + Canvas canvas = new Canvas(bitmap); | ||
| 267 | + canvas.drawColor(Color.WHITE); | ||
| 268 | + Paint paint = new Paint(); | ||
| 269 | + paint.setColor(Color.GRAY); | ||
| 270 | + paint.setAlpha(80); | ||
| 271 | + paint.setAntiAlias(true); | ||
| 272 | + paint.setTextAlign(Paint.Align.LEFT); | ||
| 273 | + paint.setTextSize(40); | ||
| 274 | + Path path = new Path(); | ||
| 275 | + path.moveTo(0, 150); | ||
| 276 | + path.lineTo(160 * 2, 0); | ||
| 277 | + canvas.drawTextOnPath(gText, path, 0, 20, paint); | ||
| 278 | +// canvas.save(Canvas.ALL_SAVE_FLAG); | ||
| 279 | + canvas.save(); | ||
| 280 | + canvas.restore(); | ||
| 281 | + bitmap.recycle(); | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + /** | ||
| 285 | + * 缩放图片 | ||
| 286 | + * | ||
| 287 | + * @param src | ||
| 288 | + * @param w | ||
| 289 | + * @param h | ||
| 290 | + * @return | ||
| 291 | + */ | ||
| 292 | + public static Bitmap scaleWithWH(Bitmap src, double w, double h) { | ||
| 293 | + if (w == 0 || h == 0 || src == null) { | ||
| 294 | + return src; | ||
| 295 | + } else { | ||
| 296 | + // 记录src的宽高 | ||
| 297 | + int width = src.getWidth(); | ||
| 298 | + int height = src.getHeight(); | ||
| 299 | + // 创建一个matrix容器 | ||
| 300 | + Matrix matrix = new Matrix(); | ||
| 301 | + // 计算缩放比例 | ||
| 302 | + float scaleWidth = (float) (w / width); | ||
| 303 | + float scaleHeight = (float) (h / height); | ||
| 304 | + // 开始缩放 | ||
| 305 | + matrix.postScale(scaleWidth, scaleHeight); | ||
| 306 | + // 创建缩放后的图片 | ||
| 307 | + return Bitmap.createBitmap(src, 0, 0, width, height, matrix, true); | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + /** | ||
| 312 | + * dip转pix | ||
| 313 | + * | ||
| 314 | + * @param context | ||
| 315 | + * @param dp | ||
| 316 | + * @return | ||
| 317 | + */ | ||
| 318 | + public static int dp2px(Context context, float dp) { | ||
| 319 | + final float scale = context.getResources().getDisplayMetrics().density; | ||
| 320 | + return (int) (dp * scale + 0.5f); | ||
| 321 | + } | ||
| 322 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/LambdaUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import java.util.Collection; | ||
| 4 | + | ||
| 5 | +import java8.util.stream.RefStreams; | ||
| 6 | +import java8.util.stream.Stream; | ||
| 7 | + | ||
| 8 | +public class LambdaUtil { | ||
| 9 | + public static <T> Stream<T> stream(Collection<T> collection) { | ||
| 10 | + if (collection == null) return null; | ||
| 11 | + return RefStreams.of((T[]) collection.toArray()); | ||
| 12 | + } | ||
| 13 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/LogUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.util.Log; | ||
| 4 | + | ||
| 5 | +import com.cnlive.libs.base.application.AppConfig; | ||
| 6 | + | ||
| 7 | +public class LogUtil { | ||
| 8 | + private static boolean ENABLED = AppConfig.isDebug(); | ||
| 9 | + | ||
| 10 | + public LogUtil() { | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + public static void setDebug(boolean debug) { | ||
| 14 | + ENABLED = debug; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public static void e(String tag, String msg) { | ||
| 18 | + if (ENABLED) { | ||
| 19 | + Log.e(tag, msg); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public static void e(String tag, String msg, Throwable tr) { | ||
| 25 | + if (ENABLED) { | ||
| 26 | + Log.e(tag, msg, tr); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public static void d(String tag, String msg) { | ||
| 32 | + if (ENABLED) { | ||
| 33 | + Log.d(tag, msg); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public static void d(String tag, String msg, Throwable tr) { | ||
| 39 | + if (ENABLED) { | ||
| 40 | + Log.d(tag, msg, tr); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + } | ||
| 44 | +} |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/MD5Util.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.io.FileInputStream; | ||
| 5 | +import java.io.IOException; | ||
| 6 | +import java.io.InputStream; | ||
| 7 | +import java.security.MessageDigest; | ||
| 8 | +import java.security.NoSuchAlgorithmException; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 提供一系列获取和校验MD5的方法 | ||
| 12 | + */ | ||
| 13 | +public class MD5Util { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 获取该输入流的MD5值 | ||
| 17 | + * | ||
| 18 | + * @param is | ||
| 19 | + * @return | ||
| 20 | + * @throws NoSuchAlgorithmException | ||
| 21 | + * @throws IOException | ||
| 22 | + */ | ||
| 23 | + public static String getMD5(InputStream is) throws NoSuchAlgorithmException, IOException { | ||
| 24 | + StringBuffer md5 = new StringBuffer(); | ||
| 25 | + MessageDigest md = MessageDigest.getInstance("MD5"); | ||
| 26 | + byte[] dataBytes = new byte[1024]; | ||
| 27 | + | ||
| 28 | + int nread = 0; | ||
| 29 | + while ((nread = is.read(dataBytes)) != -1) { | ||
| 30 | + md.update(dataBytes, 0, nread); | ||
| 31 | + } | ||
| 32 | + byte[] mdbytes = md.digest(); | ||
| 33 | + | ||
| 34 | + // convert the byte to hex format | ||
| 35 | + for (int i = 0; i < mdbytes.length; i++) { | ||
| 36 | + md5.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1)); | ||
| 37 | + } | ||
| 38 | + return md5.toString(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 获取该文件的MD5值 | ||
| 43 | + * | ||
| 44 | + * @param file | ||
| 45 | + * @return | ||
| 46 | + * @throws NoSuchAlgorithmException | ||
| 47 | + * @throws IOException | ||
| 48 | + */ | ||
| 49 | + public static String getMD5(File file) throws NoSuchAlgorithmException, IOException { | ||
| 50 | + FileInputStream fis = new FileInputStream(file); | ||
| 51 | + return getMD5(fis); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获取指定路径文件的MD5值 | ||
| 56 | + * | ||
| 57 | + * @param path | ||
| 58 | + * @return | ||
| 59 | + * @throws NoSuchAlgorithmException | ||
| 60 | + * @throws IOException | ||
| 61 | + */ | ||
| 62 | + public static String getMD5(String path) throws NoSuchAlgorithmException, IOException { | ||
| 63 | + FileInputStream fis = new FileInputStream(path); | ||
| 64 | + return getMD5(fis); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 校验该输入流的MD5值 | ||
| 69 | + * | ||
| 70 | + * @param is | ||
| 71 | + * @param toBeCheckSum | ||
| 72 | + * @return | ||
| 73 | + * @throws NoSuchAlgorithmException | ||
| 74 | + * @throws IOException | ||
| 75 | + */ | ||
| 76 | + public static boolean md5CheckSum(InputStream is, String toBeCheckSum) throws NoSuchAlgorithmException, IOException { | ||
| 77 | + return getMD5(is).equals(toBeCheckSum); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 校验该文件的MD5值 | ||
| 82 | + * | ||
| 83 | + * @param file | ||
| 84 | + * @param toBeCheckSum | ||
| 85 | + * @return | ||
| 86 | + * @throws NoSuchAlgorithmException | ||
| 87 | + * @throws IOException | ||
| 88 | + */ | ||
| 89 | + public static boolean md5CheckSum(File file, String toBeCheckSum) throws NoSuchAlgorithmException, IOException { | ||
| 90 | + return getMD5(file).equals(toBeCheckSum); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 校验指定路径文件的MD5值 | ||
| 95 | + * | ||
| 96 | + * @param path | ||
| 97 | + * @param toBeCheckSum | ||
| 98 | + * @return | ||
| 99 | + * @throws NoSuchAlgorithmException | ||
| 100 | + * @throws IOException | ||
| 101 | + */ | ||
| 102 | + public static boolean md5CheckSum(String path, String toBeCheckSum) throws NoSuchAlgorithmException, IOException { | ||
| 103 | + return getMD5(path).equals(toBeCheckSum); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /* MD5 TEST | ||
| 107 | + public static void main(String[] args) { | ||
| 108 | + try { | ||
| 109 | + System.out.println(getMD5("D:/work/BJ/ESB_CSS_CSS_ImportCustCompFormRejectInfoSrv.xml")); | ||
| 110 | + } catch (NoSuchAlgorithmException e) { | ||
| 111 | + e.printStackTrace(); | ||
| 112 | + } catch (IOException e) { | ||
| 113 | + e.printStackTrace(); | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + */ | ||
| 117 | +} | ||
| 0 | \ No newline at end of file | 118 | \ No newline at end of file |
cloud/wjj_lib/src/main/java/com/cnlive/libs/base/util/NetworkUtil.java
0 → 100644
| 1 | +package com.cnlive.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.net.ConnectivityManager; | ||
| 5 | +import android.net.NetworkInfo; | ||
| 6 | + | ||
| 7 | +public class NetworkUtil { | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + public static boolean isConnectInternet(Context context) { | ||
| 11 | + if (context == null) return false; | ||
| 12 | + ConnectivityManager connectManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
| 13 | + | ||
| 14 | + if (connectManager != null) { | ||
| 15 | + NetworkInfo networkinfo = connectManager.getActiveNetworkInfo(); | ||
| 16 | + return networkinfo != null && networkinfo.isAvailable(); | ||
| 17 | + } | ||
| 18 | + return false; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | +} | ||
| 0 | \ No newline at end of file | 22 | \ No newline at end of file |