Commit 0e7249b9 authored by 王志伟's avatar 王志伟

海外sdk初始包

parents
/.gradle/
/.idea/
/gradlew
/gradlew.bat
/local.properties
/build
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
android {
signingConfigs {
config {
storeFile file('D:\\HalomobiKeyStore\\halofkkq.jks')
storePassword 'halofkkq'
keyAlias 'halofkkq'
keyPassword 'halofkkq'
}
debug {
storeFile file("C:\\Users\\EDZ\\android\\debug.keystore")
}
}
compileSdkVersion 33
buildToolsVersion "33.0.2"
defaultConfig {
applicationId "com.jjmillion.summer.game"
minSdkVersion 21
targetSdkVersion 33
versionCode 516
versionName "5.1.6"
multiDexEnabled true
flavorDimensions "versionCode"
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', "armeabi"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
minifyEnabled false
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
android.applicationVariants.all {
variant ->
variant.outputs.all {
//这里修改apk文件名
outputFileName = "fkkq-v${variant.versionName}.apk"
// outputFileName = "${variant.productFlavors[0].name}_v${variant.versionName}.apk"
}
}
packagingOptions {
exclude 'META-INF.**'
exclude "**.module-info.class"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn"]
}
// buildFeatures {
// dataBinding = true
// viewBinding = true
// }
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
// implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.6.0'
implementation("com.guolindev.permissionx:permissionx:1.7.1")
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.applovin:applovin-sdk:12.0.0'
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.6.7'
// implementation (name:'halomobi_juhe_sdk_v1.0.0',ext:'aar')
implementation project(':haloJuheSdk')
}
# 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
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.halomobi.halomobisdk">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/Theme.HaloMobiSdk">
<meta-data
android:name="applovin.sdk.key"
android:value="TAVI1U8OIXyhL9egaWLlPirxWNem6hJ82OivKgwNQcvKoUT_XkgPvx3qUGk42s1tXmHQvd6OTLoRl5QaxLdIyU" />
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
<activity
android:name="com.halo.halomobisdk.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.HaloMobiSdk">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.halo.halomobisdk.SplashActivity"/>
<activity android:name="com.halo.halomobisdk.BannerActivity"/>
<activity android:name="com.halo.halomobisdk.InsertActivity"/>
<activity android:name="com.halo.halomobisdk.NativeActivity"/>
<activity android:name="com.halo.halomobisdk.RewardActivity"/>
<activity android:name="com.halomobi.sdk.RewardVideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"/>
</application>
</manifest>
\ No newline at end of file
{"id":"2D9B872B7D301188","seatbid":[{"bid":[{"id":"539b4c124478f3aaf90def46ba785906","impid":"078D0B854B7E0D20","price":3.9174300000000004,"adid":"4e16f83ea04d","nurl":"https://adx-us.halomobi.com/ssp/report?h=H4rnYJHTAEvu6hGAL0HkVC2fPGDf1zADerPwwePYWMRrMg1JY4zeCW2IXnRHwAMp8zDImQtrPd9BLFChPxM%2B9LqHabxHZZBqvCGmsQ8kWkI%3D&p2=${AUCTION_PRICE}&cur=USD&halo_price=__BID_PRICE__","adm":"<VAST version='3.0'><Ad id='73621'><Wrapper><Error><![CDATA[https://us-east-1.event.prod.bidr.io/log/vasterror?error_event=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGJW_BCCPGDICYXA=&error_code=[ERRORCODE]]]></Error><AdSystem>Beeswax</AdSystem><VASTAdTagURI><![CDATA[https://ads.mountain.com/serve?ms=93&aid=33311&cid=201274&ctvcb=1698948240857&eid=148&cb=480330737&ttd_impression_id=1701630388835059.2150974351.313367.steelhouse&sh_ref=317469184&tdid=dad4e4ed-7910-4309-9bb2-ee8491fc2131&did=&dev=MOBILE&bid_ip=MTA0LjYyLjE3MC4yMTI=]]></VASTAdTagURI><Impression><![CDATA[https://use-node7.imprdom.com/?event=impression&price=4.3527&seat=2793|6a26b886cbc2a2a06252b7359b954e64&traffic=video&hash=99e0ee5973fead20bf11d60c49e8d1d4]]></Impression><Impression><![CDATA[https://adrta.com/i?clid=gta&dvid=v&paid=gta&avid=2793&caid=4ADP18842&plid=4ADPsteelhouse-73621&publisherId=748076&siteId=24829e083d21&priceBid=4.35279&kv1=1280x720&kv2=null&kv3=c9b292af2639c7e5bed08e279f5a5ceee2e0f84c&kv4=104.62.170.212&kv5=g&kv6=317469184&kv7=halomobi&kv10=AT%26T%20Internet&kv11=68137a65d97ce08a84448206f8ca6ef2&kv12=600044&kv15=USA&kv16=28.1404&kv17=-80.6514&kv18=com.espn.ScoreCenter&kv19=dad4e4ed-7910-4309-9bb2-ee8491fc2131&kv23=AT%26T%20Internet&kv24=MobileInApp_video&kv25=ESPN%3A%20Live%20Sports%20%26%20Scores&kv26=iOS&kv27=Mozilla%2F5.0%20(iPhone%3B%20CPU%20iPhone%20OS%2012_5_4%20like%20Mac%20OS%20X)%20AppleWebKit%2F605.1.15%20(KHTML%2C%20like%20Gecko)%20Version%2F12.1.2%20Mobile%2F15E148%20Safari%2F604.1&kv28={{DEVICE_MAKE}}_{{DEVICE_MODEL}}&kv29=[ERRORCODE]&kv30=[CONTENTPLAYHEAD]_[ADPLAYHEAD]&kv33=[ASSETURI]&kv34=[VASTVERSIONS]&kv35=[IFATYPE]&kv36=[IFA]&kv37=[CLIENTUA]&kv38=[SERVERUA]&kv39=[DEVICEUA]&kv40=[DEVICEIP]&kv41=[LATLONG]&kv42=[DOMAIN]&kv43=[PAGEURL]&kv44=null&kv45=[PLAYERSIZE]&kv46=[REGULATIONS]&kv47=[ADTYPE]&kv48=[TRANSACTIONID]&kv49=[BREAKPOSITION]&kv50=[APPNAME]&kv51=[PLACEMENTTYPE]&kv54=[LAT]]]></Impression><Impression><![CDATA[https://n16.adprime.com/?c=e&m=b&key=094e52c17b9079519e000e8414f5e2dc&cp=6.73964]]></Impression><Impression><![CDATA[https://us-east-1.event.prod.bidr.io/log/imp/ap?sie=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCCmRigBOihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxYAF4lb8EgAGPGJIBAmFwqAEAwgEAygEfc3RlZWxob3VzZS02N2E1ZTU2ZTYxMDliNWQzNjUyZNIBANoBDjIwMjMxMjAzMDAwMDAw4gEeEgQIBBABEgQIARABEgQIAxABEgQIAhABEgQIBRAB6gEYaXAuOjpmZmZmOjEwNC42Mi4xNzAuMjEy-gEVDfEpWD8SDvQGAgEBAAAAAAAAAAAA&wp=8.6804&fie=IKZGSg8IAEIHQmVlc3dheEgBUAFqBhAAGAAgAHCmRooBEAoFCKZGEAERAAAAAAAA8D_yAQIYAA==&]]></Impression><Impression><![CDATA[https://adx-us.halomobi.com/ssp/report?h=H4rnYJHTAEvu6hGAL0HkVC2fPGDf1zADerPwwePYWMRrMg1JY4zeCcLhggUCK5bEW3y4G4w6n2txlal9NXGwtg%3D%3D&p2=${AUCTION_PRICE}&cur=USD&win_price=%%WINNING_PRICE%%&halo_price=__BID_PRICE__]]></Impression><Creatives><Creative><Linear><TrackingEvents><Tracking event=\"start\"><![CDATA[https://use-node7.imprdom.com/?event=ve&hash=99e0ee5973fead20bf11d60c49e8d1d4&eventId=1]]></Tracking><Tracking event=\"firstQuartile\"><![CDATA[https://use-node7.imprdom.com/?event=ve&hash=99e0ee5973fead20bf11d60c49e8d1d4&eventId=2]]></Tracking><Tracking event=\"midpoint\"><![CDATA[https://use-node7.imprdom.com/?event=ve&hash=99e0ee5973fead20bf11d60c49e8d1d4&eventId=3]]></Tracking><Tracking event=\"thirdQuartile\"><![CDATA[https://use-node7.imprdom.com/?event=ve&hash=99e0ee5973fead20bf11d60c49e8d1d4&eventId=4]]></Tracking><Tracking event=\"complete\"><![CDATA[https://use-node7.imprdom.com/?event=ve&hash=99e0ee5973fead20bf11d60c49e8d1d4&eventId=5]]></Tracking><Tracking event=\"complete\"><![CDATA[https://n16.adprime.com/?c=e&m=ec&key=094e52c17b9079519e000e8414f5e2dc&event=complete]]></Tracking><Tracking event='start'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCABKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='firstQuartile'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCACKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='midpoint'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCADKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='thirdQuartile'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAEKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='complete'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAFKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='mute'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAHKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='unmute'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAIKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='pause'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAJKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='resume'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAKKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='fullscreen'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCALKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking><Tracking event='close'><![CDATA[https://us-east-1.event.prod.bidr.io/log/act/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCAMKihtaWQuREFENEU0RUQtNzkxMC00MzA5LTlCQjItRUU4NDkxRkMyMTMxQJW_BEiPGFICYXBgAHoeEgQIBRABEgQIAxABEgQIBBABEgQIAhABEgQIARAB&]]></Tracking></TrackingEvents><VideoClicks><ClickTracking><![CDATA[https://n16.adprime.com/?c=e&m=ck&key=094e52c17b9079519e000e8414f5e2dc]]></ClickTracking><ClickTracking><![CDATA[https://us-east-1.event.prod.bidr.io/log/clk/ap?ai=ChMIj4fVgQgQl5ATGPOl9pb784IDEhYKCnN0ZWVsaG91c2UQAhiakwEgoYsCGgJhcCIobWlkLkRBRDRFNEVELTc5MTAtNDMwOS05QkIyLUVFODQ5MUZDMjEzMTiVvwRAjxhIAVICYXBgAHoeEgQIARABEgQIBBABEgQIBRABEgQIAhABEgQIAxAB&audit_flag_wp=8.6804]]></ClickTracking><ClickTracking>[![CDATA[https://adx-us.halomobi.com/ssp/report?h=H4rnYJHTAEvu6hGAL0HkVC2fPGDf1zADerPwwePYWMRrMg1JY4zeCcLhggUCK5bEQxFrDfKQQHoUWUggvlZN%2BNjeFzICMITs]]</ClickTracking></VideoClicks></Linear></Creative></Creatives><Extensions></Extensions><Error><![CDATA[http://n16.adprime.com/?c=e&m=nurl&auctionId=094e52c17b9079519e000e8414f5e2dc&price=6.73964]]></Error><Error><![CDATA[https://n16.adprime.com/?c=e&m=verr&key=094e52c17b9079519e000e8414f5e2dc&code=[ERRORCODE]]]></Error></Wrapper></Ad></VAST>","adomain":["instaloan.com"],"cid":"2793|4ADP18842","crid":"2793|4ADPsteelhouse-73621","cat":["IAB3"],"w":1280,"h":720,"language":"en"}]}],"bidid":"539b4c124478f3aaf90def46ba785906","cur":"USD"}
\ No newline at end of file
This diff is collapsed.
{
"native": {
"assets": [
{
"data": {
"label": "cta",
"type": 12,
"value": "Lihat details"
},
"id": 3,
"required": 0
},
{
"id": 1,
"required": 1,
"title": {
"text": "Lazada Harga Super Rendah"
}
},
{
"data": {
"label": "desc",
"type": 2,
"value": "Beli Sekarang"
},
"id": 2,
"required": 1
},
{
"id": 5,
"img": {
"h": 627,
"type": 3,
"url": "https://material.growone.sg/online/assets/2023/06/27/8d8ce45b2246f3319742d34ccec80b54.jpg",
"w": 1200
},
"required": 1
}
],
"imptrackers": [
"https://c.lazada.co.id/i/c.bgRGPS?rta_token=&rta_event_id=c4d7fc49-b3cb-4cfb-b7ff-a86e7aa5775a&os=android&gps_adid=3a150303-50cb-4e83-8111-16bcb794b655&imei=&android_id=&idfa=&idfv=__IDFV__&bundle_id=0&device_model=V2029&device_make=V2029&sub_id1=xf001&sub_id2=lazada_yxy&sub_id3=54888742B14BCD61E2C0076C4E81B6FC&sub_id4=2&sub_id5=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K&lzdcid=lzd_im_200040010176004&adtype=1",
"http://monitor.growone.sg/vw?info=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K&wp=${AUCTION_PRICE}"
],
"link": {
"clicktrackers": [
"https://c.lazada.co.id/cm/c.bgRGPS?rta_token=&rta_event_id=c4d7fc49-b3cb-4cfb-b7ff-a86e7aa5775a&os=android&gps_adid=3a150303-50cb-4e83-8111-16bcb794b655&imei=&android_id=&idfa=&idfv=__IDFV__&bundle_id=0&device_model=V2029&device_make=V2029&sub_id1=xf001&sub_id2=lazada_yxy&sub_id3=54888742B14BCD61E2C0076C4E81B6FC&sub_id4=2&sub_id5=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K&lzdcid=lzd_im_200040010176004&adtype=1",
"http://monitor.growone.sg/ck?info=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K"
],
"fallback": "https://c.lazada.co.id/t/c.bgRGPS?rta_token=&rta_event_id=c4d7fc49-b3cb-4cfb-b7ff-a86e7aa5775a&os=android&gps_adid=3a150303-50cb-4e83-8111-16bcb794b655&imei=&android_id=&idfa=&idfv=__IDFV__&bundle_id=0&device_model=V2029&device_make=V2029&sub_id1=xf001&sub_id2=lazada_yxy&sub_id3=54888742B14BCD61E2C0076C4E81B6FC&sub_id4=2&sub_id5=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K&lzdcid=lzd_im_200040010176004&adtype=1",
"url": "lazada://id/web/www/marketing/gateway/rta?null&dsource=sml&exlaz=e_dnCqjO2KHnfGip8qo24MCZxWHrQEPErDUYq%252BRPaB3irZwT6Rq4aTKIkb0Shce8ieFFslIGwFnQz%252FK7a2MQpdu%252B27Ue60aR6RD3WnASIas1Y%253D&rta_token=&rta_event_id=c4d7fc49-b3cb-4cfb-b7ff-a86e7aa5775a&os=android&gps_adid=3a150303-50cb-4e83-8111-16bcb794b655&android_id=&idfa=&idfv=__IDFV__&bundle_id=0&device_model=V2029&device_make=V2029&sub_id1=xf001&sub_id2=lazada_yxy&sub_id3=54888742B14BCD61E2C0076C4E81B6FC&sub_id4=2&sub_id5=CN-P0qoGEH8aJGM0ZDdmYzQ5LWIzY2ItNGNmYi1iN2ZmLWE4NmU3YWE1Nzc1YSItNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkLjE5NzQ0NjE0KJFOMJdOQLwCSIQaUP0YWIgZYKLFAXIgNTQ4ODg3NDJCMTRCQ0Q2MUUyQzAwNzZDNEU4MUI2RkN9AAAAAIUBAAAAAIgBoI0GkAECmgEkNmY2YmZjNmYtNjQxYi00N2ZmLTkwZWItM2VkMjlmMmI5MjVkoAGgOKgBANABAtgBAuABAfAB0cLOLvoBATCCAgEwkgIBMqoCM2NvbS5uZW1vLnZpZG1hdGV8MTE1fDEwMHwyOTd8MTk5OSwwLDAmJiYwLDAsMCwwLDB8MLACE7gCgKCwjb0K&lzdcid=lzd_im_200040010176004&adtype=1"
},
"ver": "1.1"
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.halomobi.halomobisdk.R
class BannerActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_banner)
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.halo.halojuhesdk.sdk.HlInsertAd
import com.halo.halojuhesdk.sdk.listener.HlInsertAdListener
import com.halomobi.halomobisdk.R
import org.json.JSONObject
class InsertActivity : AppCompatActivity(){
private var hlInsertAd: HlInsertAd? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_banner)
findViewById<TextView>(R.id.load).setOnClickListener {
loadInsertAd()
}
findViewById<TextView>(R.id.show).setOnClickListener {
hlInsertAd?.show()
}
}
private fun loadInsertAd() {
hlInsertAd = HlInsertAd(this, "2720709", object :
HlInsertAdListener {
override fun onDisplayAd() {
}
override fun onClickAd() {
}
override fun onCloseAd() {
}
override fun onAdReady() {
Toast.makeText(this@InsertActivity, "==价格===${hlInsertAd?.ecpm}", Toast.LENGTH_SHORT).show()
val ecpmMap = hlInsertAd?.ecpmMap
val jsonObject = JSONObject()
ecpmMap?.forEach { (key, value) ->
jsonObject.put(key, value)
}
findViewById<TextView>(R.id.price_show).text = jsonObject.toString()
}
override fun onAdError(msg: String?, code: Int) {
Toast.makeText(this@InsertActivity, "==error===$msg", Toast.LENGTH_SHORT).show()
}
})
hlInsertAd?.loadAd()
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.View.OnClickListener
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.applovin.sdk.AppLovinSdk
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.halo.halojuhesdk.sdk.HlAdClient
import com.halomobi.halomobisdk.R
import org.json.JSONException
import org.json.JSONObject
class MainActivity : AppCompatActivity(), OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Initialize the AppLovin SDK
Thread {
val ifa: String? = getIfa()
Log.e("11111", "===ifa===$ifa")
val jsonObject = JSONObject()
try {
jsonObject.put("oaId", "28f81913-97d7-4eb3-be44-d50931d6e006") //当前设备oaId
jsonObject.put("ifa", ifa)
Log.e("11111", "====jsonObject====$jsonObject")
} catch (e: JSONException) {
e.printStackTrace()
}
HlAdClient.init(this, "27207",jsonObject.toString(), false, true)
}.start()
val mTvSplash = findViewById<TextView>(R.id.tv_splash)
mTvSplash.setOnClickListener(this)
val mTvBanner = findViewById<TextView>(R.id.tv_banner)
mTvBanner.setOnClickListener(this)
val mTvInsert = findViewById<TextView>(R.id.tv_insert)
mTvInsert.setOnClickListener(this)
val mTvNative = findViewById<TextView>(R.id.tv_native)
mTvNative.setOnClickListener(this)
val mTvVideo = findViewById<TextView>(R.id.tv_video)
mTvVideo.setOnClickListener(this)
val mTvSelect = findViewById<TextView>(R.id.tv_select)
mTvSelect.setOnClickListener(this)
}
override fun onClick(v: View) {
when(v.id) {
R.id.tv_splash -> {
startActivity(Intent(this, SplashActivity::class.java))
}
R.id.tv_banner -> {
startActivity(Intent(this, BannerActivity::class.java))
}
R.id.tv_insert -> {
startActivity(Intent(this, InsertActivity::class.java))
}
R.id.tv_native -> {
startActivity(Intent(this, NativeActivity::class.java))
}
R.id.tv_video -> {
startActivity(Intent(this, RewardActivity::class.java))
}
R.id.tv_select -> {
AppLovinSdk.getInstance(this).showMediationDebugger()
}
}
}
fun getIfa(): String? {
var adInfo: AdvertisingIdClient.Info? = null
try {
adInfo = AdvertisingIdClient.getAdvertisingIdInfo(this)
} catch (e: Exception) {
e.printStackTrace()
}
return if (adInfo != null) adInfo.id else ""
}
}
package com.halo.halomobisdk
import android.os.Bundle
import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import com.halo.halojuhesdk.sdk.HlNativeAd
import com.halo.halojuhesdk.sdk.listener.HlNativeAdListener
import com.halomobi.halomobisdk.R
import org.json.JSONObject
class NativeActivity : AppCompatActivity() {
private var hlNativeAd: HlNativeAd? = null
private var mConstraintLayout: ConstraintLayout? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_native)
findViewById<TextView>(R.id.load).setOnClickListener {
loadNativeAd()
}
mConstraintLayout = findViewById(R.id.constraint)
}
private fun loadNativeAd() {
hlNativeAd = HlNativeAd(this, "2686404", object : HlNativeAdListener {
override fun onADLoadView(view: View?, adTypeStr: String, ratio: Float) {
mConstraintLayout?.removeAllViews()
mConstraintLayout?.addView(view)
val ecpmMap = hlNativeAd?.ecpmMap
val jsonObject = JSONObject()
ecpmMap?.forEach { (key, value) ->
jsonObject.put(key, value)
}
findViewById<TextView>(R.id.price_show).text = jsonObject.toString()
}
override fun onADClick(view: View?, adTypeStr: String) {
}
override fun onADShow(view: View?, adTypeStr: String) {
}
override fun onADClose(view: View?) {
mConstraintLayout?.removeAllViews()
}
override fun onADError(errorMsg: String?, errorCode: Int) {
Toast.makeText(this@NativeActivity, "===error===$errorMsg",Toast.LENGTH_LONG).show()
}
})
hlNativeAd?.loadData()
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import com.applovin.mediation.nativeAds.MaxNativeAdView
import com.halo.halojuhesdk.sdk.HlNativeUnifiedAd
import com.halo.halojuhesdk.sdk.listener.HlNativeResponse
import com.halo.halojuhesdk.sdk.listener.HlUnifiedNativeAdListener
import com.halomobi.halomobisdk.R
class NativeUnifiedActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_native)
val mConstraintLayout = findViewById<ConstraintLayout>(R.id.constraint)
// val hlNativeAd = HlNativeUnifiedAd(this, "2864604", object : HlUnifiedNativeAdListener {
// override fun onAdLoadSuccess(response: HlNativeResponse?) {
// if (response != null) {
// val selfView =
// View.inflate(this@NativeUnifiedActivity, R.layout.item_unified_native, null)
//// val adView: MaxNativeAdView = createNativeAdView()
//
// // Check if ad is expired before rendering
//
// // Check if ad is expired before rendering
//// if (nativeAd.getNativeAd() != null && nativeAd.getNativeAd().isExpired()) {
//// // Destroy expired ad and load a new one
//// nativeAdLoader.destroy(nativeAd)
//// nativeAdLoader.loadAd()
//// showAdButton.setEnabled(false)
//// return
//// }
////
//// // Render the ad separately
////
//// // Render the ad separately
//// nativeAdLoader.render(adView, nativeAd)
//// nativeAdLayout.addView(adView)
// }
// }
// override fun onAdLoadFail(msg: String?, cod: Int) {
// }
// })
// hlNativeAd.loadData()
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.halo.halojuhesdk.sdk.HlVideoAd
import com.halo.halojuhesdk.sdk.listener.HlVideoListener
import com.halomobi.halomobisdk.R
import org.json.JSONObject
class RewardActivity : AppCompatActivity() {
private var hlVideoAd: HlVideoAd? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_reward)
findViewById<TextView>(R.id.load).setOnClickListener {
loadRewardAd()
}
findViewById<TextView>(R.id.show).setOnClickListener {
hlVideoAd?.show()
}
}
private fun loadRewardAd() {
hlVideoAd = HlVideoAd(this, "2686403", object : HlVideoListener {
override fun onSuccess() {
Toast.makeText(this@RewardActivity, "==onSuccess===${hlVideoAd?.ecpm}", Toast.LENGTH_SHORT).show()
val ecpmMap = hlVideoAd?.ecpmMap
val jsonObject = JSONObject()
ecpmMap?.forEach { (key, value) ->
jsonObject.put(key, value)
}
findViewById<TextView>(R.id.price_show).text = jsonObject.toString()
}
override fun onAdFailed(errorMsg: String, errorCode: Int) {
Toast.makeText(this@RewardActivity, "==error===$errorMsg", Toast.LENGTH_SHORT).show()
}
override fun onAdShow() {
}
override fun onAdClose() {
}
override fun onAdClick() {
}
override fun onPlayEnd() {
}
override fun onSkipped() {
}
override fun onRewardArrived() {
}
})
hlVideoAd?.loadAd()
}
}
\ No newline at end of file
package com.halo.halomobisdk
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.halo.halojuhesdk.sdk.HlSplashAd
import com.halo.halojuhesdk.sdk.listener.HlSplashAdListener
import com.halomobi.halomobisdk.R
import org.json.JSONObject
class SplashActivity : AppCompatActivity(){
private var hlSplashAd: HlSplashAd? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
findViewById<TextView>(R.id.load).setOnClickListener {
loadInsertAd()
}
findViewById<TextView>(R.id.show).setOnClickListener {
hlSplashAd?.showAd()
}
}
private fun loadInsertAd() {
hlSplashAd = HlSplashAd(this, "2686401", findViewById(R.id.constraint), object :HlSplashAdListener {
override fun onReadyAd(adTypeStr: String) {
val ecpmMap = hlSplashAd?.ecpmMap
val jsonObject = JSONObject()
ecpmMap?.forEach { (key, value) ->
jsonObject.put(key, value)
}
findViewById<TextView>(R.id.price_show).text = jsonObject.toString()
}
override fun onDisplayAd(adTypeStr: String) {
}
override fun onClickAd(adTypeStr: String) {
}
override fun onCloseAd() {
}
override fun onAdError(msg: String?, code: Int) {
}
override fun onAdSkip() {
}
})
}
}
\ No newline at end of file
This diff is collapsed.
<?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>
<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"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/load"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="加载"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/show"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="展示"
android:textSize="20dp"
android:layout_marginTop="20dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/load"/>
<TextView
android:id="@+id/price_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textSize="20dp"
app:layout_constraintTop_toBottomOf="@id/show"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/tv_splash"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="开屏"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/tv_banner"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="横幅"
android:gravity="center"
android:visibility="gone"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_splash"/>
<TextView
android:id="@+id/tv_insert"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="插屏"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_banner"/>
<TextView
android:id="@+id/tv_native"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="信息流"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_insert"/>
<TextView
android:id="@+id/tv_video"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="激励视频"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_native"/>
<TextView
android:id="@+id/tv_select"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="选择测试"
android:gravity="center"
android:textSize="20sp"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/tv_video"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/load"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="加载"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/price_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textSize="20dp"
app:layout_constraintTop_toBottomOf="@id/load"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@id/price_show"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/load"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="加载"
android:textSize="20dp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/show"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="展示"
android:textSize="20dp"
android:layout_marginTop="20dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/load"/>
<TextView
android:id="@+id/price_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textSize="20dp"
app:layout_constraintTop_toBottomOf="@id/show"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/load"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="加载"
android:textSize="20sp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="展示"
android:gravity="center"
android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@id/load"/>
<TextView
android:id="@+id/price_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@id/show"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@id/price_show"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="20dp"
android:textColor="@color/black"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/imageView"/>
<TextView
android:id="@+id/tv_desc"
android:layout_width="match_parent"
android:layout_height="20dp"
android:textColor="@color/black"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Please click the button below to get your location" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
<TextView
android:id="@+id/cellText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="@+id/lacationText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</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" />
<monochrome 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" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<resources>
<string name="app_name">HaloMobiSdk</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.HaloMobiSdk" parent="Theme.AppCompat.Light.NoActionBar" />
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
\ 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.9.10"
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com'}
maven { url "https://maven.aliyun.com/repository/public" }
maven { url 'https://repo1.maven.org/maven2/' }
maven { url 'https://artifact.bytedance.com/repository/pangle' }
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
//plugins {
// id "com.hi.dhl.plugin" apply false
//}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com'}
maven { url "https://maven.aliyun.com/repository/public" }
maven { url 'https://repo1.maven.org/maven2/' }
maven { url 'https://artifact.bytedance.com/repository/pangle' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
\ No newline at end of file
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
#android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
#android.enableJetifier=true
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
android.injected.testOnly=false
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
targetSdkVersion 33
versionCode 1000
versionName "1.0.0.0"
}
def SDK_CHANNEL = "halomobi_juhe_sdk"
def SDK_VERSION = "1.0.0"
def SDK_BASENAME = SDK_CHANNEL + "_v" + SDK_VERSION
repositories {
flatDir {
dirs 'libs'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
lintOptions {
abortOnError false
}
android.libraryVariants.all { variant ->
variant.outputs.all {
def fileName = SDK_BASENAME + ".aar"
outputFileName = fileName
}
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("com.google.android.material:material:1.6.0")
implementation("com.applovin:applovin-sdk:12.0.0")
implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.6.7'
// implementation (name:'halomobi_sdk_v1.0.0',ext:'aar')
implementation project(':haloMobiSdk')
}
# 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
-keep public class com.halomobi.sdk.**{*;}
-keep public class com.halo.halojuhesdk.sdk.**{*;}
\ No newline at end of file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.halo.halojuhesdk">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--获取蓝牙相关信息-->
<!-- <uses-permission android:name="android.permission.BLUETOOTH" />-->
<!--监听网络变化-->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
\ No newline at end of file
{
"msg": "success",
"status": 0,
"request_id": "657199daeca8fd40624a793a",
"data": {
"config": {
"applist": 0,
"appwg": 1,
"bidfloor": 100,
"gdt_splash": 0,
"hw_tips": 1,
"rt": 2904490,
"sdk_x1": 1,
"tmax": 10000
},
"ip": "111.196.19.142",
"slot": {
"2686401": [
{
"slotId": "2686401",
"slotType": 0,
"adFrom": "sdk_max",
"extendStr": "",
"adSlotId": "824ed60bcde688c5",
"adAppId": "max_sdk",
"package": "wordassociation.trivia.games.g",
"version": "-",
"appName": "max_sdk",
"d": 100,
"e": 1
}
],
"2686402": [
{
"slotId": "2686402",
"slotType": 1,
"adFrom": "api",
"extendStr": "-",
"adSlotId": "-",
"adAppId": "-",
"package": "-",
"version": "-",
"appName": "-",
"e": 1
},
{
"slotId": "2686402",
"slotType": 1,
"adFrom": "sdk_max",
"extendStr": "",
"adSlotId": "0ca9b2dae0a1ad51",
"adAppId": "max_sdk",
"package": "wordassociation.trivia.games.g",
"version": "-",
"appName": "max_sdk",
"d": 100,
"e": 1
}
],
"2686403": [
{
"slotId": "2686403",
"slotType": 4,
"adFrom": "api",
"extendStr": "-",
"adSlotId": "-",
"adAppId": "-",
"package": "-",
"version": "-",
"appName": "-",
"e": 1
},
{
"slotId": "2686403",
"slotType": 1,
"adFrom": "sdk_max",
"extendStr": "",
"adSlotId": "058d4539b12ff5cf",
"adAppId": "max_sdk",
"package": "wordassociation.trivia.games.g",
"version": "-",
"appName": "max_sdk",
"d": 100,
"e": 1
}
],
"2686404": [
{
"slotId": "2686404",
"slotType": 3,
"adFrom": "api",
"extendStr": "-",
"adSlotId": "-",
"adAppId": "-",
"package": "-",
"version": "-",
"appName": "-",
"e": 1
},
{
"slotId": "2686404",
"slotType": 1,
"adFrom": "sdk_max",
"extendStr": "",
"adSlotId": "c2d03dd0bcc5bb01",
"adAppId": "max_sdk",
"package": "wordassociation.trivia.games.g",
"version": "-",
"appName": "max_sdk",
"d": 100,
"e": 1
}
]
},
"sn": ""
}
}
\ No newline at end of file
package com.halo.halojuhesdk.core.base;
import android.content.Context;
import com.halo.halojuhesdk.core.base.utils.LogUtils;
/**
* Created by dream on 2016/11/10.
*/
public abstract class AbstractProcessor<T extends AbstractTask, P> implements ITaskListener<P> {
private static final String TAG = "AbstractProcessor";
private HjTaskManager mTaskManager;
/**
* 添加管理器
*
* @param manager
*/
public void setTaskManager(HjTaskManager manager) {
mTaskManager = manager;
}
/**
* 创建执行Task
*
* @return
*/
protected abstract T createTask();
/**
* 执行当前任务
*
* @param hjabstracktask
*/
private void doProcess(T hjabstracktask) {
LogUtils.d( hjabstracktask.getName() + " start process");
// 默认是自启动模式
if (mTaskManager == null) {
startBySelf(hjabstracktask);
} else {
startByTaskManager(hjabstracktask);
}
}
private void startByTaskManager(T hjabstracktask) {
if (mTaskManager != null) {
mTaskManager.add(hjabstracktask);
}
}
private void startBySelf(T hjabstracktask) {
Thread thread = new Thread(hjabstracktask);
thread.start();
}
/**
* 预处理在主线程判断是否需要执行
*
* @param hjabstracktask
* @return boolean
*/
protected boolean canProcess(T hjabstracktask) {
if (hjabstracktask.preExecute()) {
LogUtils.d( hjabstracktask.getName() + " can process");
return true;
}
return false;
}
/**
* 执行完成后处理需要回到原有线程问题
* @param hjabstracktask
*/
protected void afterProcess(T hjabstracktask) {
hjabstracktask.afterExcute();
}
/**
* 开始执行
*/
public void process() {
T t = createTask();
t.setListener(this);
if (t != null && canProcess(t)) {
doProcess(t);
afterProcess(t);
}
}
}
package com.halo.halojuhesdk.core.base;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
/**
* Created by dream on 2016/11/10.
*/
public abstract class AbstractTask implements Runnable {
protected Runnable mRunnable;
protected Handler mHandler = null;
protected boolean mGoBack = false;
private boolean isPrepared = false;
protected Context mContext;
protected ITaskListener mListener;
/**
* 当前任务执行结果状态机
*/
protected boolean mExcuteSucc;
/**
* 为当前task做预处理
*
* @return 是否继续执行
*/
protected abstract boolean preExecute();
/**
* task处理后收尾工作private
*/
protected abstract void onExcute();
/**
* task处理事件方法
*/
protected void postExcute() {
if (mGoBack && mRunnable != null) {
mHandler.post(mRunnable);
}
}
/**
* 加载方式
*
* @return
*/
public abstract LaunchMode getLaunchMode();
/**
* 当前Task区分标识
*
* @return
*/
public abstract String getName();
/**
* 外部传入Runnable做同线程返回
* @param runable
*/
public void setRunable(Runnable runable) {
this.mRunnable = runable;
}
/**
* 外部传入监听对象做同线程返回
* @param
*/
public void setListener(ITaskListener listener) {
this.mListener = listener;
}
/**
* 构造方法
* @param context
* @param needGoBack 是否需要返回原有线程
*/
public AbstractTask(Context context , boolean needGoBack) {
this.mContext = context;
mGoBack = needGoBack;
if (mGoBack) {
if(Looper.myLooper() == null){
isPrepared = true;
Looper.prepare();
}
mHandler = new Handler();
}
}
/**
* 当所有执行完之后调用
* 运行在Create线程
*/
public void afterExcute(){
if(isPrepared){
Looper.loop();
}
}
@Override
public String toString() {
return getName();
}
@Override
public boolean equals(Object obj) {
return toString().equals(obj.toString());
}
@Override
public void run() {
if (preExecute()) {
onExcute();
postExcute();
}
}
}
package com.halo.halojuhesdk.core.base;
import android.content.Context;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Created by dream on 2016/11/10.
* 工作Task管理类,可应用于多任务并发管理
*/
public class HjTaskManager {
private Context mContext;
private ThreadPoolExecutor mExcutor;
private static long SLEEP_TIME = 5;
public static int MOD_SINGLE = 1;
public static int MOD_NORMAL = 3;
public static int MOD_DOWNLOAD = 3;
// BlockingQueue为线程安全队列
private ArrayBlockingQueue<Runnable> runnables;
public HjTaskManager(Context context, int excuteSize) {
this.mContext = context;
runnables = new ArrayBlockingQueue<Runnable>(32);
mExcutor = new ThreadPoolExecutor(excuteSize, excuteSize, SLEEP_TIME, TimeUnit.SECONDS, runnables, handler);
}
RejectedExecutionHandler handler = new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) {
}
};
public <T extends AbstractTask> void add(T hjabstracktask) {
if (hjabstracktask.getLaunchMode() == LaunchMode.updateold) {
for (Runnable t : runnables
) {
if (t.equals(hjabstracktask)) {
runnables.remove(t);
}
}
}
mExcutor.execute(hjabstracktask);
}
}
package com.halo.halojuhesdk.core.base;
/**
* Created by dream on 2016/8/18.
*/
public interface ITaskListener<T> {
void finish(int i, T t);
void onError(int errorCode, String errorMsg);
}
package com.halo.halojuhesdk.core.base;
/**
* Created by dream on 2016/10/27.
*/
public enum LaunchMode {
/**
* 更新旧的Task(按照TaskName,先删掉旧的,再添加新的)
*/
updateold,
/**
* 添加新的Task
*/
addnew
}
package com.halo.halojuhesdk.core.base;
/**
* Created by dream on 2016/11/11.
*/
public enum ReqType {
Get, Post
}
package com.halo.halojuhesdk.core.base;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy;
import java.util.concurrent.TimeUnit;
public class ThreadManager {
private static final String DEFAULT_SINGLE_POOL_NAME = "DEFAULT_SINGLE_POOL_NAME";
private static ThreadPoolProxy mLongPool = null;
private static ThreadPoolProxy mShortPool = null;
private static ThreadPoolProxy mDownloadPool = null;
private static ThreadPoolProxy mCheckViewPool = null;
private static ThreadPoolProxy mRequestAdPool = null;
private static Map<String, ThreadPoolProxy> mMap = new HashMap<>();
private static final Object mSingleLock = new Object();
/**
* 请求广告线程
*/
public synchronized static ThreadPoolProxy getRequestAdPool() {
if (mRequestAdPool == null) {
mRequestAdPool = new ThreadPoolProxy(3, 5, 5L);
}
return mRequestAdPool;
}
/**
* 获取下载线程
*/
public synchronized static ThreadPoolProxy getDownloadPool() {
if (mDownloadPool == null) {
mDownloadPool = new ThreadPoolProxy(3, 3, 5L);
}
return mDownloadPool;
}
public synchronized static ThreadPoolProxy getCheckViewPool() {
if (mCheckViewPool == null) {
mCheckViewPool = new ThreadPoolProxy(3, 3, 5L);
}
return mCheckViewPool;
}
/**
* 获取一个用于执行长耗时任务的线程池,避免和短耗时任务处在同一个队列而阻塞了重要的短耗时任务,通常用来联网操作
*/
public synchronized static ThreadPoolProxy getLongPool() {
if (mLongPool == null) {
mLongPool = new ThreadPoolProxy(3, 5, 5L);
}
return mLongPool;
}
/**
* 获取一个用于执行短耗时任务的线程池,避免因为和耗时长的任务处在同一个队列而长时间得不到执行,通常用来执行本地的IO/SQL
*/
public synchronized static ThreadPoolProxy getShortPool() {
if (mShortPool == null) {
mShortPool = new ThreadPoolProxy(2, 2, 5L);
}
return mShortPool;
}
/**
* 获取一个单线程池,所有任务将会被按照加入的顺序执行,免除了同步开销的问题
*/
public static ThreadPoolProxy getSinglePool() {
return getSinglePool(DEFAULT_SINGLE_POOL_NAME);
}
/**
* 获取一个单线程池,所有任务将会被按照加入的顺序执行,免除了同步开销的问题
*/
public static ThreadPoolProxy getSinglePool(String name) {
synchronized (mSingleLock) {
ThreadPoolProxy singlePool = mMap.get(name);
if (singlePool == null) {
singlePool = new ThreadPoolProxy(1, 1, 1L);
mMap.put(name, singlePool);
}
return singlePool;
}
}
public static void onDestroy() {
Set<Map.Entry<String, ThreadPoolProxy>> entries = mMap.entrySet();
for (Map.Entry<String, ThreadPoolProxy> entry : entries) {
entry.getValue().shutdown();
}
mMap.clear();
getCheckViewPool().stop();
}
public static class ThreadPoolProxy {
private ThreadPoolExecutor mPool;
private int mCorePoolSize;
private int mMaximumPoolSize;
private long mKeepAliveTime;
private ThreadPoolProxy(int corePoolSize, int maximumPoolSize, long keepAliveTime) {
mCorePoolSize = corePoolSize;
mMaximumPoolSize = maximumPoolSize;
mKeepAliveTime = keepAliveTime;
}
/**
* 执行任务,当线程池处于关闭,将会重新创建新的线程池
*/
public synchronized void execute(Runnable task) {
if (task == null) {
return;
}
if (mPool == null || mPool.isShutdown()) {
mPool = new ThreadPoolExecutor(mCorePoolSize, mMaximumPoolSize, mKeepAliveTime,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
Executors.defaultThreadFactory(), new AbortPolicy());
}
mPool.execute(task);
}
/**
* 取消线程池中某个还未执行的任务
*/
public synchronized boolean cancel(Runnable run) {
return mPool != null && (!mPool.isShutdown() || mPool.isTerminating()) && mPool.getQueue().remove(run);
}
/**
* 判断队列中是否包含该任务
*/
public synchronized boolean contains(Runnable run) {
return mPool != null && (!mPool.isShutdown() || mPool.isTerminating()) && mPool.getQueue().contains(run);
}
/**
* 立刻关闭线程池,并且正在执行的任务也将会被中断
*/
synchronized void stop() {
if (mPool != null && (!mPool.isShutdown() || mPool.isTerminating())) {
mPool.shutdownNow();
}
}
/**
* 平缓关闭单任务线程池,但是会确保所有已经加入的任务都将会被执行完毕才关闭
*/
synchronized void shutdown() {
if (mPool != null && (!mPool.isShutdown() || mPool.isTerminating())) {
mPool.shutdown();
}
}
}
}
package com.halo.halojuhesdk.core.base.net;
import com.halo.halojuhesdk.core.base.AbstractProcessor;
/**
* Created by dream on 2016/11/10.
*/
public abstract class AbstractNetProcessor extends AbstractProcessor<AbstractNetTask, String> {
}
package com.halo.halojuhesdk.core.base.net;
import android.content.Context;
import android.text.TextUtils;
import com.halo.halojuhesdk.core.base.AbstractTask;
import com.halo.halojuhesdk.core.base.ReqType;
import com.halo.halojuhesdk.core.base.utils.LogUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
/**
* Created by dream on 2016/11/10.
*/
public abstract class AbstractNetTask extends AbstractTask implements HlConnectionListener {
// 是否为欢聚请求
protected boolean isHjRequest = true;
// 是否为实时请求
protected boolean isHotTimeRequest = false;
// 是否为Gzip请求
protected boolean isGzipRequest = false;
// 当前请求网络限制
protected int netLevel = NetworkManager.HJ_ACCEPT_NET_LEVEL;
/**
* HTTP链接超时时间
*/
private static final int HTTP_TIMEOUT_MS = 180000;
/**
* 请求获取数据超时时间
*/
private static final int SOCKET_TIMEOUT_MS = 180000;
/**
* HTTP链接超时时间
*/
private static final int HTTP_TIMEOUT = 100 * 1000;
/**
* 请求获取数据超时时间
*/
private static final int SOCKET_TIMEOUT = 100 * 1000;
/**
* HTTP链接超时时间
*/
private static final int HTTP_MIN_TIMEOUT_MS = 3000;
/**
* 请求获取数据超时时间
*/
private static final int SOCKET_MIN_TIMEOUT_MS = 3000;
private static final String TAG = "AbstractNetTask";
/**
* 没有网络连接
*/
public static final int ERROR_NOT_CONNECT = -1;
/**
* 网络连接异常
*/
public static final int ERROR_CONNECT_EXCEPTION = -2;
/**
* 未知网络类型
*/
public static final int ERROR_UNKNOWN_NET_TYPE = -3;
/**
* 当前网络类型和任务支持的网络类型不匹配
*/
public static final int ERROR_NET_TYPE_MISMATCH = -4;
public static final int ERROR_FILE_NOT_FOUND = -5;
public static final int ERROR_UNKNOWN_HOST = -6;
public AbstractNetTask(Context context, boolean isNeed) {
super(context, isNeed);
}
protected abstract String getURL();
protected abstract void getEntity(OutputStream outputStream);
protected abstract void onAddHeaders(HttpURLConnection connection);
protected abstract ReqType getReqType();
@Override
protected boolean preExecute() {
if (!NetworkManager.isNetworkConnected(mContext)) {
onNetworkError(ERROR_NOT_CONNECT, "没有网络连接");
return false;
}
if (NetworkManager.getNetworkType(mContext) > netLevel) {
onNetworkError(ERROR_UNKNOWN_NET_TYPE, "允许的网络等级限制,netLevel : " + netLevel);
return false;
}
return true;
}
@Override
protected void onExcute() {
String url = getURL();
if (!TextUtils.isEmpty(url)) {
try {
HlConnectionManager hjConnectionManager = new HlConnectionManager(getReqType(), url);
hjConnectionManager.setGzipRequest(isGzipRequest);
if (isHotTimeRequest) {
hjConnectionManager.setTimeOut(HTTP_MIN_TIMEOUT_MS, SOCKET_MIN_TIMEOUT_MS);
} else {
hjConnectionManager.setTimeOut(HTTP_TIMEOUT_MS, SOCKET_TIMEOUT_MS);
}
hjConnectionManager.openConnection(this);
} catch (FileNotFoundException e) {
LogUtils.e("出错了。");
LogUtils.e( e);
e.printStackTrace();
} catch (Exception e) {
LogUtils.e( e);
e.printStackTrace();
}
}
}
private void onNetworkError(int errorCode, String errorMsg) {
mListener.onError(errorCode, errorMsg);
mExcuteSucc = false;
}
@Override
public void onRecive(int code, String content) {
mListener.finish(code, content);
}
public HttpURLConnection openConnection(String url) throws Exception {
if (TextUtils.isEmpty(url)) {
LogUtils.e( "url == null");
return null;
}
URL Url = new URL(url);
String str_http = url.substring(0, url.indexOf(":"));
HttpURLConnection connection;
if (str_http.equals("https")) {
connection = getHttpsURLConnection(Url);
} else {
connection = getHttpURLConnection(Url);
}
return dealWithHttpConnection(connection);
}
private HttpsURLConnection getHttpsURLConnection(URL url) throws IOException, NoSuchAlgorithmException, KeyManagementException {
HttpsURLConnection httpsURLConnection;
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setConnectTimeout(SOCKET_TIMEOUT);
httpsURLConnection.setReadTimeout(HTTP_TIMEOUT);
TrustManager[] tm = {new MyX509TrustManager()};
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, tm, null);
httpsURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
httpsURLConnection.setHostnameVerifier(new TrustAnyHostnameVerifier());
httpsURLConnection.setInstanceFollowRedirects(true);
httpsURLConnection.setRequestProperty("Accept-Charset", "UTF-8");
return httpsURLConnection;
}
private HttpURLConnection getHttpURLConnection(URL url) throws IOException {
HttpURLConnection httpURLConnection;
httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(SOCKET_TIMEOUT);
httpURLConnection.setReadTimeout(HTTP_TIMEOUT);
httpURLConnection.setInstanceFollowRedirects(true);
httpURLConnection.setRequestProperty("Accept-Charset", "UTF-8");
return httpURLConnection;
}
private HttpURLConnection dealWithHttpConnection(HttpURLConnection connection) throws Exception {
if (isGzipRequest) {
connection.addRequestProperty("Content-Type", "text/html");
connection.addRequestProperty("Accept-Encoding", "gzip,deflate");
} else {
connection.addRequestProperty("Accept-Encoding", "");
}
onAddHeaders(connection);
connection.setRequestMethod("GET");
return connection;
}
}
package com.halo.halojuhesdk.core.base.net;
/**
* Created by dream on 2016/8/16.
*/
public interface HlConnectionListener {
void onRecive(int code, String content);
}
package com.halo.halojuhesdk.core.base.net;
import android.text.TextUtils;
import com.halo.halojuhesdk.core.base.ReqType;
import com.halo.halojuhesdk.core.base.utils.Utils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
/**
* Created by dream on 2016/8/11.
*/
public class HlConnectionManager {
private ReqType mReqType;
private URL mUrl;
private boolean isGzipRequest = false;
private boolean isHttps = false;
/**
* HTTP链接超时时间
*/
private int http_timeout = 180000;
/**
* 请求获取数据超时时间
*/
private int socket_timeout = 180000;
public HlConnectionManager(ReqType reqType, String url) throws Exception {
this.mReqType = reqType;
if (!TextUtils.isEmpty(url)) {
String str_http = url.substring(0, url.indexOf(":"));
if (str_http.equals("https")) {
isHttps = true;
}
} else {
throw new Exception("URL is Empty");
}
mUrl = new URL(url);
}
public void setGzipRequest(boolean isGzipRequest) {
this.isGzipRequest = isGzipRequest;
}
public void setTimeOut(int http_timeout, int socket_timeout) {
this.http_timeout = http_timeout;
this.socket_timeout = socket_timeout;
}
public void openConnection(AbstractNetTask abstractNetTask) throws Exception {
if (isHttps) {
dealWithHttpsConnection(abstractNetTask);
} else {
dealWithHttpConnection(abstractNetTask);
}
}
private void dealWithHttpConnection(AbstractNetTask abstractNetTask) throws Exception {
HttpURLConnection httpURLConnection = null;
InputStream inputStream = null;
try {
httpURLConnection = getHttpURLConnection();
if (isGzipRequest) {
httpURLConnection.addRequestProperty("Accept-Encoding", "gzip,deflate");
}else{
httpURLConnection.addRequestProperty("Accept-Encoding","");
}
abstractNetTask.onAddHeaders(httpURLConnection);
switch (mReqType) {
case Get:
httpURLConnection.setRequestMethod("GET");
break;
case Post:
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
OutputStream outputStream = null;
try {
outputStream = httpURLConnection.getOutputStream();
abstractNetTask.getEntity(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
break;
}
int responseCode = httpURLConnection.getResponseCode();
String content;
inputStream = httpURLConnection.getInputStream();
String contentEncoding = httpURLConnection.getContentEncoding();
content = Utils.parseInputString(Utils.decodeInputStream(inputStream, contentEncoding));
if (TextUtils.isEmpty(content)) {
content = httpURLConnection.getResponseMessage();
}
abstractNetTask.onRecive(responseCode, content);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private HttpURLConnection getHttpURLConnection() throws IOException {
HttpURLConnection httpURLConnection;
httpURLConnection = (HttpURLConnection) mUrl.openConnection();
httpURLConnection.setConnectTimeout(socket_timeout);
httpURLConnection.setReadTimeout(http_timeout);
httpURLConnection.setInstanceFollowRedirects(true);
httpURLConnection.addRequestProperty("Accept-Charset", "UTF-8;");
return httpURLConnection;
}
private void dealWithHttpsConnection(AbstractNetTask abstractNetTask) throws Exception {
HttpsURLConnection httpsURLConnection = null;
InputStream inputStream = null;
try {
httpsURLConnection = getHttpsURLConnection();
if (isGzipRequest) {
httpsURLConnection.addRequestProperty("Accept-Encoding", "gzip,deflate");
} else{
httpsURLConnection.addRequestProperty("Accept-Encoding","");
}
abstractNetTask.onAddHeaders(httpsURLConnection);
switch (mReqType) {
case Get:
httpsURLConnection.setRequestMethod("GET");
break;
case Post:
httpsURLConnection.setRequestMethod("POST");
httpsURLConnection.setDoOutput(true);
OutputStream outputStream = null;
try {
outputStream = httpsURLConnection.getOutputStream();
abstractNetTask.getEntity(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
break;
}
int responseCode = httpsURLConnection.getResponseCode();
String content;
inputStream = httpsURLConnection.getInputStream();
String contentEncoding = httpsURLConnection.getContentEncoding();
content = Utils.parseInputString(Utils.decodeInputStream(inputStream, contentEncoding));
if (TextUtils.isEmpty(content)) {
content = httpsURLConnection.getResponseMessage();
}
abstractNetTask.onRecive(responseCode, content);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (httpsURLConnection != null) {
httpsURLConnection.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private HttpsURLConnection getHttpsURLConnection() throws IOException, NoSuchAlgorithmException, KeyManagementException {
HttpsURLConnection httpsURLConnection;
httpsURLConnection = (HttpsURLConnection) mUrl.openConnection();
httpsURLConnection.setConnectTimeout(socket_timeout);
httpsURLConnection.setReadTimeout(http_timeout);
TrustManager[] tm = {new MyX509TrustManager()};
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, tm, null);
httpsURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
httpsURLConnection.setHostnameVerifier(new TrustAnyHostnameVerifier());
httpsURLConnection.setInstanceFollowRedirects(true);
httpsURLConnection.addRequestProperty("Accept-Charset", "UTF-8;");
return httpsURLConnection;
}
}
package com.halo.halojuhesdk.core.base.net;
import com.halo.halojuhesdk.core.base.utils.FileUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
/**
* Created by liuzheng on 2017/2/28.
*/
public class HttpResult {
private static final String[] httpCode3XXs = {"多选项", "永久移动", "临时移动",
"参见其他", "未改动", "使用代理", "", "暂时重定向"};
private static final String[] httpCode4XXs = {"错误请求", "未授权", "要求付费", "禁止",
"未找到", "不允许的方法", "不被采纳", "要求代理授权", "请求超时", "冲突", "过期的", "要求的长度",
"前提不成立", "请求实例太大", "请求URI太大", "不支持的媒体类型", "无法满足的请求范围", "失败的预期"};
private static final String[] httpCode5XXs = {"内部服务器错误", "未被使用", "网关错误",
"不可用的服务", "网关超时", "HTTP版本未被支持"};
private HttpURLConnection mConnection;
private InputStream mIn;
private String mStr;
private int mCode;
public HttpResult(HttpURLConnection connection) throws IOException {
mConnection = connection;
mCode = connection.getResponseCode();
}
/**
* @param statusCode 状态码
* @return ErrorMsg
* @since 2015-12-9
*/
public static String getMsgByErrorCode(int statusCode) {
String resultMsg = "";
if (300 <= statusCode && statusCode < 400) {
resultMsg = "重定向:" + statusCode;
int code = statusCode - 300;
if (code < httpCode3XXs.length) {
resultMsg += "----->" + httpCode3XXs[code];
}
}
if (400 <= statusCode && statusCode < 500) {
resultMsg = "客户端错误:" + statusCode;
int code = statusCode - 400;
if (code < httpCode4XXs.length) {
resultMsg += "----->" + httpCode4XXs[code];
}
} else if (500 <= statusCode) {
resultMsg = "服务器错误:" + statusCode;
int code = statusCode - 500;
if (code < httpCode5XXs.length) {
resultMsg += "----->" + httpCode5XXs[code];
}
}
return resultMsg;
}
public HttpURLConnection getHttpResponse() {
return mConnection;
}
public int getCode() {
return mCode;
}
/**
* 获取文件长度
*/
public long getLength() {
if (getCode() >= 200 && getCode() < 400) {
return mConnection.getContentLength();
}
return 0;
}
/**
* 获取流,需要使用完毕后调用close方法关闭网络连接
*/
public InputStream getInputStream() {
if (mIn == null && getCode() < 400) {
try {
mIn = mConnection.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
}
return mIn;
}
/**
* 关闭网络连接
*/
public void close() {
FileUtils.close(mIn);
if (mConnection != null) {
mConnection.disconnect();
}
}
}
package com.halo.halojuhesdk.core.base.net;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* 网络管理器(用于判断当前网络连接类型,接入点,代理服务器信息)
*
* @author david
*/
public class NetworkManager {
public static final int NET_WIFI = 0x01;
public static final int NET_4G = 0x02;
public static final int NET_3G = 0x03;
public static final int NET_2G = 0x04;
public static final int NET_UNKNOWN = 0x05;
public static final int NET_NONE = 0x06;
public static final int HJ_ACCEPT_NET_LEVEL = NET_NONE;
public static int HJ_ACCEPT_DOWNLOAD_NET_LEVEL = NET_NONE;
/**
* 判断当前是否有网
* <p>
* 1 Wifi
* <p>
* 2 4G
* <p>
* 3 3G
* <p>
* 4 2G
* <p>
* 6 无网
*
* @param cx
* @return 判断值
*/
public static int getNetworkType(Context cx) {
ConnectivityManager cwjManager = (ConnectivityManager) cx
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cwjManager.getActiveNetworkInfo();
if (info == null)
return NET_NONE;// 无网
int netType = info.getType();
if (netType == ConnectivityManager.TYPE_WIFI)
return NET_WIFI;// wifi
else if (netType == ConnectivityManager.TYPE_MOBILE) {
return getMobileNetClass(info.getSubtype());// 各种手机网络
}
return 0;
}
/**
* 当前网络是否可用
*
* @param cxt Context
* @return activeNetInfo.isConnected();
*/
public static boolean isNetworkConnected(Context cxt) {
ConnectivityManager connectivityManager = (ConnectivityManager) cxt
.getApplicationContext().getSystemService(
Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetInfo != null) {
return activeNetInfo.isConnectedOrConnecting();
}
return false;
}
/**
* 区分手机制式
*
* @param networkType
* @return
*/
private static int getMobileNetClass(int networkType) {
switch (networkType) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
case TelephonyManager.NETWORK_TYPE_CDMA:
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_IDEN:
return NET_2G;
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_EVDO_0:
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
case TelephonyManager.NETWORK_TYPE_HSPAP:
return NET_3G;
case TelephonyManager.NETWORK_TYPE_LTE:
return NET_4G;
default:
return NET_UNKNOWN;
}
}
}
package com.halo.halojuhesdk.core.base.net;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
/**
* Created by dream on 2016/8/10.
*/
public class TrustAnyHostnameVerifier implements HostnameVerifier {
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
package com.halo.halojuhesdk.core.base.net;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
/**
* Created dream on 2016/8/10.
*/
class MyX509TrustManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
package com.halo.halojuhesdk.core.base.utils;
import com.halo.halojuhesdk.core.common.utils.Config;
import com.halo.halojuhesdk.core.request.SlotBean;
import org.json.JSONObject;
import java.math.BigDecimal;
public class AnalyseSlotBeanUtils {
public static JSONObject analyseBean(SlotBean mBean, boolean isQuota, boolean isUse, double op, String reqId) {
JSONObject parameJson = new JSONObject();
try {
parameJson.put("appId", Config.mAppId);
parameJson.put("slotId", mBean.getSlotId());
parameJson.put("adAppId", mBean.getAppId());
parameJson.put("adSlotId", mBean.getAdSlotId());
parameJson.put("isQuota", isQuota);
parameJson.put("isUse", isUse);
// LogUtils.e("===op===" + mBean.getOp() + "====ep===" + mBean.getEp());
if (op > 0) {
BigDecimal bigDecimal = BigDecimal.valueOf(mBean.getOp());
String opStr = KeyUtil.encryptCurrentAES(SystemUtils.formatCurrentData(), String.valueOf(bigDecimal));
// opStr = String.valueOf(op);
parameJson.put("op", opStr);
} else {
parameJson.put("op", "0");
}
double ep = mBean.getEp();
if (ep > 0) {
BigDecimal bigDecimal = BigDecimal.valueOf(mBean.getEp());
String epStr = KeyUtil.encryptCurrentAES(SystemUtils.formatCurrentData(), String.valueOf(bigDecimal));
// epStr = String.valueOf(mBean.getEp());
parameJson.put("ep", epStr);
} else {
parameJson.put("ep", "0");
}
parameJson.put("startTime", mBean.getStartTime());
parameJson.put("endTime", mBean.getEndTime());
parameJson.put("cur","USD");
// parameJson.put("adid", HlStatisManager.getInstance().getConfigReqId());
// parameJson.put("reqId", reqId);
} catch (Exception e) {
e.printStackTrace();
}
return parameJson;
}
}
package com.halo.halojuhesdk.core.base.utils;
import java.io.UnsupportedEncodingException;
/**
* This class implements Base64 encoding/decoding functionality
* as specified in RFC 2045 (http://www.ietf.org/rfc/rfc2045.txt).
*/
public final class Base64 {
/** utility class should not have a public constructor. */
private Base64() { }
/**
* 对输入进行base64编码。
* @param in 输入
* @return base64编码字符串。
*/
public static byte[] decode(byte[] in) {
return decode(in, in.length);
}
/**
* 对base64编码数据进行解码。
* @param in base64编码输入数据
* @param len 长度
* @return 解码后的数据
*/
public static byte[] decode(byte[] in, int len) {
// approximate output length
int length = len / 4 * 3; // SUPPRESS CHECKSTYLE
// return an empty array on emtpy or short input without padding
if (length == 0) {
return new byte[0];
}
// temporary array
byte[] out = new byte[length];
// number of padding characters ('=')
int pad = 0;
byte chr;
// compute the number of the padding characters
// and adjust the length of the input
for ( ;; len--) {
chr = in[len - 1];
// skip the neutral characters
if ((chr == '\n') || (chr == '\r') || (chr == ' ') || (chr == '\t')) {
continue;
}
if (chr == '=') {
pad++;
} else {
break;
}
}
// index in the output array
int outIndex = 0;
// index in the input array
int inIndex = 0;
// holds the value of the input character
int bits = 0;
// holds the value of the input quantum
int quantum = 0;
for (int i = 0; i < len; i++) {
chr = in[i];
// skip the neutral characters
if ((chr == '\n') || (chr == '\r') || (chr == ' ') || (chr == '\t')) {
continue;
}
if ((chr >= 'A') && (chr <= 'Z')) {
// char ASCII value
// A 65 0
// Z 90 25 (ASCII - 65)
bits = chr - 65; // SUPPRESS CHECKSTYLE
} else if ((chr >= 'a') && (chr <= 'z')) {
// char ASCII value
// a 97 26
// z 122 51 (ASCII - 71)
bits = chr - 71; // SUPPRESS CHECKSTYLE
} else if ((chr >= '0') && (chr <= '9')) {
// char ASCII value
// 0 48 52
// 9 57 61 (ASCII + 4)
bits = chr + 4; // SUPPRESS CHECKSTYLE
} else if (chr == '+') {
bits = 62; // SUPPRESS CHECKSTYLE
} else if (chr == '/') {
bits = 63; // SUPPRESS CHECKSTYLE
} else {
return null;
}
// append the value to the quantum
quantum = (quantum << 6) | (byte) bits; // SUPPRESS CHECKSTYLE
if (inIndex%4 == 3) { // SUPPRESS CHECKSTYLE
// 4 characters were read, so make the output:
out[outIndex++] = (byte) ((quantum & 0x00FF0000) >> 16); // SUPPRESS CHECKSTYLE
out[outIndex++] = (byte) ((quantum & 0x0000FF00) >> 8); // SUPPRESS CHECKSTYLE
out[outIndex++] = (byte) (quantum & 0x000000FF); // SUPPRESS CHECKSTYLE
}
inIndex++;
}
if (pad > 0) {
// adjust the quantum value according to the padding
quantum = quantum << (6 * pad); // SUPPRESS CHECKSTYLE
// make output
out[outIndex++] = (byte) ((quantum & 0x00FF0000) >> 16);// SUPPRESS CHECKSTYLE
if (pad == 1) {
out[outIndex++] = (byte) ((quantum & 0x0000FF00) >> 8); // SUPPRESS CHECKSTYLE
}
}
// create the resulting array
byte[] result = new byte[outIndex];
System.arraycopy(out, 0, result, 0, outIndex);
return result;
}
/**
* BASE 64 MAP.
*/
private static final byte[] MAP = new byte[]
{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b',
'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'};
/**
* base64编码。
* @param in 原始输入
* @param charsetName 字符串集
* @return base64编码后的字符串。
* @throws UnsupportedEncodingException UnsupportedEncodingException
*/
public static String encode(byte[] in, String charsetName) throws UnsupportedEncodingException {
int length = in.length * 4 / 3; // SUPPRESS CHECKSTYLE
length += length / 76 + 3; // SUPPRESS CHECKSTYLE // for crlr
byte[] out = new byte[length];
int index = 0, i, crlr = 0, end = in.length - in.length%3; // SUPPRESS CHECKSTYLE
for (i=0; i<end; i+=3) { // SUPPRESS CHECKSTYLE
out[index++] = MAP[(in[i] & 0xff) >> 2]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[((in[i] & 0x03) << 4) // SUPPRESS CHECKSTYLE
| ((in[i+1] & 0xff) >> 4)]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[((in[i+1] & 0x0f) << 2) // SUPPRESS CHECKSTYLE
| ((in[i+2] & 0xff) >> 6)]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[(in[i+2] & 0x3f)]; // SUPPRESS CHECKSTYLE
if (((index - crlr)%76 == 0) && (index != 0)) { // SUPPRESS CHECKSTYLE
out[index++] = '\n';
crlr++;
//out[index++] = '\r';
//crlr++;
}
}
switch (in.length % 3) { // SUPPRESS CHECKSTYLE
case 1:
out[index++] = MAP[(in[end] & 0xff) >> 2]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[(in[end] & 0x03) << 4]; // SUPPRESS CHECKSTYLE
out[index++] = '=';
out[index++] = '=';
break;
case 2:
out[index++] = MAP[(in[end] & 0xff) >> 2]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[((in[end] & 0x03) << 4) // SUPPRESS CHECKSTYLE
| ((in[end+1] & 0xff) >> 4)]; // SUPPRESS CHECKSTYLE
out[index++] = MAP[((in[end+1] & 0x0f) << 2)]; // SUPPRESS CHECKSTYLE
out[index++] = '=';
break;
}
if (charsetName != null) {
return new String(out, 0, index, charsetName);
}
return new String(out, 0, index);
}
public static String encode(byte[] in) throws UnsupportedEncodingException {
return encode(in, null);
}
}
package com.halo.halojuhesdk.core.base.utils;
import com.halo.halojuhesdk.core.request.EcpmCompareBean;
import com.halo.halojuhesdk.core.request.SlotBean;
public class CompareEcpmUtils {
public static EcpmCompareBean compareEcpm(SlotBean bean, double ecpm) {
if (ecpm <= 0) {
ecpm = bean.getE();
}
if (bean.getP() > 0) {
if (bean.getP() < ecpm) {
return new EcpmCompareBean(true, bean.getP());
} else {//竞价竞败时 EcpmCompareBean传竞胜的价格
return new EcpmCompareBean(false, bean.getP());
}
} else {
ecpm = ecpm*bean.getD()/100;
if (ecpm <= bean.getMinPrice()) {//竞价竞败时 EcpmCompareBean传竞胜的价格
return new EcpmCompareBean(false, bean.getMinPrice());
} else {
return new EcpmCompareBean(true, ecpm);
}
}
}
}
package com.halo.halojuhesdk.core.base.utils;
public interface ConstantPool {
String SWICH_UPDATE = "swich";
String SWICH_DWLCONFIRM = "dwlconfirm";
String LOGO_SWITCH = "lg_swh";
String BRKDWN = "brkdwn";
String SSP_SDK = "SSP_SDK";
String A_SDK = "ASDK";
String UA_KEY = "UA_KEY";
String IMEI = "imei";
String DEFAULT_IMEI = "";
String DEFAULT_CELLULAR_ID = "0";
String DEFAULT_LAC = "0";
public static enum a {
nf("横幅广告", 1),
of("开屏广告", 2),
pf("插屏广告", 3),
NATIVE("原生广告", 4),
qf("激励视频广告", 5);
private String name;
private int type;
private a(String var3, int var4) {
this.name = var3;
this.type = var4;
}
public static a m(int var0) {
a[] var1;
int var2 = (var1 = values()).length;
for(int var3 = 0; var3 < var2; ++var3) {
a var4;
if ((var4 = var1[var3]).type == var0) {
return var4;
}
}
return null;
}
public String getName() {
return this.name;
}
public int getType() {
return this.type;
}
}
}
package com.halo.halojuhesdk.core.base.utils;
import static java.lang.Runtime.getRuntime;
import android.util.Log;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author zhanao.feng
* @date 2021/11/9 6:44 下午
* @description
*/
public class ExeCommand {
//shell进程
private Process process;
//对应进程的3个流
private BufferedReader successResult;
private BufferedReader errorResult;
private DataOutputStream os;
//是否同步,true:run会一直阻塞至完成或超时。false:run会立刻返回
private boolean bSynchronous;
//表示shell进程是否还在运行
private boolean bRunning = false;
//同步锁
ReadWriteLock lock = new ReentrantReadWriteLock();
//保存执行结果
private StringBuffer result = new StringBuffer();
/**
* 构造函数
*
* @param synchronous true:同步,false:异步
*/
public ExeCommand(boolean synchronous) {
bSynchronous = synchronous;
}
/**
* 默认构造函数,默认是同步执行
*/
public ExeCommand() {
bSynchronous = true;
}
/**
* 还没开始执行,和已经执行完成 这两种情况都返回false
*
* @return 是否正在执行
*/
public boolean isRunning() {
return bRunning;
}
/**
* @return 返回执行结果
*/
public String getResult() {
Lock readLock = lock.readLock();
readLock.lock();
try {
return new String(result);
} finally {
readLock.unlock();
}
}
/**
* 执行命令
*
* @param command eg: cat /sdcard/test.txt
* @param maxTime 最大等待时间 (ms)
* @return this
*/
public ExeCommand run(String command, final int maxTime) {
Log.i("auto", "run command:" + command + ",maxtime:" + maxTime);
if (command == null || command.length() == 0) {
return this;
}
try {
process = getRuntime().exec("sh");
} catch (Throwable e) {
return this;
}
bRunning = true;
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
os = new DataOutputStream(process.getOutputStream());
try {
//向sh写入要执行的命令
os.write(command.getBytes());
os.writeBytes("\n");
os.flush();
os.writeBytes("exit\n");
os.flush();
os.close();
//如果等待时间设置为非正,就不开启超时关闭功能
if (maxTime > 0) {
//超时就关闭进程
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(maxTime);
} catch (Throwable e) {
}
try {
int ret = process.exitValue();
} catch (Throwable e) {
Log.i("auto", "take maxTime,forced to destroy process");
process.destroy();
}
}
}).start();
}
//开一个线程来处理input流
final Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
String line;
Lock writeLock = lock.writeLock();
try {
while ((line = successResult.readLine()) != null) {
line += "\n";
writeLock.lock();
result.append(line);
writeLock.unlock();
}
} catch (Throwable e) {
Log.i("auto", "read InputStream exception:" + e.toString());
} finally {
try {
successResult.close();
} catch (Throwable e) {
Log.i("auto", "close InputStream exception:" + e.toString());
}
}
}
});
t1.start();
//开一个线程来处理error流
final Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
String line;
Lock writeLock = lock.writeLock();
try {
while ((line = errorResult.readLine()) != null) {
line += "\n";
writeLock.lock();
result.append(line);
writeLock.unlock();
}
} catch (Throwable e) {
Log.i("auto", "read ErrorStream exception:" + e.toString());
} finally {
try {
errorResult.close();
} catch (Throwable e) {
Log.i("auto", "read ErrorStream exception:" + e.toString());
}
}
}
});
t2.start();
Thread t3 = new Thread(new Runnable() {
@Override
public void run() {
try {
//等待执行完毕
t1.join();
t2.join();
process.waitFor();
} catch (Throwable e) {
} finally {
bRunning = false;
Log.i("auto", "run command process end");
}
}
});
t3.start();
if (bSynchronous) {
t3.join();
}
} catch (Throwable e) {
Log.i("auto", "run command process exception:" + e.toString());
}
return this;
}
}
/*
* Copyright (C) 2014 Huanju Inc. All rights reserved.
*/
package com.halo.halojuhesdk.core.base.utils;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
/**
* Hunanju 未捕获异常处理类
*
* 整体思路是捕获异常之后抛出异常
*
* @author Wang mingjun
* @since 2015-10-21
*/
public class HjExceptionHandler implements UncaughtExceptionHandler {
// private static final String TAG = "HjExceptionHandler";
// 缓存ExceptionHandler
private static UncaughtExceptionHandler mExceptionHandler;
// // 用于格式化日期,作为日志文件名的一部分
// private DateFormat formatter = new
// SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
/*
* 获取欢聚相关未捕获异常
*
* 由于有些异常可能是无网络情况下出现的因此需要考虑无网络状态兼容
*
* @see
* java.lang.Thread.UncaughtExceptionHandler#uncaughtException(java.lang
* .Thread, java.lang.Throwable)
*/
@Override
public void uncaughtException(Thread thread, Throwable ex) {
String threadLog = readCrashInfo(ex);
if (threadLog.contains("com.huanju")) {
// HjInfoGatheringManager.getInstance(HjSearchClient.getContext()).crashAdd();
// new HjReportExceptionProcessor(HjSearchClient.getContext(),
// threadLog).process();
}
if (mExceptionHandler != null) {
mExceptionHandler.uncaughtException(thread, ex);
}
}
/**
* @description 注册异常捕获
* @see
* @version
* @author Wang mingjun
* @since 2015-10-21
* @tags 需要在主线程调用
*/
public static void initExceptionHandler() {
mExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new HjExceptionHandler());
}
private String readCrashInfo(Throwable ex) {
StringBuffer sb = new StringBuffer();
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append(result);
return sb.toString();
}
}
package com.halo.halojuhesdk.core.base.utils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
* AES 算法工具类。
*/
public final class KeyUtil {
private static final String PRIVATE_KEY = "halomobi4966180e09676e73";
private static final String IV = "2011121211143000";
/**
* the name of the transformation to create a cipher for.
*/
private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding";
private static final String DETRANSFORMATION = "AES/CBC/PKCS7Padding";
/**
* 算法名称
*/
private static final String ALGORITHM_NAME = "AES";
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**
* private constructor.
*/
private KeyUtil() {
}
public static String encryptCurrentAES(String uid, String text) throws Exception {
// 固定前缀PRIVATE_KEY + uid
String key = PRIVATE_KEY;
// 转化为16位key
key = getMD5(key);
int size = key.length();
key = key.substring(size / 2).toLowerCase();
byte[] bs = encrypt(IV, key, text.getBytes("UTF-8"));
return Base64.encode(bs);
}
public static String encryptAES(String uid, String text) throws Exception {
// 固定前缀PRIVATE_KEY + uid
String key = PRIVATE_KEY;
// 转化为16位key
key = getMD5(key);
int size = key.length();
key = key.substring(size / 2);
// AES加密
byte[] data = encrypt(IV, key, text.getBytes("UTF-8"));
// base64转化
String encText = Base64.encode(data);
return encText;
}
public static String decryptAES(String uid, String text) throws Exception {
// base64解码
byte[] decrypted = Base64.decode(text.getBytes("UTF-8"));
// 固定前缀PRIVATE_KEY + uid
String key = PRIVATE_KEY + uid;
// 转化为16位key
key = getMD5(key);
int size = key.length();
key = key.substring(size / 2);
// 解密
byte[] data = decrypt(IV, key, decrypted);
String realText = new String(data, "UTF-8");
return realText;
}
/**
* aes 加密,AES/CBC/PKCS5Padding
*
* @param key 密钥字符串, 此处使用AES-128-CBC加密模式,key需要为16位
* @param content 要加密的内容
* @param cbcIv 初始化向量(CBC模式必须使用) 使用CBC模式,需要一个向量iv,可增加加密算法的强度
* @return 加密后原始二进制字符串
* @throws Exception Exception
*/
public static byte[] encrypt(String cbcIv, String key, byte[] content) throws Exception {
SecretKeySpec sksSpec = new SecretKeySpec(key.getBytes("UTF-8"),
ALGORITHM_NAME);
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
IvParameterSpec iv = new IvParameterSpec(cbcIv.getBytes("UTF-8"));
cipher.init(Cipher.ENCRYPT_MODE, sksSpec, iv);
byte[] encrypted = cipher.doFinal(content);
return encrypted;
}
/**
* aes 解密,AES/CBC/PKCS5Padding
*
* @param key 密钥, 此处使用AES-128-CBC加密模式,key需要为16位
* @param encrypted 密文
* @param cbcIv 初始化向量(CBC模式必须使用) 使用CBC模式,需要一个向量iv,可增加加密算法的强度
* @return 明文
* @throws Exception 异常
*/
public static byte[] decrypt(String cbcIv, String key, byte[] encrypted) throws Exception {
SecretKeySpec skeSpect = new SecretKeySpec(key.getBytes("UTF-8"),
ALGORITHM_NAME);
Cipher cipher = Cipher.getInstance(DETRANSFORMATION);
IvParameterSpec iv = new IvParameterSpec(cbcIv.getBytes("UTF-8"));
cipher.init(Cipher.DECRYPT_MODE, skeSpect, iv);
byte[] decrypted = cipher.doFinal(encrypted);
return decrypted;
}
public static String getMD5(String originalString) {
try {
MessageDigest digester = MessageDigest.getInstance("MD5");
try {
digester.update(originalString.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] b = digester.digest();
return bytesToHexString(b);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static String bytesToHexString(byte[] b) {
final int CONSTANT_NUMBER0XF0 = 0xf0;
final int CONSTANT_NUMBER0X0F = 0x0f;
final int CONSTANT_NUMBER4 = 4;
StringBuilder builder = new StringBuilder(b.length * 2);
for (int i = 0; i < b.length; i++) {
builder.append(HEX_DIGITS[(b[i] & CONSTANT_NUMBER0XF0) >>> CONSTANT_NUMBER4]);
builder.append(HEX_DIGITS[b[i] & CONSTANT_NUMBER0X0F]);
}
String string = builder.toString();
return string;
}
}
package com.halo.halojuhesdk.core.base.utils;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.text.TextUtils;
import android.util.Log;
import com.halo.halojuhesdk.core.common.utils.MyUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* @author Jeven QQ:2723402941
* @ClassName: LogUtils
* @Description: 日志输出控制类
* @date 2015-6-12 下午1:47:41
*/
public class LogUtils {
/**
* 日志输出级别NONE
*/
public static final int LEVEL_NONE = 0;
/**
* 日志输出级别V
*/
public static final int LEVEL_VERBOSE = 1;
/**
* 日志输出级别D
*/
public static final int LEVEL_DEBUG = 2;
/**
* 日志输出级别I
*/
public static final int LEVEL_INFO = 3;
/**
* 日志输出级别W
*/
public static final int LEVEL_WARN = 4;
/**
* 日志输出级别E
*/
public static final int LEVEL_ERROR = 5;
private static final String TEMPLATE1 = "%s(L:%d) %s";
/**
* 日志输出时的TAG
*/
private static String mTag = "huanju_tag";
/**
* 是否允许输出log
*/
private static int mDebuggable = LEVEL_NONE;
/**
* @param debug
*/
private static String clipText = "c372e6227d4a89c55d36addf72c7ea3f";
public static void setDeBugModel(int debug) {
//通过粘贴板中的内容为clipText,判断是否打开log日志
// if (getClipBoard()) {
// mDebuggable = LEVEL_ERROR;
// } else {
mDebuggable = debug;
// }
}
public static String getThrowable(Throwable e) {
StringBuffer sb_ero = new StringBuffer("\n----------------------------------");
sb_ero.append("threadId:" + Thread.currentThread().getId() + "\n");
sb_ero.append("error:" + e.getMessage() + "\n");
StackTraceElement[] elements = e.getStackTrace();
for (StackTraceElement element : elements) {
sb_ero.append(element.toString() + "\n");
}
sb_ero.append("\n" + "causeBy:" + e.getMessage() + "\n");
Throwable cause = e.getCause();
if (cause != null) {
StackTraceElement[] causesElements = cause.getStackTrace();
for (StackTraceElement element : causesElements) {
sb_ero.append(element.toString() + "\n");
}
}
sb_ero.append("\n----------------------------------------");
return sb_ero.toString();
}
//==================================================================================
/**
* 以级别为 v 的形式输出LOG
*/
public static void v(String log) {
if (mDebuggable >= LEVEL_VERBOSE) {
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.v(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 d 的形式输出LOG
*/
public static void d(String log) {
if (mDebuggable >= LEVEL_VERBOSE) {
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.d(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 i 的形式输出LOG
*/
public static void i(String log) {
if (mDebuggable >= LEVEL_VERBOSE) {
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.i(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 w 的形式输出LOG
*/
public static void w(String log) {
if (mDebuggable >= LEVEL_VERBOSE) {
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.w(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 w 的形式输出LOG
*/
public static void w(Throwable throwable) {
if (mDebuggable >= LEVEL_VERBOSE) {
String log = createThrowableInfo(throwable);
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.w(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 e 的形式输出LOG
*/
public static void e(String log) {
if (mDebuggable >= LEVEL_VERBOSE) {
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.e(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 以级别为 e 的形式输出LOG
*/
public static void e(Throwable throwable) {
if (mDebuggable >= LEVEL_VERBOSE) {
String log = createThrowableInfo(throwable);
StackTraceElement[] sElements = new Throwable().getStackTrace();
Log.e(sElements[1].getClassName(), createLog(sElements, log));
}
}
/**
* 拼接log
*
* @param sElements
* @param log
* @return
*/
private static String createLog(StackTraceElement[] sElements, String log) {
String methodName = sElements[1].getMethodName();
int lineNumber = sElements[1].getLineNumber();
String logInfo = String.format(TEMPLATE1, methodName, lineNumber, log);
// 存储log2file
// saveLog(saveLevel, logInfo);
return logInfo;
}
private static String createThrowableInfo(Throwable ex) {
StringBuffer sb_record = new StringBuffer();
StackTraceElement[] elements = ex.getStackTrace();
for (StackTraceElement element : elements) {
sb_record.append(element.toString() + "\n");
}
sb_record.append("\n" + "causeBy:" + ex.getMessage() + "\n");
Throwable cause = ex.getCause();
if (cause != null) {
StackTraceElement[] causesElements = cause.getStackTrace();
for (StackTraceElement element : causesElements) {
sb_record.append(element.toString() + "\n");
}
}
return sb_record.toString();
}
/**
* 转化成可读时间
*
* @param time 时间戳
* @return 可读时间
*/
public static String formatDate(long time) {
return new SimpleDateFormat("yy-MM-dd hh:mm:ss.SSS", Locale.getDefault()).format(new Date(time));
}
}
package com.halo.halojuhesdk.core.base.utils;
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import com.halo.halojuhesdk.core.common.utils.MyUtils;
import java.util.ArrayList;
import java.util.List;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class RequestPermissionManager {
public static final int DEFAULT_REQUEST_CODE = 10001;
private static RequestPermissionManager mInstance;
private RequestPermissionManager() {
}
public synchronized static RequestPermissionManager getInstance() {
return mInstance == null ? mInstance = new RequestPermissionManager() : mInstance;
}
public boolean shouldShowRequestPermissionRationale(Activity activity, String permission) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && activity != null) {
return activity.shouldShowRequestPermissionRationale(permission);
}
return false;
}
/**
* 初始化时调用,请求SDK所需的所有权限
* 位置、手机硬件信息、SD卡权限等
*/
public void requestPermissions(Activity activity, int requestCode) {
if (activity == null) {
LogUtils.d(" activity == null");
return;
}
List<String> permissions = new ArrayList<>();
//获取手机信息
if (!checkSelfPermission(Manifest.permission.READ_PHONE_STATE)) {
permissions.add(Manifest.permission.READ_PHONE_STATE);
}
//获取位置
// if (!checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
// permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
// }
//外部存储
if (!checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
requestPermissions(activity, permissions.toArray(new String[permissions.size()]), requestCode);
}
private void requestPermissions(Activity activity, String[] permission, int requestCode) {
if (permission == null || permission.length < 1) {
LogUtils.d("没有权限需要申请");
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.requestPermissions(permission, requestCode);
}
}
/**
* 检测权限
* Android 6.0之前版本默认返回true
*
* @param permission 权限名称
* @return 是否具有该权限
*/
public static boolean checkSelfPermission(String permission) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| PackageManager.PERMISSION_GRANTED == MyUtils.getContext().checkSelfPermission(permission);
}
}
package com.halo.halojuhesdk.core.channel;
import com.halo.halojuhesdk.core.common.utils.Config;
import com.halo.halojuhesdk.sdk.HlAdClient;
public class ChannelInitAdapter {
public static String api = "com.halomobi.sdk.HaloAdSdk";
public static String max = "com.applovin.sdk.AppLovinSdk";
/**
* 检查当前sdk 的接入情况
*/
public boolean verifyInitClass(Config.JuHeAdType platform) {
try {
if (HlAdClient.mTypeList.contains(platform)) {
return true;
}
String initClass = mappingInitClass(platform);
Class.forName(initClass);
HlAdClient.mTypeList.add(platform);
// Log.e("已接入SDK: " + platform + UbixConstant.PlatForm.getAdnName(platform));
return true;
} catch (Throwable e) {
// ULog.exception(e);
}
return false;
}
public String mappingInitClass(Config.JuHeAdType platform) {
switch (platform) {
case API:
return ChannelInitAdapter.api;
case MAX:
return ChannelInitAdapter.max;
default:
return null;
}
}
}
package com.halo.halojuhesdk.core.channel;
/**
* @author Feng Zhanao
* @date 2018/12/28
* @description 渠道静态变量
*/
public class ChnelContant {
/**
* 以下是各个渠道
*/
public static final int CHANNEL_MTG = 1;
public static final int CHANNEL_GDT = 2;
public static final int CHANNEL_TT = 3;
public static final int CHANNEL_NGA = 4;
public static final int CHANNEL_API = 5;
public static final int CHANNEL_JD = 6;
public static final int CHANNEL_KS = 7;
public static final int CHANNEL_BD = 8;
}
package com.halo.halojuhesdk.core.channel;
/**
* @author Feng Zhanao
* @date 2018/12/28
* @description
*/
public interface ISplashAd {
void LoadAndShowAd();
}
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