Commit fdd9b441 authored by 王雪伟's avatar 王雪伟

Initial commit

parents
Pipeline #767 failed with stages
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
# Java class files
*.class
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/
gradlew.bat
build/
/gradle
cms/build
cms/*.iml
app/build
app/debug
app/*.iml
moduleMain/build
moduleMain/*.iml
\ No newline at end of file
/build
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
// 将版本相关的属性剥离到属性文件中
def Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
def PACKAGE_NAME = versionProps['PACKAGE_NAME']
def VERSION_CODE = versionProps['VERSION_CODE']
def VERSION_NAME = versionProps['VERSION_NAME']
def code = (VERSION_CODE ?: "0").toInteger()
defaultConfig {
applicationId PACKAGE_NAME
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode code
versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
flavorDimensions "1"
}
signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
storePassword DEBUG_STORE_PASSWORD
keyPassword DEBUG_KEY_PASSWORD
keyAlias DEBUG_KEY_ALIAS
v2SigningEnabled true
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyPassword RELEASE_KEY_PASSWORD
keyAlias RELEASE_KEY_ALIAS
v2SigningEnabled true
}
}
buildTypes {
//签名配置
debug {
signingConfig signingConfigs.debug
}
release {
//是否zip对齐
// zipAlignEnabled true
// 移除无用的resource文件
// shrinkResources true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//签名配置
signingConfig signingConfigs.release
}
}
productFlavors {
guanwang {}
toutiao {}
toutiao_h5 {}
oppo{}
xiaomi{}
huawei{}
meizu
_360{}
yyb{}
hykb{}
vivo{}
zhihu{}
bilibili{}
baidu{}
baidu{}
bilibili{}
baichuan{}
kuaishou{}
weibo{}
zhihu{}
tuia{}
source1{}
mbt{}
baichuan{}
huafei_h5{}
sh{}
}
productFlavors.all {
flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
applicationVariants.all { variant ->
//这个修改输出的APK路径
if (variant.buildType.name != "debug") {//防止AS无法安装debug包(apk)
variant.getPackageApplication().outputDirectory = new File(APK_PATH + versionProps['PACKAGE_NAME'] + "/" + variant.versionName + "/")
}
variant.outputs.all {
//这个修改输出APK的文件名
apkData.outputFileName = versionProps['PACKAGE_NAME'] +"_"+
variant.flavorName + "-" +
variant.versionName +
".apk"
}
}
}
repositories {
flatDir {
dirs 'libs', '../cms/libs'
}
}
dependencies {
implementation project(':moduleMain')
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.zxhl.aprileye
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.zxhl.aprileyeapp", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zxhl.aprileye">
<!-- 权限声明 -->
<!-- 允许程序打开网络套接字 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 允许程序获取网络相关信息 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 允许程序向外部存储设备写数据 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 允许程序写音频数据 -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" />-->
<!-- 允许程序使用PowerManager WakeLocks以防止处理器休眠或者屏幕锁屏 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 允许程序获取Wifi网络状态信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 允许程序使用设备的camera -->
<!-- <uses-permission android:name="android.permission.CAMERA" />-->
<!-- 允许程序使用闪光灯 -->
<!-- <uses-permission android:name="android.permission.FLASHLIGHT" />-->
<!-- 允许程序获得设备信息 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!-- 声明程序使用camera和自动对焦功能 -->
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:name=".AppLi"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".InitActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="main"
android:scheme="aprileye" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>
\ No newline at end of file
package com.zxhl.aprileye
import android.app.Application
import android.text.TextUtils
import com.tencent.bugly.crashreport.CrashReport
import com.umeng.commonsdk.UMConfigure
import com.umeng.socialize.PlatformConfig
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Config
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.base.BaseChildApplication
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.MiitHelper
import com.zxhl.cms.utils.Utils
/**
* @author (wangXuewei)
* @datetime 2022-08-05 11:16 GMT+8
* @detail :
*/
class AppLi : BaseChildApplication() {
override fun onCreate() {
super.onCreate()
AppContext.init(applicationContext)
}
private fun getOaid() {
MiitHelper(appIdsUpdater).getDeviceIds(AppContext.mAppContext)
}
private val appIdsUpdater: MiitHelper.AppIdsUpdater =
MiitHelper.AppIdsUpdater { ids ->
if (!TextUtils.isEmpty(ids)) {
SettingPreference.setOaid(ids)
EventUtils.onEvent("tab_imp", "获取到oaid$ids")
}
}
fun initAppConfig() {
UMConfigure.init(AppContext.get(), UMConfigure.DEVICE_TYPE_PHONE, "")
Utils.checkDebugMode(AppContext.get())
PlatformConfig.setWeixin(Constant.WX_APPID, Constant.WX_APPKEY)
PlatformConfig.setWXFileProvider("com.tencent.sample2.fileprovider");
Config.init(AppContext.get())
//初始化bugly
CrashReport.initCrashReport(AppContext.get(), "f9fb9a9ef5", false);
getOaid()
}
}
\ No newline at end of file
package com.zxhl.aprileye
import android.content.Intent
import android.text.TextUtils
import android.view.View
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.utils.Utils
import com.zxhl.cms.widget.CenterDialog
import com.zxhl.modulemain.activity.SplashActivity
/**
* @author (wangXuewei)
* @detail :
*/
class InitActivity :BaseActivity() {
override fun onClick(v: View?) {
}
override fun layoutID(): Int = R.layout.activity_layout_splash
override fun init() {
if (AppContext.get()!=null){
var source = Utils.getChannel(AppContext.get())
if (!TextUtils.isEmpty(source)) {
SettingPreference.setSource(source)
}
}
if (SettingPreference.getFirstApp()) {
CenterDialog.showPrivacyProtocol(this, {
AppLi().initAppConfig()
SettingPreference.setFirstApp()
startActivity(Intent(this@InitActivity, SplashActivity::class.java))
finish()
}, {
finish()
})
} else {
startActivity(Intent(this@InitActivity, SplashActivity::class.java))
finish()
}
}
}
\ No newline at end of file
package com.zxhl.aprileye
import android.view.View
import com.zxhl.cms.common.base.BaseActivity
class MainActivity : BaseActivity() {
override fun layoutID(): Int = R.layout.activity_main
override fun onClick(v: View?) {
}
override fun init() {
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true">
<FrameLayout
android:id="@+id/id_activity_main_fragment_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/id_activity_main_fragment_navigation" />
<com.zxhl.modulemain.view.NavigationBottomView
android:id="@+id/id_activity_main_fragment_navigation"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:clipChildren="false" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_above="@+id/id_activity_main_fragment_navigation"
android:background="#E6E6E6" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">Aprileye</string>
</resources>
\ No newline at end of file
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="android:textColorPrimary">@color/color_000000</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/white</item>
<item name="colorAccent">@color/color_ffc109</item>
<item name="android:windowBackground">@color/white</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="cache"
path="Android/data/com.zxhl.aprileye/" />
<external-path
name="downloadfile"
path="com.zxhl.aprileye/" />
<!--项目中用到的-->
<external-path
name="beta_external_files_path"
path="Android/data/" />
<external-path
name="tt_external_download"
path="Download" />
<external-path name="tt_external_root" path="." />
<external-files-path name="tt_external_files_download" path="Download" />
<files-path name="tt_internal_file_download" path="Download" />
<external-path name="tt_external_root" path="." />
<external-files-path name="tt_external_files_download" path="Download" />
<!--闲玩中用到的-->
<cache-path name="tt_internal_cache_download" path="Download" />
<external-path
name="51xianwan"
path="51xianwan" />
<files-path
name="downloads"
path="downloads" />
<external-cache-path
name="cache_download"
path="download" />
<external-path
name="bullnews"
path="bullnews" />
<external-files-path
name="external_files_pat"
path="Download" />
<external-files-path
name="external_files_midong"
path="Download/external_files/" />
<cache-path
name="apk1"
path="." />
<external-path
name="files_root"
path="Android/data/com.sponsor.hbhunter/" />
<external-path
name="external_storage_root"
path="." />
<external-path
name="Download"
path="aaa" />
<!--头条穿山甲-->
<external-files-path
name="external_files_path"
path="Download" />
<external-path
name="51xianwan"
path="51xianwan" />
<external-path
name="gdt_sdk_download_path"
path="GDTDOWNLOAD" />
<!--科大讯飞-->
<files-path
name="IFly_AD_Download_Path"
path="IFlyAdDownload" />
</paths>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates
overridePins="true"
src="system" />
<certificates
overridePins="true"
src="user" />
</trust-anchors>
</base-config>
</network-security-config>
\ No newline at end of file
package com.zxhl.aprileye
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
\ No newline at end of file
PACKAGE_NAME=com.zxhl.aprileye
VERSION_CODE=1
VERSION_NAME=1.0.0
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
targetSdkVersion = 29
minSdkVersion = 21
compileSdkVersion = 29
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi-v7a', 'arm64-v8a'
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'typedefs.txt'
}
}
ext {
glide_need_version = '4.9.0'
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
api 'com.android.support:design:28.0.0'
api 'com.android.support:support-v4:28.0.0'
api 'org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.71'
api 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
api 'com.trello.rxlifecycle2:rxlifecycle:2.2.0'
api 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.0'
api 'com.squareup.retrofit2:retrofit:2.3.0'
api 'com.squareup.retrofit2:converter-gson:2.3.0'
api 'com.squareup.okhttp3:logging-interceptor:3.4.1'
api 'org.jetbrains.anko:anko-common:0.9'
//友盟
api 'com.badoo.mobile:android-weak-handler:1.1'
api 'com.umeng.umsdk:common:9.4.2'// 必选
api 'com.umeng.umsdk:asms:1.4.1'// 必选
api 'com.umeng.umsdk:share-core:7.1.6'//分享核心库,必选
api 'com.umeng.umsdk:share-wx:7.1.6' //微信完整版
api group: 'com.github.bumptech.glide', name: 'glide', version: '4.9.0'
api 'jp.wasabeef:glide-transformations:2.0.1'
api(name: 'oaid_sdk_1.0.25', ext: 'aar')
api(name: 'tools_release', ext: 'aar')
api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation(name: 'alipaySdk-15.6.4-20190611174341', ext: 'aar')
api 'org.greenrobot:eventbus:3.2.0'
//implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
api 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'
//画廊视图
api 'com.yarolegovich:discrete-scrollview:1.5.1'
//bugly
api 'com.tencent.bugly:crashreport:4.0.4'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zxhl.cms">
<application>
<activity android:name=".udesk.UdeskWebViewActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="udesk"
android:scheme="aprileye" />
</intent-filter>
</activity>
<activity android:name=".common.WebActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="web"
android:scheme="aprileye" />
</intent-filter>
</activity>
<activity android:name=".common.H5Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="h5"
android:scheme="aprileye" />
</intent-filter>
</activity>
<activity android:name=".pay.PayActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="pay"
android:scheme="aprileye" />
</intent-filter>
</activity>
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind"></activity>
<!-- 友盟配置 -->
<meta-data
android:name="UMENG_APPKEY"
android:value="5d0dd39b570df3d7c5000d1a" />
<meta-data
android:name="UMENG_CHANNEL"
android:value="${UMENG_CHANNEL_VALUE}" /> <!-- QQ配置 -->
</application>
</manifest>
package com.ayl.ces.jni
import android.content.Context
import android.util.Log
/**
* Created by gaoleichao on 2018/7/13.
*/
class CesCore {
lateinit var mContext: Context
var isInit: Boolean = false
init {
System.loadLibrary("native-lib")
}
companion object {
/**
* @param
*/
@Volatile
var mCesCore: CesCore? = null
fun getInstance(): CesCore {
if (mCesCore == null) {
synchronized(CesCore::class.java) {
if (mCesCore == null) {
mCesCore = CesCore()
}
}
}
return mCesCore!!
}
}
fun init(context: Context) {
mContext = context
native_init(mContext)
}
fun SmData(): String {
return sm_work(mContext)
}
fun setData(strS: String) {
SetData(strS)
isInit = true
Log.d("splash", "isInit:" + isInit)
}
fun getIsInit(): Boolean {
return isInit
}
private external fun native_init(context: Context?)
private external fun sm_work(context: Context?): String
/////////////////////////////////////
external fun SetData(strSource: String): Boolean
external fun Dowork(src: String, client_no: String): String
external fun Dework(src: String, client_no: String): String
external fun Sgwork(src: String): String
external fun Ckwork(client_no: String): String
external fun Version(): String
}
\ No newline at end of file
package com.zxhl.cms;
import android.content.Context;
/**
* Created by gaoleichao on 2018/12/7.
*/
public class AppContext {
public static Context mAppContext;
public static void init(Context context) {
if (mAppContext == null) {
mAppContext = context.getApplicationContext();
} else {
throw new IllegalStateException("set context duplicate");
}
}
public static Context get() {
if (mAppContext == null) {
throw new IllegalStateException("forget init?");
} else {
return mAppContext;
}
}
}
\ No newline at end of file
package com.zxhl.cms.ad.upload.Utils;
/**
* Created by gaoleichao on 2018/12/3.
*/
public interface AdCallback<T> {
void onResult(int code, T result);
}
package com.zxhl.cms.ad.upload.Utils
import java.util.Comparator
/**
* Created by gaoleichao on 2018/7/13.
*/
class MapKeyComparator : Comparator<String> {
override fun compare(str1: String, str2: String): Int {
return str1.compareTo(str2)
}
}
This diff is collapsed.
package com.zxhl.cms.ad.upload.cache;
import android.content.Context;
import android.text.TextUtils;
import com.zxhl.cms.utils.PhoneUtils;
import com.zxhl.cms.ad.upload.model.ReportAd;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by gaoleichao on 2018/7/14.
*/
public class AdCache {
private static ACache aCache;
private static HashMap aMemory = new HashMap<String, Object>();
private static String ADLOAD_SIZE = "adupload_size";
private static ACache init(Context context) {
if (aCache == null) {
aCache = ACache.get(context);
}
return aCache;
}
public static synchronized String getAdImpressionCount(Context context) {
if (aMemory.containsKey(ADLOAD_SIZE)) {
return (String) aMemory.get(ADLOAD_SIZE);
}
String str = init(context).getAsString(ADLOAD_SIZE);
if (TextUtils.isEmpty(str)) {
return "";
} else {
aMemory.put(ADLOAD_SIZE, str);
return str;
}
}
public static void addAdAdImpression(Context context, ReportAd entity) {
String str = getAdImpressionCount(context);
List<ReportAd> list;
if (!TextUtils.isEmpty(str)) {
list = PhoneUtils.INSTANCE.getAdImpressionList(str);
} else {
list = new ArrayList();
}
list.add(entity);
init(context).put(ADLOAD_SIZE, PhoneUtils.INSTANCE.ListToJson(list));
aMemory.put(ADLOAD_SIZE, PhoneUtils.INSTANCE.ListToJson(list));
}
public static void saveAdImpressionCount(Context context, String data) {
init(context).put(ADLOAD_SIZE, data);
aMemory.put(ADLOAD_SIZE, data);
}
}
\ No newline at end of file
package com.zxhl.cms.ad.upload.model;
import java.util.List;
/**
* Created by gaoleichao on 2018/7/10.
*/
public class EasternNewsEntity {
public int stat = 1;
public String endkey = "";
public String newkey = "";
public List<Data> data;
public class Data {
public String pk;
public String id;
public String ts;
public int hotnews;//是否热点新闻;1:是热点新闻;0:不是热点新闻
public int isrecom;//是否是推荐新闻;1:是推荐新闻;0:不是推荐
public int isvideo;//是否是视频新闻;1:是视频新闻;0:不是视频
public int miniimg_size;
public String rowkey;
public String source;
public String type;
public String topic;
public String url;
public List<Img> lbimg;
public List<Img> miniimg;
}
public class Img {
public String src;
public String imgheight;
public String imgwidth;
}
}
package com.zxhl.cms.ad.upload.model
/**
* Created by gaoleichao on 2018/7/20.
*/
class EncryptEntity{
val encrypt: String = ""
}
\ No newline at end of file
package com.zxhl.cms.ad.upload.model
import java.io.Serializable
/**
* Created by gaoleichao on 2018/7/13.
*/
class NewsEntity : Serializable {
var tab_id: String = ""
var type: Int = 0
var slot_id: String? = ""
var read_num: String? = ""
var read_coins: String? = ""
var adType: Int = 0
var total_read_coins: String? = ""
var codeId: String? = ""
var delay: Int = 0
var redPacketFlag: Int = 0
var author_name: String = ""
var appmodel_id: Int = 0
var slot_ad_type: Int = 0
var category: String? = ""
var timeTrigger: String? = ""
var current_nums: String? = ""
var source: String? = ""
var award_limit: String? = ""
var sourceUrl: String? = ""
var url: String? = ""
var title: String? = ""
var description: String? = ""
var pubDate: String? = ""
var images: List<String>? = null
var icon_url: String? = null
var sid: Int = 0
var tabid: String? = ""
var image_url: String? = ""
var deep_url_re: String? = ""
var incentive_level: Int = 0
var opentype: Int = 0
var alert: String? = ""
var explorerType: String? = ""
var pk: String? = ""
var image_render_type: Int = 0
var position: Int = 0
var isStick: Int = 0
var coins: String? = ""
var pkg: String? = ""
var total_coins: String? = ""
var desc: String? = ""
var redPackageText: String? = ""
var contentType: String? = ""
var clk_tracking: List<String>? = null
var imp_tracking: List<String>? = null
var big_images: List<String>? = null
var downloadSucc: List<String>? = null
var startDownload: List<String>? = null
var appActiveSucc: List<String>? = null
var installSucc: List<String>? = null
var startInstall: List<String>? = null
var clickDownX: String? = ""
var clickDownY: String? = ""
var clickUpX: String? = ""
var clickId: String? = ""
var clickUpY: String? = ""
var progress: String? = ""
var ts: String? = ""
var ad_width: String? = ""
var ad_height: String? = ""
var adMarkImage: String? = ""
var adMark: String? = ""
var label: String? = ""
var videoAdBody: String? = ""
var rowKey: String? = ""
var shareType: String? = ""
var shareUrl: String? = ""
var status: Int = 0
var autoPlay: Int = 0
var quiet: Int = 0
var adPlatform: String? = ""
var clickViewUpY: String? = ""
var clickViewUpX: String? = ""
var clickViewDownY: String? = ""
var clickViewDownX: String? = ""
var cornerText: String? = ""
var isClick: Boolean = false
var isShow: Boolean = false
var miniProgram: MiniPro? = null
var videoSrc: VideoSrc? = null
var isPlaying = false
var showFromFeed: List<String>? = null//曝光信息流
var playFromFeed: List<String>? = null//点击信息流
var showParams: MutableMap<String, String>? = null//曝光信息参数
var playParams: MutableMap<String, String>? = null//点击信息参数
var from: String? = ""
var date: String? = ""//视频发布时间
class Track : Serializable {
var replace: String? = ""
var default: String? = ""
}
class MiniPro : Serializable {
var miniPath: String? = ""
var miniId: String? = ""
var appId: String? = ""
}
class VideoSrc : Serializable {
var videoURL: String? = null
var loadStart: List<String>? = null
var loadFail: List<String>? = null
var loadSuccess: List<String>? = null
var playStart: List<String>? = null
var playComplete: List<String>? = null
var playCancel: List<String>? = null
var followVideoImage: String? = null
var followVideoURL: String? = null
var followVideoH5: String? = null
}
companion object {
const val TYPE_NEWS = 0//新闻
const val TYPE_DSP_AD = 5//DSP广告
const val TYPE_CMS_AD = 3//CMS广告
const val TYPE_VIDEO = 2//视频
const val TYPE_SOGOU_AD = 119//搜狗广告
const val TYPE_FEED_AD = 118//今日头条广告
const val TYPE_PUMA_AD = 126//瑞狮
const val TYPE_GDT_AD = 141//广点通
const val AD_TYPE_SDK = 1
const val AD_TYPE_URL = 2
const val AD_TYPE_API = 3
const val AD_TYPE_SHARE = 4
const val AD_TYPE_WAKEUP = 5
const val AD_TYPE_DOWNLOAD = 6
const val AD_TYPE_MINI_PROGRAM = 8
const val AD_TYPE_VIDEO = 9
const val AD_TYPE_APPMODEL = 7
const val NONE_REDPACKET = 0
const val REDPACKET = 1
}
}
package com.zxhl.cms.ad.upload.model
import java.io.Serializable
/**
* Created by gaoleichao on 2018/7/14.
*/
class ReportAd : Serializable {
var event: String = ""
var slot_id: String = ""
var sid: String = ""
var type: Int = 0
var ts: String = ""
constructor(event: String, slot_id: String, sid: String, type: Int, st: String) {
this.event = event
this.slot_id = slot_id
this.sid = sid
this.type = type
this.ts = st
}
companion object {
val BANNER = 5
val SPLASH = 6
val FEED = 2
val CARD = 3
val SHOW = "show"
val CLICK = "click"
val ADSHARE = "adShare"
val DOWNLOAD = "download"
val INSTALL = "install"
val DEEPCLICK = "deep_click"
}
}
\ No newline at end of file
package com.zxhl.cms.ad.upload.model
import java.io.Serializable
/**
* Created by gaoleichao on 2018/7/13.
*/
class Response<T> {
var status: String? = ""
var msg: String? = ""
var result: Result<T>? = null
inner class Result<T> : Serializable {
var data: T? = null
}
}
package com.zxhl.cms.ad.upload.model
import java.io.Serializable
/**
* Created by gaoleichao on 2018/7/13.
*/
class Response2<T> {
var error: String? = ""
var msg: String? = ""
var result: String? = ""
var request_id: String? = ""
var data: T? = null
}
package com.zxhl.cms.ad.upload.model;
import android.provider.SearchRecentSuggestions;
import java.io.Serializable;
/**
* Copyright @ 2018 Bitgoose All rights reserved.
*
* @class name: WeatherEntity
* @class describe: 天气
* @author: fuxin
* @date: 2018/12/15 下午4:08
*/
public class WeatherEntity implements Serializable {
private String lowTpr;//低温
private String highTpr;//高温
public String getLowTpr() {
return lowTpr;
}
public void setLowTpr(String lowTpr) {
this.lowTpr = lowTpr;
}
public String getHighTpr() {
return highTpr;
}
public void setHighTpr(String highTpr) {
this.highTpr = highTpr;
}
}
package com.zxhl.cms.common
import android.app.Application
/**
* Created by gaoleichao on 2018/12/26
*/
interface ApplicationAsLibrary {
fun onCreateAsLibrary(application: Application)
fun onLowMemoryAsLibrary(application: Application)
fun onTrimMemoryAsLibrary(application: Application, level: Int)
}
\ No newline at end of file
package com.zxhl.cms.common
import android.content.Context
import android.os.Build
import com.ayl.ces.jni.CesCore
import com.zxhl.cms.AppContext
import com.zxhl.cms.utils.LogUtils
import com.zxhl.cms.utils.PhoneUtils
import org.jetbrains.anko.doAsync
/**
* Created by gaoleichao on 2018/7/12.
*/
class Config {
companion object {
fun init(context: Context) {
doAsync {
CesCore.getInstance().init(AppContext.mAppContext)
Constant.Param.vendor = Build.MANUFACTURER
Constant.Param.svn = android.os.Build.VERSION.SDK_INT.toString()
Constant.Param.model = PhoneUtils.getModel()
Constant.Param.androidId = PhoneUtils.getAndroidID(context)
Constant.Param.carrier = PhoneUtils.getOperator(context)
Constant.Param.w = PhoneUtils.getScreenWidth(context).toString()
Constant.Param.h = PhoneUtils.getScreenHeight(context).toString()
Constant.Param.vc = PhoneUtils.getAppVersionCode(context).toString()
Constant.Param.vn = PhoneUtils.getAppVersionName(context)
Constant.Param.device = PhoneUtils.getDeviceId(context)
Constant.Param.imei = PhoneUtils.getImei(context)
// Constant.Param.ssid = PhoneUtils.getBSSID(context)
// if (!TextUtils.isEmpty(Constant.Param.ssid)) {
// Constant.Param.ssid.replace(":", "")
// }
Constant.Param.ua = System.getProperty("http.agent")
Constant.Param.ntt = PhoneUtils.getNetworkType(context)?.toString()
Constant.Param.miToken = PhoneUtils.getDeviceToken(context)
// uiThread {
// LocationProvider.getInstance(context).startLocation()
// }
Constant.Param.imsi = PhoneUtils.getIMSI(context)
// Constant.Param.mac = PhoneUtils.getMac(context) ?: ""
// Constant.Param.env = CesCore.getInstance().Ckwork(Constant.Param.androidId)
LogUtils.d("Param", "Param.androidId: " + Constant.Param.androidId)
LogUtils.d("Param", "Param.carrier: " + Constant.Param.carrier)
LogUtils.d("Param", "Param.w: " + Constant.Param.w)
LogUtils.d("Param", "Param.h: " + Constant.Param.h)
LogUtils.d("Param", "Param.model: " + Constant.Param.model)
LogUtils.d("Param", "Param.vc: " + Constant.Param.vc)
LogUtils.d("Param", "Param.device: " + Constant.Param.device)
LogUtils.d("Param", "Param.imei: " + Constant.Param.imei)
LogUtils.d("Param", "Param.mac: " + Constant.Param.mac)
LogUtils.d("Param", "Param.ua: " + Constant.Param.ua)
LogUtils.d("Param", "Param.ntt: " + Constant.Param.ntt)
LogUtils.d("Param", "Param.svn: " + Constant.Param.svn)
LogUtils.d("Param", "Param.vendor: " + Constant.Param.vendor)
LogUtils.d("Param", "Param.imsi: " + Constant.Param.imsi)
LogUtils.d("Param", "Param.miToken: " + Constant.Param.miToken)
LogUtils.d("Param", "Param.env: " + Constant.Param.env)
// AdConstant.param.androidId = Constant.Param.androidId
// AdConstant.param.carrier = Constant.Param.carrier
// AdConstant.param.w = Constant.Param.w
// AdConstant.param.h = Constant.Param.h
// AdConstant.param.model = Constant.Param.model
// AdConstant.param.vc = Constant.Param.vc
// AdConstant.param.device = Constant.Param.device
// AdConstant.param.imei = Constant.Param.imei
// AdConstant.param.mac = Constant.Param.mac
// AdConstant.param.ua = Constant.Param.ua
// AdConstant.param.ntt = Constant.Param.ntt
// AdConstant.param.svn = Constant.Param.svn
// AdConstant.param.imsi = Constant.Param.imsi
// AdConstant.param.env = Constant.Param.env
// AdManager.init(context, Constant.Param.APPLS)
}
}
}
}
\ No newline at end of file
This diff is collapsed.
package com.zxhl.cms.common
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.zxhl.cms.common.base.BaseFragment
import java.util.*
/**
* Created by gaoleichao on 2018/10/11.
*/
class FragmentAdapter : FragmentPagerAdapter {
private val mCateInfoBase = ArrayList<BaseFragment>()
private val mTitleList = ArrayList<String>()
constructor(fm: FragmentManager?) : super(fm!!)
override fun getItem(position: Int): Fragment {
return mCateInfoBase[position]
}
fun addFrag(fragment: BaseFragment?) {
if (fragment != null) {
mCateInfoBase.add(fragment)
}
}
fun addFrag(fragment: BaseFragment?, title: String) {
if (fragment != null) {
mCateInfoBase.add(fragment)
mTitleList.add(title)
}
}
fun clear() {
mCateInfoBase.clear()
}
override fun getPageTitle(position: Int): CharSequence? {
return mTitleList[position]
}
override fun getCount(): Int {
return mCateInfoBase.size
}
override fun getItemId(position: Int): Long {
// 获取当前数据的hashCode
val hashCode: Int = mCateInfoBase.get(position).hashCode()
return hashCode.toLong()
}
override fun destroyItem(container: ViewGroup, position: Int, obj: Any) {
//如果注释这行,那么不管怎么切换,page都不会被销毁
// super.destroyItem(container, position, obj)
}
}
\ No newline at end of file
package com.zxhl.cms.common
import android.content.Intent
import android.net.Uri
import android.net.http.SslError
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.webkit.*
import androidx.appcompat.app.AppCompatActivity
import com.zxhl.cms.R
import com.zxhl.cms.utils.EventUtils
import kotlinx.android.synthetic.main.activity_h5.*
class H5Activity : AppCompatActivity() {
var mWebView: WebView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_h5)
initData()
}
private fun initData() {
id_activity_web_toolbar?.setNavigationOnClickListener { finish() }
val url = intent?.data?.getQueryParameter("url") ?: ""
mWebView = findViewById(R.id.id_activity_web_view)
id_activity_web_view?.loadUrl(url)
initWebView()
}
fun initWebView() {
val webSettings = mWebView!!.getSettings()
//如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
webSettings.javaScriptEnabled = true
// 若加载的 html 里有JS 在执行动画等操作,会造成资源浪费(CPU、电量)
// 在 onStop 和 onResume 里分别把 setJavaScriptEnabled() 给设置成 false 和 true 即可
//设置自适应屏幕,两者合用
webSettings.useWideViewPort = true //将图片调整到适合webview的大小
webSettings.loadWithOverviewMode = true // 缩放至屏幕的大小
//缩放操作
webSettings.setSupportZoom(true) //支持缩放,默认为true。是下面那个的前提。
webSettings.builtInZoomControls = true //设置内置的缩放控件。若为false,则该WebView不可缩放
webSettings.displayZoomControls = false //隐藏原生的缩放控件
//其他细节操作
webSettings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK //关闭webview中缓存
webSettings.allowFileAccess = true //设置可以访问文件
webSettings.javaScriptCanOpenWindowsAutomatically = true //支持通过JS打开新窗口
webSettings.loadsImagesAutomatically = true //支持自动加载图片
webSettings.defaultTextEncodingName = "utf-8" //设置编码格式
webSettings.domStorageEnabled = true
mWebView?.setWebChromeClient(object : WebChromeClient() {
override fun onJsAlert(
view: WebView?,
url: String?,
message: String?,
result: JsResult
): Boolean {
result.confirm()
return true
}
override fun onPermissionRequest(request: PermissionRequest) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
request.grant(request.resources)
request.origin
}
}
override fun onProgressChanged(view: WebView?, newProgress: Int) {
super.onProgressChanged(view, newProgress)
if (newProgress == 100) {
id_webview_progress_view.visibility = View.GONE
} else {
id_webview_progress_view.visibility = View.VISIBLE
id_webview_progress_view.progress = newProgress
}
}
})
mWebView?.setWebViewClient(object : WebViewClient() {
override fun shouldOverrideUrlLoading(wv: WebView, url: String): Boolean {
Log.e("MXL", "URL" + url)
if (url == null) return false
try {
if (url.startsWith("weixin://") //微信
|| url.startsWith("alipays://") //支付宝
|| url.startsWith("mailto://") //邮件
|| url.startsWith("tel://") //电话
|| url.startsWith("dianping://") //大众点评
|| url.startsWith("tbopen://") //淘宝
|| url.startsWith("openapp.jdmobile://") //淘宝
|| url.startsWith("tmast://") //淘宝
|| url.startsWith("pinduoduo://") //拼多多
|| url.startsWith("imeituan://") //美团
//其他自定义的scheme
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
return true
}
} catch (e: Exception) { //防止crash (如果手机上没有安装处理某个scheme开头的url的APP, 会导致crash)
return true //没有安装该app时,返回true,表示拦截自定义链接,但不跳转,避免弹出上面的错误页面
}
//处理http和https开头的url
// wv.loadUrl(url)
return false
}
override fun onReceivedSslError(
view: WebView,
handler: SslErrorHandler,
error: SslError
) {
handler.proceed()
}
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
error: WebResourceError?
) {
super.onReceivedError(view, request, error)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
Log.d("wxw", "1error${error?.errorCode}")
Log.d("wxw", "2error${error?.description}")
} else {
}
}
})
}
var firstLoad: Boolean = false
override fun onPause() {
super.onPause()
firstLoad = true
}
override fun onResume() {
super.onResume()
if (firstLoad) {
//从支付宝回来
Log.e("MXL", "从支付宝回来")
finish()
}
}
}
\ No newline at end of file
This diff is collapsed.
package com.zxhl.cms.common;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.webkit.PermissionRequest;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import androidx.annotation.NonNull;
public class PaxWebChromeClient extends WebChromeClient {
private static final int CHOOSE_REQUEST_CODE = 0x9001;
private Activity mActivity;
private ValueCallback<Uri> uploadFile;//定义接受返回值
private ValueCallback<Uri[]> uploadFiles;
private LoadingCallBack mLoadingCallBack;
public interface LoadingCallBack {
void onProgress(int progress);
}
public PaxWebChromeClient(@NonNull Activity mActivity, LoadingCallBack callBack) {
this.mActivity = mActivity;
mLoadingCallBack = callBack;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onPermissionRequest(PermissionRequest request) {
// super.onPermissionRequest(request);//必须要注视掉
request.grant(request.getResources());
}
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (mLoadingCallBack != null) {
mLoadingCallBack.onProgress(newProgress);
}
}
// For Android 3.0+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
this.uploadFile = uploadFile;
openFileChooseProcess();
}
// For Android < 3.0
public void openFileChooser(ValueCallback<Uri> uploadMsgs) {
this.uploadFile = uploadFile;
openFileChooseProcess();
}
// For Android > 4.1.1
// @Override
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
this.uploadFile = uploadFile;
openFileChooseProcess();
}
// For Android >= 5.0
@Override
public boolean onShowFileChooser(WebView webView,
ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {
this.uploadFiles = filePathCallback;
openFileChooseProcess();
return true;
}
private void openFileChooseProcess() {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
mActivity.startActivityForResult(Intent.createChooser(i, "Choose"), CHOOSE_REQUEST_CODE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// LogCat.d("requestCode===",requestCode+"====");
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case CHOOSE_REQUEST_CODE:
if (null != uploadFile) {
Uri result = data == null || resultCode != Activity.RESULT_OK ? null
: data.getData();
uploadFile.onReceiveValue(result);
uploadFile = null;
}
if (null != uploadFiles) {
Uri result = data == null || resultCode != Activity.RESULT_OK ? null
: data.getData();
uploadFiles.onReceiveValue(new Uri[]{result});
uploadFiles = null;
}
break;
default:
break;
}
} else if (resultCode == Activity.RESULT_CANCELED) {
if (null != uploadFile) {
uploadFile.onReceiveValue(null);
uploadFile = null;
}
if (null != uploadFiles) {
uploadFiles.onReceiveValue(null);
uploadFiles = null;
}
}
}
}
\ No newline at end of file
package com.zxhl.cms.common
import android.content.Intent
import android.net.Uri
import android.net.http.SslError
import android.os.Build
import android.util.Log
import android.view.View
import android.webkit.SslErrorHandler
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import com.zxhl.cms.R
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.utils.FileUtils
import kotlinx.android.synthetic.main.activity_h5.*
import kotlinx.android.synthetic.main.activity_member.*
import kotlinx.android.synthetic.main.activity_web.*
import kotlinx.android.synthetic.main.activity_web.id_activity_web_title
import kotlinx.android.synthetic.main.activity_web.id_activity_web_toolbar
import kotlinx.android.synthetic.main.activity_web.id_activity_web_view
class WebActivity : BaseActivity() {
private var chromeClient: PaxWebChromeClient? = null
override fun onClick(p0: View?) {
}
override fun layoutID(): Int = R.layout.activity_web
override fun init() {
id_activity_web_toolbar?.setNavigationOnClickListener { finish() }
val title = intent?.data?.getQueryParameter("title") ?: ""
val url = intent?.data?.getQueryParameter("url") ?: ""
Log.e("MXL", "url" + url)
initWebView()
id_activity_web_title?.text = title
id_activity_web_view?.loadUrl(url)
}
private fun initWebView() {
val settings = id_activity_web_view?.settings
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
settings?.mediaPlaybackRequiresUserGesture = true//设置视频不自动播放
}
chromeClient = PaxWebChromeClient(this) {
if (it == 100) {
id_web_view_progress_view.visibility = View.GONE
} else {
id_web_view_progress_view.visibility = View.VISIBLE
id_web_view_progress_view.progress = it
}
}
settings?.javaScriptCanOpenWindowsAutomatically = true//支持js自动弹框
settings?.setSupportZoom(true) //支持缩放
settings?.setNeedInitialFocus(false)
settings?.allowFileAccess = true
settings?.setRenderPriority(WebSettings.RenderPriority.HIGH)
settings?.builtInZoomControls = true//支持手势缩放
settings?.displayZoomControls = false //是否显示缩放按钮
// >= 19(SDK4.4)启动硬件加速,否则启动软件加速
settings?.loadsImagesAutomatically = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
settings?.useWideViewPort = true //设置内容自适应屏幕大小
settings?.loadWithOverviewMode = true
settings?.saveFormData = true
settings?.cacheMode = WebSettings.LOAD_NO_CACHE
settings?.setEnableSmoothTransition(true)
settings?.setSupportMultipleWindows(false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
settings?.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
settings?.mediaPlaybackRequiresUserGesture = false
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true)
}
// support android API 7-
try {
// API 7, LocalStorage/SessionStorage
settings?.domStorageEnabled = true
settings?.databaseEnabled = true
settings?.databasePath = FileUtils.getWebViewCacheDiectory()
// API 7, Web SQL Database, 需要重载方法(WebChromeClient)才能生效,无法只通过反射实现
} catch (e: Exception) {
}
try {
// API 7, Application Storage
settings?.setAppCacheEnabled(true)
settings?.setAppCachePath(FileUtils.getWebViewCacheDiectory())
settings?.setAppCacheMaxSize(5 * 1024 * 1024)
} catch (e: Exception) {
}
try {
// API 5, Geolocation
settings?.setGeolocationEnabled(true)
settings?.setGeolocationDatabasePath(FileUtils.getWebViewCacheDiectory())
} catch (e: Exception) {
}
id_activity_web_view?.isHorizontalScrollBarEnabled = false
id_activity_web_view?.overScrollMode = View.OVER_SCROLL_NEVER // 取消WebView中滚动或拖动到顶部、底部时的阴影
id_activity_web_view?.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
// settings.userAgentString = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; zh-tw) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16"
//注意:以下两项是必须设置,其他设置选项根据自身项目需求进行配置
settings?.javaScriptEnabled = true
id_activity_web_view?.webChromeClient = chromeClient
id_pay_web_view?.setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
Log.e("MXL", "Download " + url)
var intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent);
}
id_activity_web_view?.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(wv: WebView, url: String?): Boolean {
Log.e("MXL", "AURL " + url)
if (url == null) return false
try {
if (url.startsWith("weixin://") //微信
|| url.startsWith("alipays://") //支付宝
|| url.startsWith("mqq://") //QQ
|| url.startsWith("youku://") //QQ
|| url.startsWith("mailto://") //邮件
|| url.startsWith("tel://") //电话
|| url.startsWith("dianping://") //大众点评
|| url.startsWith("tbopen://") //淘宝
|| url.startsWith("openapp.jdmobile://") //京东
|| url.startsWith("tmast://") //淘宝
|| url.startsWith("pinduoduo://") //拼多多
|| url.startsWith("imeituan://") //美团
//其他自定义的scheme
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
return true
}
} catch (e: Exception) { //防止crash (如果手机上没有安装处理某个scheme开头的url的APP, 会导致crash)
return true //没有安装该app时,返回true,表示拦截自定义链接,但不跳转,避免弹出上面的错误页面
}
//处理http和https开头的url
// wv.loadUrl(url)
return false
}
override fun onReceivedSslError(
view: WebView?,
handler: SslErrorHandler,
error: SslError?
) {
handler.proceed()
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
chromeClient?.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data)
}
}
This diff is collapsed.
package com.zxhl.cms.common.base;
import android.app.Application;
import com.zxhl.cms.common.ApplicationAsLibrary;
/**
* Created by gaoleichao on 2018/12/26
*/
public class BaseChildApplication extends Application implements ApplicationAsLibrary {
@Override public void onCreate() {
super.onCreate();
onCreateAsLibrary(this);
}
@Override public void onLowMemory() {
super.onLowMemory();
onLowMemoryAsLibrary(this);
}
@Override public void onTrimMemory(int level) {
super.onTrimMemory(level);
onTrimMemoryAsLibrary(this, level);
}
@Override public void onCreateAsLibrary(Application application) {
}
@Override public void onLowMemoryAsLibrary(Application application) {
}
@Override public void onTrimMemoryAsLibrary(Application application, int level) {
}
}
\ No newline at end of file
package com.zxhl.cms.common.base;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.bumptech.glide.Glide;
import com.google.android.material.snackbar.Snackbar;
import com.zxhl.cms.common.Constant;
import com.zxhl.cms.utils.Utils;
import com.trello.rxlifecycle2.components.support.RxFragment;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* Created by gaoleichao on 2018/5/2.
*/
public abstract class BaseFragment extends RxFragment {
public Activity mActivity;
public View fragmentView;
protected boolean isInitial = false;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
before();
if (fragmentView == null && layoutID() > 0) {
fragmentView = inflater.inflate(layoutID(), container, false);
}
after(fragmentView);
return fragmentView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
isInitial = true;
init(fragmentView);
data();
}
protected void before() {
}
protected void after(View view) {
mActivity = getActivity();
}
public abstract int layoutID();
public abstract void init(View view);
public void data() {
}
public void destoryView() {
Utils.destory(fragmentView);
}
public void openActivity(Class<?> pClass) {
openActivity(pClass, null);
}
public void openActivity(Class<?> pClass, Bundle pBundle) {
Intent intent = new Intent(getActivity(), pClass);
if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
// overridePendingTransition(R.anim.slide_in_right,
// R.anim.activity_close_enter);
}
/**
* 启动Activity
*/
protected void openActivity(String pAction) {
openActivity(pAction, null);
}
/**
* 启动Activity
*/
protected void openActivity(String pAction, Bundle pBundle) {
Intent intent = new Intent(pAction);
if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
// overridePendingTransition(R.anim.slide_in_right,
// R.anim.activity_close_enter);
}
/**
* 短时间显示Toast
*
* @param info 显示的内容
*/
public void showToast(String info) {
Context context = getActivity();
// 防止未Attach到界面上时,getActivity为空
if (context != null) {
Utils.showToast(context, info);
}
}
public void showSnake(View view, String info) {
Snackbar.make(view, info, Snackbar.LENGTH_LONG).show();
}
public void showSnake(View view, String info, String actionInfo, View.OnClickListener listener) {
Snackbar.make(view, info, Snackbar.LENGTH_LONG).setAction(actionInfo, listener).show();
}
/**
* 短时间显示Toast
*
* @param resId 显示的内容
*/
public void showToast(int resId) {
showToast(getString(resId));
}
public void showSnackbar(@NonNull String text) {
showSnackbar(text, "", null);
}
public void showSnackbar(@NonNull String text, @NonNull String actionStr, View.OnClickListener listener) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
showSnackbar(new View(getContext()), text, actionStr, listener);
}
}
public void showSnackbar(@NonNull View view, @NonNull String text, @NonNull String actionStr, View.OnClickListener listener) {
Snackbar.make(view, text, Snackbar.LENGTH_LONG).setAction(actionStr, listener).show();
}
protected boolean hasLiveProcess() {
android.app.ActivityManager appAM = (android.app.ActivityManager) getActivity().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
for (android.app.ActivityManager.RunningAppProcessInfo appProcess : appAM.getRunningAppProcesses()) {
if (appProcess.processName.contains(":live")) {
return true;
}
}
return false;
}
// 检测MIUI
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
public boolean isNeedAdapterPhone() {
return Build.VERSION.SDK_INT < 21;
// if (SettingPreference.isSaveNeedAdapterPhone(getContext())) {
// return SettingPreference.isNeedAdapterPhone(getContext());
// }
// boolean b = isMIUI() || isFuckPhone();
// SettingPreference.setIsSaveNeedAdapterPhone(getContext(), true);
// SettingPreference.setIsNeedAdapterPhone(getContext(), b);
//
// return b;
}
private boolean isFuckPhone() {
if (Build.VERSION.SDK_INT < 21) {// && !str.contains("nexus")
return true;
} else {
return false;
}
}
//是否小米手机
private boolean isMIUI() {
Properties prop = new Properties();
boolean isMIUI;
try {
prop.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));
} catch (IOException e) {
e.printStackTrace();
return false;
}
isMIUI = prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null;
return isMIUI;
}
protected boolean isVisible = false;
/**
* 设置状态栏背景色
*
* @param color
*/
protected void setStatusBarBackground(int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//注意要清除 FLAG_TRANSLUCENT_STATUS flag
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getActivity().getWindow().setStatusBarColor(color);
}
}
protected void onVisible() {
lazyLoad();
}
protected void lazyLoad() {
}
protected void onInvisible() {
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (getActivity() != null) {
Glide.get(getActivity()).clearMemory();
}
}
/**
* 在这里实现Fragment数据的缓加载.
*
* @param isVisibleToUser
*/
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
isVisible = isVisibleToUser;
if (isVisible) {
onVisible();
} else {
onInvisible();
}
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);{
isVisible = !hidden;
if (isVisible) {
onVisible();
} else {
onInvisible();
}
}
}
}
\ No newline at end of file
package com.zxhl.cms.common.base;
import androidx.recyclerview.widget.RecyclerView;
import java.util.LinkedList;
import java.util.List;
/**
* Created by gaoleichao on 2018/1/7.
*/
public abstract class BaseRecyclerAdapter<T, H extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<H> {
protected final List<T> mList = new LinkedList<>();
protected int mRecommendPosition;
/**
* 获取列表数据
*/
public List<T> getList() {
return mList;
}
public void onMove(int fromPosition, int toPosition) {
}
public int getmRecommendPosition() {
return mRecommendPosition;
}
public void setmRecommendPosition(int mRecommendPosition) {
this.mRecommendPosition = mRecommendPosition;
}
public void appendToTop(T t) {
if (t == null) {
return;
}
mList.add(0, t);
notifyItemInserted(0);
}
public void append(T t) {
if (t == null) {
return;
}
mList.add(t);
notifyDataSetChanged();
}
public void replaceItem(int position, T item) {
if (position >= 0) {
mList.set(position, item);
}
}
public void removieBottom() {
if (mList.size() > 0) {
mList.remove(mList.size() - 1);
notifyDataSetChanged();
}
}
public void removieByIndex(int index) {
mList.remove(index);
notifyItemRemoved(index);
notifyDataSetChanged();
}
/**
* 追加数据
*
* @param list
*/
public void appendToList(List<T> list) {
if (list == null) {
return;
}
mList.addAll(list);
notifyItemRangeInserted(getItemCount(), list.size());
}
/**
* 追加数据
*
* @param list
*/
public void appendToTopList(List<T> list) {
if (list == null) {
return;
}
mList.addAll(0, list);
notifyDataSetChanged();
}
/**
* 清空数据
*/
public void clear() {
int i = getItemCount();
mList.clear();
// notifyItemRangeRemoved(0, i);
notifyDataSetChanged();
}
public void deleteAll() {
mList.clear();
}
public void replace(List<T> list) {
if (list == null) {
return;
}
mList.clear();
mList.addAll(0, list);
notifyDataSetChanged();
}
/**
* 获取数量
*/
@Override
public int getItemCount() {
// TODO Auto-generated method stub
return mList.size();
}
/**
* 根据position 获取单个对象
*/
public T getItem(int position) {
// TODO Auto-generated method stub
if (position >= 0 && position < mList.size()) {
return mList.get(position);
} else {
return null;
}
}
/**
* 获取position
*/
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
}
package com.zxhl.cms.common.base;
import android.content.Intent;
import android.view.View;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMAuthListener;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareConfig;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.zxhl.cms.R;
import com.zxhl.cms.common.Constant;
import com.zxhl.cms.widget.LoadingDialog;
import java.util.Map;
/**
* Created by gaoleichao on 2018/6/20.
*/
public abstract class WxImpl extends BaseActivity implements UMAuthListener {
protected UMShareAPI mShareAPI;
protected LoadingDialog mLoading;
@Override
public int layoutID() {
return 0;
}
@Override
public void init() {
// PlatformConfig.setWeixin(Constant.Key.WX_LOGIN_APP_ID, Constant.Key.WX_LOGIN_KEY);
mShareAPI = UMShareAPI.get(getApplicationContext());
mLoading = LoadingDialog.getLoadingDialog(this, getString(R.string.wait_ing), false, false);
}
@Override
public void onClick(View v) {
}
protected void onWxLogin() {
mLoading.setLoading(getString(R.string.login_ing));
mLoading.show();
UMShareConfig config = new UMShareConfig();
config.isNeedAuthOnGetUserInfo(true);
mShareAPI.setShareConfig(config);
mShareAPI.getPlatformInfo(this, SHARE_MEDIA.WEIXIN, this);
}
protected void onAuth() {
mLoading.setLoading(getString(R.string.auth_ing));
mLoading.show();
UMShareConfig config = new UMShareConfig();
config.isNeedAuthOnGetUserInfo(true);
mShareAPI.getPlatformInfo(this, SHARE_MEDIA.WEIXIN, this);
}
@Override
public void onStart(SHARE_MEDIA share_media) {
}
@Override
public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> data) {
onWxSuccess(data.get("access_token"), data.get("openid"));
}
@Override
public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
mLoading.setResult(false, "没有安装微信", 1000);
}
@Override
public void onCancel(SHARE_MEDIA share_media, int i) {
mLoading.setResult(false, "授权取消", 1000);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}catch (Exception ex){
}
}
public abstract void onWxSuccess(String token, String openid);
}
package com.zxhl.cms.db;
/**
* Created by gaoleichao on 2018/10/29.
*/
public interface DBCallback<T> {
void onResult(int code, T result);
}
package com.zxhl.cms.db;
/**
* Created by gaoleichao on 2018/10/29.
*/
public final class DBConfig {
public static final String DB_TRUE = "1";
public static final String DB_FALSE = "0";
/* database name */
public static final String DB_NAME = "localnews_database";
/* database version code */
public static final int DB_VERSION = 1; //数据库表添加一列,升级数据库
/* database table names */
public static final String CLICK_AD_TABLE_NAME = "click_ad_list";//点点赚
public static final String NEWS_AND_AD_TABLE_NAME = "news_and_ad_list";//资讯和广告列表
public static final String NEWS_TAB_TABLE_NAME = "news_tab_list";//资讯和广告列表
public static final String STEP_TABLE_NAME = "step_table_name";//资讯和广告列表
public static final String USERCENTER_APLI_TABLE_NAME = "usercenter_apli_list";//用户中心应用模块列表
public static final String USERCENTER_SETTING_TABLE_NAME = "usercenter_setting_list";//用户中心我的阅读
public static final String WATCH_OR_CLICK_OR_TIMER_AD_TABLE_NAME = "watch_or_click_or_timer_list";//看看赚
public static final String NEWS_READ_HISTORY_TABLE_NAME = "news_history_list";//资讯阅读历史
/* VideoDetail db fields */
public static final String CONTENT = "content"; //内容
public static final String CONTENTID = "content_id"; //内容
public static final String ID = "id"; //id
static final String CREATE_CLICK_AD_TABLE_SQL =
"create table " + CLICK_AD_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENT + " TEXT" +
")";
static final String CREATE_WATCH_AD_TABLE_SQL =
"create table " + WATCH_OR_CLICK_OR_TIMER_AD_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
static final String CREATE_NEWS_OR_AD_TABLE_SQL =
"create table " + NEWS_AND_AD_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
static final String CREATE_NEWS_TAB_LIST_TABLE_SQL =
"create table " + NEWS_TAB_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENT + " TEXT" +
")";
static final String CREATE_STEP_TABLE_SQL =
"create table " + STEP_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
static final String CREATE_USERCENTER_SETTING_TABLE_SQL =
"create table " + USERCENTER_SETTING_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
static final String CREATE_USERCENTER_APLI_TABLE_SQL =
"create table " + USERCENTER_APLI_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
static final String CREATE_NEWS_READ_HISTORY_TABLE_SQL =
"create table " + NEWS_READ_HISTORY_TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT," +
CONTENTID + " varchar2(1000)," +
CONTENT + " TEXT" +
")";
}
package com.zxhl.cms.db;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by gaoleichao on 2018/10/29.
*/
class DataHelper extends SQLiteOpenHelper {
DataHelper(Context context) {
this(context, DBConfig.DB_NAME, null, DBConfig.DB_VERSION);
}
private DataHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
public DataHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int
version, DatabaseErrorHandler errorHandler) {
super(context, name, factory, version, errorHandler);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DBConfig.CREATE_CLICK_AD_TABLE_SQL);
db.execSQL(DBConfig.CREATE_WATCH_AD_TABLE_SQL);
db.execSQL(DBConfig.CREATE_NEWS_OR_AD_TABLE_SQL);
db.execSQL(DBConfig.CREATE_NEWS_TAB_LIST_TABLE_SQL);
db.execSQL(DBConfig.CREATE_STEP_TABLE_SQL);
db.execSQL(DBConfig.CREATE_USERCENTER_SETTING_TABLE_SQL);
db.execSQL(DBConfig.CREATE_USERCENTER_APLI_TABLE_SQL);
db.execSQL(DBConfig.CREATE_NEWS_READ_HISTORY_TABLE_SQL);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
// //数据库升级
}
}
\ No newline at end of file
package com.zxhl.cms.db;
import android.content.Context;
import com.zxhl.cms.AppContext;
/**
* Created by gaoleichao on 2018/10/29.
*/
public class DataSupport {
private static DataSupport dataSupport;
private DataHelper dataHelper;
/**
* @param context
*/
public static void init(Context context) {
if (dataSupport == null) {
synchronized (DataSupport.class) {
if (dataSupport == null) dataSupport = new DataSupport(context);
}
}
}
private DataSupport(Context context) {
dataHelper = new DataHelper(context);
}
/**
* 更新
*
* @param tableName
* @return
*/
public static SqlBuilder update(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withTable(tableName)
.withSqlAction(SqlExcuters.ACTION_UPDATE)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 删除
*
* @param tableName
* @return
*/
public static SqlBuilder delete(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_DEL)
.withTable(tableName)
.withValue(null)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 插入
*
* @param tableName
* @return
*/
public static SqlBuilder insert(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_INSERT)
.withTable(tableName)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 查找
*
* @param tableName
* @return
*/
public static SqlBuilder search(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_SELECT)
.withTable(tableName)
.withValue(null)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 插入全部
*
* @param tableName
* @return
*/
public static SqlBuilder insertAll(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_INSERT_ALL)
.withTable(tableName)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 插入或更新
*
* @param tableName
* @return
*/
public static SqlBuilder insertOrUpdate(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_INSERT_OR_UPDATE)
.withTable(tableName)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
/**
* 插入或替换
*
* @param tableName
* @return
*/
public static SqlBuilder insertOrReplace(String tableName) {
if (dataSupport == null) {
DataSupport.init(AppContext.get());
}
return SqlBuilder.create()
.withSqlAction(SqlExcuters.ACTION_INSERT_OR_REPLACE)
.withTable(tableName)
.withDatabase(dataSupport.dataHelper.getWritableDatabase());
}
}
package com.zxhl.cms.db;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
/**
* Created by gaoleichao on 2018/10/29.
*/
public class SqlBuilder {
private String mTableName; // 表名称
private int mAction; // 数据库操作事件
private ContentValues mValues; // 更新的数据集
private ContentValues[] valueArray; // 更新的数据集队列
private DBCallback<String> mCallback; // 数据库事件回调接口
private SQLiteDatabase mDatabase; // SqliteDatabase实例
private SqlCondition mCondition; // 搜索条件
private boolean isSingle = true;
private SqlBuilder() {
}
SqlBuilder withDatabase(SQLiteDatabase database) {
mDatabase = database;
return this;
}
static SqlBuilder create() {
return new SqlBuilder();
}
SqlBuilder withSqlAction(int action) {
mAction = action;
return this;
}
SqlBuilder withTable(String table) {
mTableName = table;
return this;
}
public SqlBuilder withValue(ContentValues contentValues) {
mValues = contentValues;
isSingle = true;
return this;
}
public SqlBuilder withValues(ContentValues[] contentValues) {
valueArray = contentValues;
isSingle = false;
return this;
}
public SqlBuilder withCallback(DBCallback<String> callback) {
mCallback = callback;
return this;
}
public SqlCondition condition() {
if (mCondition == null) {
mCondition = SqlCondition.prepare(this);
}
return mCondition;
}
public void excute() {
SqlExcuters.excute(mAction, mTableName, mDatabase, mCondition, isSingle ?mValues : valueArray,
mCallback);
}
}
package com.zxhl.cms.db;
import java.util.HashMap;
/**
* Created by gaoleichao on 2018/10/29.
*/
public class SqlCondition {
private HashMap<String, String> conditionClause = new HashMap<>();
private String orderBy = null;
private String groupBy = null;
private String limit = null;
private String[] select = null;
private boolean distinct = false;
private SqlBuilder sqlBuilder;
public static SqlCondition prepare(SqlBuilder sqlBuilder) {
return new SqlCondition(sqlBuilder);
}
private SqlCondition(SqlBuilder builder) {
sqlBuilder = builder;
}
public SqlBuilder build() {
if (sqlBuilder == null) {
return SqlBuilder.create();
}
return sqlBuilder;
}
String[] getSelect() {
return select;
}
String getOrderBy() {
return orderBy;
}
String getGroupBy() {
return groupBy;
}
String getLimit() {
return limit;
}
Boolean getDistinct() {
return distinct;
}
String getClause() {
StringBuilder builder = new StringBuilder();
for (String key : conditionClause.keySet()) {
if (builder.length() > 0) {
builder.append(" and ");
}
builder.append(key);
}
return builder.toString();
}
String[] getArgs() {
return conditionClause.values().toArray(new String[]{});
}
public SqlCondition select(String[] fields) {
select = fields;
return this;
}
public SqlCondition eq(String field, String value) {
conditionClause.put(field + " = ? ", value);
return this;
}
public SqlCondition noteq(String field, String value) {
conditionClause.put(field + " != ? ", value);
return this;
}
public SqlCondition gt(String field, String value) {
conditionClause.put(field + " > ? ", value);
return this;
}
public SqlCondition lt(String field, String value) {
conditionClause.put(field + " < ? ", value);
return this;
}
public SqlCondition ge(String field, String value) {
conditionClause.put(field + " >= ? ", value);
return this;
}
public SqlCondition le(String field, String value) {
conditionClause.put(field + " <= ? ", value);
return this;
}
public SqlCondition like(String field, String value) {
conditionClause.put(field + " like ?", "%" + value + "%");
return this;
}
public SqlCondition OrderBy(String field) {
orderBy = field;
return this;
}
public SqlCondition groupBy(String value) {
groupBy = value;
return this;
}
public SqlCondition limit(String value) {
limit = value;
return this;
}
public SqlCondition Distinct(boolean vlaue) {
distinct = vlaue;
return this;
}
}
This diff is collapsed.
package com.zxhl.cms.down
class UpdateVersionContract {
interface View {
fun showMandatoryUpdateDialog(title: String, desc: String)
fun showNonMandatoryUpdateDialog(title: String, desc: String)
fun onNoUpdate()
fun onDownloadError()
fun onDownloadComplete(path: String)
fun onDownloadProgress(total: Long, current: Long)
}
interface Presenter {
fun downloadApk()
fun checkVersion(isShowToast: Boolean)
fun unsubscribe()
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment