Bladeren bron

优化广告拉去失败

dxl 4 maanden geleden
bovenliggende
commit
8226d183e9
35 gewijzigde bestanden met toevoegingen van 2534 en 220 verwijderingen
  1. 2 2
      .idea/deploymentTargetSelector.xml
  2. 34 1
      app/build.gradle.kts
  3. 41 1
      app/src/main/AndroidManifest.xml
  4. 1 0
      app/src/main/assets/localStrategy/a684009039113d.json
  5. 0 0
      app/src/main/assets/localStrategy/b68400ad783355.json
  6. 107 3
      app/src/main/java/com/ytpm/hydtw/activity/LoginActivity.kt
  7. 30 9
      app/src/main/java/com/ytpm/hydtw/activity/MainActivity.kt
  8. 102 0
      app/src/main/java/com/ytpm/hydtw/activity/SplashActivity.kt
  9. 1 0
      app/src/main/java/com/ytpm/hydtw/adapter/BaseAdapter.kt
  10. 1 1
      app/src/main/java/com/ytpm/hydtw/adapter/MineAdapter.kt
  11. 1 5
      app/src/main/java/com/ytpm/hydtw/adapter/NotePagerAdapter.kt
  12. 19 2
      app/src/main/java/com/ytpm/hydtw/application/DatiApplication.kt
  13. 5 5
      app/src/main/java/com/ytpm/hydtw/dao/UserInfo.kt
  14. 407 33
      app/src/main/java/com/ytpm/hydtw/fragment/DatiFragment.kt
  15. 9 1
      app/src/main/java/com/ytpm/hydtw/loading/GlobalLoading.java
  16. 1 4
      app/src/main/java/com/ytpm/hydtw/network/BaseRetrofit.java
  17. 13 8
      app/src/main/java/com/ytpm/hydtw/network/Callback2.java
  18. 24 1
      app/src/main/java/com/ytpm/hydtw/network/api/MRefrofitInterface.java
  19. 2 1
      app/src/main/java/com/ytpm/hydtw/network/api/api.java
  20. 60 0
      app/src/main/java/com/ytpm/hydtw/utils/Base64Decoder.kt
  21. 61 0
      app/src/main/java/com/ytpm/hydtw/utils/DateTimeUtils.kt
  22. 120 0
      app/src/main/java/com/ytpm/hydtw/utils/GameNetworkUtils.kt
  23. 525 0
      app/src/main/java/com/ytpm/hydtw/utils/MediationNativeAdUtil.java
  24. 39 0
      app/src/main/java/com/ytpm/hydtw/utils/MutiImageView.java
  25. 459 0
      app/src/main/java/com/ytpm/hydtw/utils/SelfRenderViewUtil.java
  26. 192 116
      app/src/main/res/layout/activity_login.xml
  27. 2 0
      app/src/main/res/layout/activity_main.xml
  28. 40 0
      app/src/main/res/layout/activity_splash.xml
  29. 26 2
      app/src/main/res/layout/fragment_dati.xml
  30. 193 0
      app/src/main/res/layout/layout_native_self_mix.xml
  31. BIN
      app/src/main/res/mipmap-xxhdpi/close.png
  32. 4 4
      app/src/main/res/xml/network_security_config.xml
  33. 0 1
      build.gradle.kts
  34. 1 19
      gradle.properties
  35. 12 1
      settings.gradle.kts

+ 2 - 2
.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2025-06-03T09:51:06.650632200Z">
+        <DropdownSelection timestamp="2025-06-24T08:17:15.280385900Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="Default" identifier="serial=emulator-5554;connection=727cecb6" />
+              <DeviceId pluginId="PhysicalDevice" identifier="serial=000002f6ac59484e" />
             </handle>
           </Target>
         </DropdownSelection>

+ 34 - 1
app/build.gradle.kts

@@ -35,10 +35,11 @@ android {
         minSdk = 24
         targetSdk = 35
         versionCode = 1
-        versionName = "1.0"
+        versionName = "1.0.2.1"
         multiDexEnabled = true
         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
         resValue("string", "app_name", "好运答题王")
+//        buildConfigField("String", "BASE_URL", "DDDDDD")
     }
 
     buildTypes {
@@ -66,6 +67,7 @@ android {
         viewBinding = true
         aidl = true
     }
+
 }
 
 dependencies {
@@ -88,4 +90,35 @@ dependencies {
     testImplementation(libs.junit)
     androidTestImplementation(libs.androidx.junit)
     androidTestImplementation(libs.androidx.espresso.core)
+    implementation("org.threeten:threetenbp:1.5.1")
+
+    //Anythink (Necessary)
+    api("com.anythink.sdk:core-taku:6.4.87")
+    api("com.anythink.sdk:core-china-taku:6.4.87")
+    api("com.anythink.sdk:nativead-taku:6.4.87")
+    api("com.anythink.sdk:banner-taku:6.4.87")
+    api("com.anythink.sdk:interstitial-taku:6.4.87")
+    api("com.anythink.sdk:rewardedvideo-taku:6.4.87")
+    api("com.anythink.sdk:splash-taku:6.4.87")
+
+    //Support (Necessary)
+    api("com.android.support:appcompat-v7:28.0.0")
+
+    //Baidu
+    api("com.anythink.sdk:adapter-taku-baidu:6.4.87.4")
+    api("mobi.baidu.sdk:mobads:9.391.2")
+
+    //Kuaishou
+    api("com.anythink.sdk:adapter-taku-kuaishou:6.4.87")
+    api("com.anythink.sdk:sdk-ads-kuaishou:3.3.76")
+    api("com.android.support:design:28.0.0")
+
+    //Csj
+    api("com.anythink.sdk:adapter-taku-csj:6.4.87.5")
+    api("com.pangle.cn:ads-sdk-pro:6.8.2.0")
+
+    //GDT
+    api("com.anythink.sdk:adapter-taku-gdt:6.4.87.1")
+    api("com.qq.e.union:union:4.640.1510")
+
 }

+ 41 - 1
app/src/main/AndroidManifest.xml

@@ -30,6 +30,17 @@
             android:name="design_height_in_dp"
             android:value="812" />
 
+        <activity
+            android:name="com.ytpm.hydtw.activity.SplashActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:exported="true"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait"
+            android:theme="@style/Theme.Dati"
+            tools:ignore="DiscouragedApi,LockedOrientationActivity">
+
+        </activity>
+
         <activity
             android:name="com.ytpm.hydtw.activity.LoginActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
@@ -41,14 +52,16 @@
                 <action android:name="android.intent.action.MAIN" />
 
                 <category android:name="android.intent.category.LAUNCHER" />
+
             </intent-filter>
+
         </activity>
 
         <activity
             android:name="com.ytpm.hydtw.activity.MainActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:exported="true"
-            android:launchMode="singleTask"
+            android:launchMode="standard"
             android:screenOrientation="portrait"
             android:theme="@style/Theme.Dati"
             tools:ignore="DiscouragedApi,LockedOrientationActivity" />
@@ -104,7 +117,34 @@
         <uses-library
             android:name="org.apache.http.legacy"
             android:required="false" />
+        <!-- source file: china_jcenter/network_sdk/baidu/9.391.2/AndroidManifest.xml -->
+
+        <!-- source file: china_jcenter/network_sdk/csj/6.8.2.0/AndroidManifest.xml -->
+        <provider
+            android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
+            android:authorities="${applicationId}.TTMultiProvider"
+            android:exported="false" />
+
+        <provider
+            android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
+            android:authorities="${applicationId}.TTFileProvider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/anythink_bk_tt_file_path" />
+        </provider>
+        <!-- source file: china_jcenter/network_sdk/gdt/4.640.1510/AndroidManifest.xml -->
 
+        <provider
+            android:name="com.qq.e.comm.GDTFileProvider"
+            android:authorities="${applicationId}.gdt.fileprovider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/anythink_bk_gdt_file_path" />
+        </provider>
     </application>
 
 </manifest>

+ 1 - 0
app/src/main/assets/localStrategy/a684009039113d.json

@@ -0,0 +1 @@
+eyJzX3BfZGF0YSI6e319

File diff suppressed because it is too large
+ 0 - 0
app/src/main/assets/localStrategy/b68400ad783355.json


File diff suppressed because it is too large
+ 107 - 3
app/src/main/java/com/ytpm/hydtw/activity/LoginActivity.kt


+ 30 - 9
app/src/main/java/com/ytpm/hydtw/activity/MainActivity.kt

@@ -6,11 +6,15 @@ import android.widget.RadioGroup.OnCheckedChangeListener
 import androidx.appcompat.app.AppCompatActivity
 import androidx.fragment.app.FragmentActivity
 import androidx.viewpager.widget.ViewPager.OnPageChangeListener
+import com.blankj.utilcode.util.ToastUtils
 import com.ytpm.hydtw.R
 import com.ytpm.hydtw.adapter.NotePagerAdapter
 import com.ytpm.hydtw.databinding.ActivityMainBinding
+import com.ytpm.hydtw.utils.DateTimeUtils
 
 class MainActivity : FragmentActivity(), OnPageChangeListener, OnCheckedChangeListener {
+    private var clickTime: Int = 0
+    private var millisTimestamp1: Long = 0L
     private lateinit var binding: ActivityMainBinding
 
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -28,9 +32,9 @@ class MainActivity : FragmentActivity(), OnPageChangeListener, OnCheckedChangeLi
         val pagerAdapter = NotePagerAdapter(supportFragmentManager)
         binding.vp.adapter = pagerAdapter
 
-        binding.vp.addOnPageChangeListener(this)
+//        binding.vp.addOnPageChangeListener(this)
 
-        binding.rg.setOnCheckedChangeListener(this)
+//        binding.rg.setOnCheckedChangeListener(this)
     }
 
     override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
@@ -48,14 +52,31 @@ class MainActivity : FragmentActivity(), OnPageChangeListener, OnCheckedChangeLi
     }
 
     override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
-        var currentPosition = 0
-        when (checkedId) {
-            R.id.rb1 -> currentPosition = 0
-            R.id.rb2 -> currentPosition = 1
-            R.id.rb3 -> currentPosition = 2
-        }
+//        var currentPosition = 0
+//        when (checkedId) {
+//            R.id.rb1 -> currentPosition = 0
+//            R.id.rb2 -> currentPosition = 1
+//            R.id.rb3 -> currentPosition = 2
+//        }
+
+//        binding.vp.currentItem = currentPosition
+
+    }
 
-        binding.vp.currentItem = currentPosition
+    @Deprecated("Deprecated in Java")
+    override fun onBackPressed() {
 
+        if (clickTime == 0) {
+            millisTimestamp1 = System.currentTimeMillis()
+            ToastUtils.showLong("再次点击退出应用!")
+            clickTime++
+            return
+        }
+
+        if (System.currentTimeMillis() - millisTimestamp1 < 1000) {
+            super.onBackPressed()
+        } else {
+            clickTime = 0
+        }
     }
 }

+ 102 - 0
app/src/main/java/com/ytpm/hydtw/activity/SplashActivity.kt

@@ -0,0 +1,102 @@
+package com.ytpm.hydtw.activity
+
+import android.annotation.SuppressLint
+import android.content.Intent
+import android.os.Bundle
+import android.os.CountDownTimer
+import android.view.View
+import androidx.fragment.app.FragmentActivity
+import com.anythink.core.api.ATAdInfo
+import com.anythink.core.api.AdError
+import com.anythink.splashad.api.ATSplashAd
+import com.anythink.splashad.api.ATSplashAdExtraInfo
+import com.anythink.splashad.api.ATSplashAdListener
+import com.blankj.utilcode.util.LogUtils
+import com.ytpm.hydtw.databinding.ActivitySplashBinding
+
+class SplashActivity : FragmentActivity(), ATSplashAdListener {
+
+    private var getTlCountDownTimer: CountDownTimer? = null
+    private lateinit var binding: ActivitySplashBinding
+    private var splashAd: ATSplashAd? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+
+        binding = ActivitySplashBinding.inflate(layoutInflater)
+        setContentView(binding.root)
+//        loadAd()
+        startGetTlTime()
+    }
+
+    override fun onResume() {
+        super.onResume()
+        binding.close.setOnClickListener {
+            val intent = Intent(this@SplashActivity, LoginActivity::class.java)
+            startActivity(intent)
+            finish()
+        }
+    }
+
+    private fun startGetTlTime() {
+
+        if (getTlCountDownTimer != null) {
+            return
+        }
+
+        getTlCountDownTimer = object : CountDownTimer(5000, 1000) {
+            @SuppressLint("SetTextI18n")
+            override fun onTick(millisUntilFinished: Long) {
+
+            }
+
+            override fun onFinish() {
+                val intent = Intent(this@SplashActivity, LoginActivity::class.java)
+                startActivity(intent)
+                finish()
+            }
+        }
+    }
+
+    private fun loadAd() {
+        splashAd = ATSplashAd(this, "b68400ad783355", this, 5000)
+        splashAd?.loadAd()
+    }
+
+    override fun onAdLoaded(p0: Boolean) {
+        LogUtils.e("=======onAdLoaded=${p0}")
+        if (splashAd?.isAdReady == true) {
+            splashAd?.show(this@SplashActivity, binding.splashAdFl)
+        }
+    }
+
+
+    override fun onAdLoadTimeout() {
+        LogUtils.e("=======onAdLoadTimeout")
+    }
+
+    override fun onNoAdError(p0: AdError?) {
+        LogUtils.e("=======onNoAdError=${p0}")
+        if (getTlCountDownTimer != null) getTlCountDownTimer?.start()
+    }
+
+    override fun onAdShow(p0: ATAdInfo?) {
+        LogUtils.e("=======onAdShow=${p0.toString()}")
+        if (getTlCountDownTimer != null) getTlCountDownTimer?.start()
+    }
+
+    override fun onAdClick(p0: ATAdInfo?) {
+        LogUtils.e("=======onAdClick=${p0.toString()}")
+    }
+
+    override fun onAdDismiss(p0: ATAdInfo?, p1: ATSplashAdExtraInfo?) {
+        LogUtils.e("=======onAdDismiss=${p0.toString()}")
+    }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        splashAd = null
+        getTlCountDownTimer?.cancel()
+        getTlCountDownTimer = null
+    }
+}

+ 1 - 0
app/src/main/java/com/ytpm/hydtw/adapter/BaseAdapter.kt

@@ -5,6 +5,7 @@ import android.view.LayoutInflater
 import android.view.ViewGroup
 import androidx.recyclerview.widget.RecyclerView
 import androidx.viewbinding.ViewBinding
+import com.ytpm.hydtw.dao.item
 
 abstract class BaseAdapter<VB : ViewBinding, T>(
     val inflater: (LayoutInflater, parent: ViewGroup, attachToRoot: Boolean) -> VB,

+ 1 - 1
app/src/main/java/com/ytpm/hydtw/adapter/MineAdapter.kt

@@ -16,7 +16,7 @@ class MineAdapter(items: MutableList<Record>) :
     ) {
 
         val ddd = DateTimeConverter.convertToBeijingTime(t.answerTime, "yyyy/MM/dd HH:mm:ss")
-        val index = position + 1
+        val index = itemCount - position
         binding.time.text = "${index}: $ddd"
     }
 }

+ 1 - 5
app/src/main/java/com/ytpm/hydtw/adapter/NotePagerAdapter.kt

@@ -4,21 +4,17 @@ import androidx.fragment.app.Fragment
 import androidx.fragment.app.FragmentManager
 import androidx.fragment.app.FragmentPagerAdapter
 import com.ytpm.hydtw.fragment.DatiFragment
-import com.ytpm.hydtw.fragment.MineFragment
-import com.ytpm.hydtw.fragment.ZixunFragment
 
 @Suppress("DEPRECATION")
 class NotePagerAdapter(fm: FragmentManager) :
     FragmentPagerAdapter(fm) {
     override fun getCount(): Int {
-        return 3
+        return 1
     }
 
     override fun getItem(position: Int): Fragment {
         when (position) {
             0 -> return DatiFragment()
-            1 -> return ZixunFragment()
-            2 -> return MineFragment()
             else -> return DatiFragment()
         }
     }

+ 19 - 2
app/src/main/java/com/ytpm/hydtw/application/DatiApplication.kt

@@ -2,6 +2,8 @@ package com.ytpm.hydtw.application
 
 import android.app.Application
 import android.view.Gravity
+import com.anythink.core.api.ATAdConst
+import com.anythink.core.api.ATSDK
 import com.blankj.utilcode.util.LogUtils
 import com.blankj.utilcode.util.ToastUtils
 import com.ytpm.hydtw.R
@@ -17,12 +19,27 @@ class DatiApplication : Application() {
 
     override fun onCreate() {
         super.onCreate()
+
+        instance = this
+
         AutoSize.initCompatMultiProcess(this)
+
         ToastUtils.getDefaultMaker().setMode(ToastUtils.MODE.DARK)
         ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER, 0, 0)
 
-        LogUtils.getConfig().setLogSwitch(false)
+        LogUtils.getConfig().setLogSwitch(true)
+
+        ATSDK.setNetworkLogDebug(true)
+        ATSDK.integrationChecking(this)
+        ATSDK.setPersonalizedAdStatus(ATAdConst.PRIVACY.PERSIONALIZED_ALLOW_STATUS)
+
+        ATSDK.setLocalStrategyAssetPath(this, "localStrategy")
+        ATSDK.init(
+            applicationContext,
+            "a684009039113d",
+            "afd78bcd2b03126f0c24d7b4e48a439d6"
+        )
+        ATSDK.start()
 
-        instance = this
     }
 }

+ 5 - 5
app/src/main/java/com/ytpm/hydtw/dao/UserInfo.kt

@@ -9,15 +9,15 @@ data class UserInfo(
     val lastLoginIp: String,
     val loginDays: Int,
     val totalVideo: Int,
-    val totalIncome: Int,
+    val totalIncome: Double,
     val redPacketBalance: Double,
     val redPacketAmount: Double,
-    val pointsBalance: Int,
-    val pointsTotal: Int,
-    val withdrawTotal: Int,
+    val pointsBalance: Double,
+    val pointsTotal: Double,
+    val withdrawTotal: Double,
     val signDays: Int,
     val userStatus: Int,
-    val riskReason: Int,
+    val riskReason: String,
     val wxOpenId: String,
     val platformId: String,
     var lastQuestionId: String,

+ 407 - 33
app/src/main/java/com/ytpm/hydtw/fragment/DatiFragment.kt

@@ -10,7 +10,19 @@ import android.view.View
 import android.view.ViewGroup
 import androidx.core.content.res.ResourcesCompat
 import androidx.fragment.app.Fragment
-import com.blankj.utilcode.util.GsonUtils
+import com.anythink.banner.api.ATBannerListener
+import com.anythink.banner.api.ATBannerView
+import com.anythink.core.api.ATAdConst
+import com.anythink.core.api.ATAdInfo
+import com.anythink.core.api.ATShowConfig
+import com.anythink.core.api.AdError
+import com.anythink.interstitial.api.ATInterstitial
+import com.anythink.interstitial.api.ATInterstitialListener
+import com.anythink.nativead.api.ATNative
+import com.anythink.nativead.api.ATNativeNetworkListener
+import com.anythink.nativead.api.NativeAd
+import com.anythink.rewardvideo.api.ATRewardVideoAd
+import com.anythink.rewardvideo.api.ATRewardVideoListener
 import com.blankj.utilcode.util.LogUtils
 import com.blankj.utilcode.util.ToastUtils
 import com.blankj.utilcode.util.ToastUtils.MODE
@@ -20,10 +32,14 @@ import com.ytpm.hydtw.adapter.MineAdapter
 import com.ytpm.hydtw.dao.Question
 import com.ytpm.hydtw.dao.Record
 import com.ytpm.hydtw.databinding.FragmentDatiBinding
+import com.ytpm.hydtw.loading.GlobalLoading
+import com.ytpm.hydtw.loading.LoadingDialog
 import com.ytpm.hydtw.network.BaseRetrofit
 import com.ytpm.hydtw.network.Callback2
 import com.ytpm.hydtw.utils.DateTimeConverter
+import com.ytpm.hydtw.utils.DateTimeUtils
 import com.ytpm.hydtw.utils.GlideUtils
+import com.ytpm.hydtw.utils.MediationNativeAdUtil
 import com.ytpm.hydtw.utils.UserInfoSpUtils
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.DelicateCoroutinesApi
@@ -34,13 +50,28 @@ import kotlinx.coroutines.cancel
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.isActive
 import kotlinx.coroutines.launch
-
-class DatiFragment : Fragment() {
-
-    private var job:Job? = null
-    private var scope:CoroutineScope? = null
+import java.time.Instant
+import java.time.LocalDateTime
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
+
+
+class DatiFragment() : Fragment(), ATRewardVideoListener,
+    ATBannerListener {
+
+    private var atNative: ATNative? = null
+    private var interstitialAd: ATInterstitial? = null
+    private var startAdTime: String? = null
+    private var endAdTime: String? = null
+    private var mRewardVideoAd: ATRewardVideoAd? = null
+    private var job: Job? = null
+    private var scope: CoroutineScope? = null
+    private var job1: Job? = null
+    private var scope1: CoroutineScope? = null
+    private var inAdTime: Int = 0
     private var getTlCountDownTimer: CountDownTimer? = null
     private var getTlShowBtnCountDownTimer: CountDownTimer? = null
+    private var startReloadRewardVideoAd: CountDownTimer? = null
     private var useTimer: Int = 0
     private var questions: ArrayList<Question>? = arrayListOf()
     private lateinit var binding: FragmentDatiBinding
@@ -50,13 +81,17 @@ class DatiFragment : Fragment() {
     private var jrdd = 0
     private var lsdd = 0
 
-    private var getTlTime = 30
-    private var getTlShowBtnTime = 10
+    private var getTlTime = 20
+    private var getTlShowBtnTime = 8
 
     private var isGrDialogShow = false
     private var isGetTlDialogShow = false
 
     private var isGetResult = false
+    private var isInAdPaunse = false
+
+    private var loadDialog: LoadingDialog? = null
+    private var loadingTime = 10
 
     override fun onCreateView(
         inflater: LayoutInflater,
@@ -69,25 +104,28 @@ class DatiFragment : Fragment() {
             .statusBarDarkFont(true)
             .titleBar(null)
             .init()
-
+        loadAd()
         initData()
         initUserTime()
-        return binding.root
-    }
-
-    override fun onResume() {
-        super.onResume()
+        initInAdTime()
+        loadBannerAd()
+        loadNativeAd()
+        loadInterstitial()
         initView()
         useTimer = 0
+        return binding.root
     }
 
     private fun initView() {
 
         val headImg = UserInfoSpUtils().getHeadImg()
-        context?.let {
-            GlideUtils().circelImages(it, headImg, binding.dialogGettlHead)
-            GlideUtils().circelImages(it, headImg, binding.fragmentDatiHead)
-            GlideUtils().circelImages(it, headImg, binding.dialogSetHead)
+
+        if (headImg.isNotEmpty()) {
+            context?.let {
+                GlideUtils().circelImages(it, headImg, binding.dialogGettlHead)
+                GlideUtils().circelImages(it, headImg, binding.fragmentDatiHead)
+                GlideUtils().circelImages(it, headImg, binding.dialogSetHead)
+            }
         }
 
         val registerTime = UserInfoSpUtils().getRegistryTime()
@@ -100,7 +138,7 @@ class DatiFragment : Fragment() {
         binding.dialogGettlLoginTime.text = "登录时间:${ccc}"
 
         val uid = UserInfoSpUtils().getUserId()
-        binding.fragmentDatiUid.text = "UID:${uid}"
+        binding.fragmentDatiUid.text = uid
         binding.dialogGettlUserid.text = uid
         binding.dialogSetUserid.text = uid
 
@@ -121,6 +159,7 @@ class DatiFragment : Fragment() {
         binding.switch2.isChecked = true
 
         startGetTlTime()
+
         startGetTlShowBtnTime()
 
         initGetTlTime()
@@ -143,7 +182,7 @@ class DatiFragment : Fragment() {
             binding.dialogGr.visibility = View.GONE
         }
 
-        binding.getTl.setOnClickListener {
+        binding.getTlCl.setOnClickListener {
 
             if (getTlTime > 0) {
                 ToastUtils.showShort("等待倒计时结束!")
@@ -164,7 +203,12 @@ class DatiFragment : Fragment() {
         binding.dialgoGettlLl.setOnClickListener { }
 
         binding.dialotGettlBtnTx.setOnClickListener {
-            addPower()
+            showAd()
+        }
+        binding.getTlDialogClose.setOnClickListener {
+            this.isGetTlDialogShow = false
+            binding.dialgoGettlLl.visibility = View.GONE
+            initGetTlBtnTime()
         }
 
         binding.a1.setOnClickListener {
@@ -185,23 +229,60 @@ class DatiFragment : Fragment() {
     }
 
     private fun initUserTime() {
-        if (job == null){
+        if (job == null) {
             job = Job()
         }
 
-        if (scope == null){
+        if (scope == null) {
             scope = CoroutineScope(Dispatchers.Main + job!!)
         }
 
         scope!!.launch {
             while (isActive) {
                 useTimer++
-                LogUtils.e(useTimer)
                 delay(1000)
             }
         }
     }
 
+    private fun initInAdTime() {
+        if (job1 == null) {
+            job1 = Job()
+        }
+
+        if (scope1 == null) {
+            scope1 = CoroutineScope(Dispatchers.Main + job1!!)
+        }
+
+        scope1!!.launch {
+            while (isActive) {
+                if (!isInAdPaunse) {
+                    inAdTime++
+                    if (inAdTime == 60) {
+
+                        interstitialAd?.show(activity, getATShowConfig1())
+                        job1?.cancel()
+                        scope1?.cancel()
+                        job1 = null
+                        scope1 = null
+                        inAdTime = 0
+                    }
+                }
+                delay(1000)
+            }
+        }
+    }
+
+    override fun onPause() {
+        super.onPause()
+        this.isInAdPaunse = true
+    }
+
+    override fun onResume() {
+        super.onResume()
+        this.isInAdPaunse = false
+    }
+
     private fun initDialogGetTl() {
 
         val adapter = MineAdapter(initDataAdapter())
@@ -230,6 +311,23 @@ class DatiFragment : Fragment() {
             .enqueue(object : Callback2<Any>() {
                 override fun success(body: Any?) {
                     val userinfo = UserInfoSpUtils().getUserInfo()
+
+                    var answerTime = ""
+
+                    // 格式化为ISO字符串
+                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                        val instant = Instant.now()
+                        val formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME
+                        answerTime = instant.atZone(ZoneId.of("UTC")).format(formatter)
+                    } else {
+                        answerTime = DateTimeUtils.getCurrentDateTimeIso().toString()
+                    }
+
+                    val record = Record(answerTime)
+                    val ddd = UserInfoSpUtils().getUserInfo().answerRecordList as MutableList
+                    ddd.add(0, record)
+
+                    userinfo.answerRecordList = ddd
                     userinfo.lastQuestionId = questionId
                     UserInfoSpUtils().changeValue(userinfo)
                     initDialogGetTl()
@@ -282,7 +380,7 @@ class DatiFragment : Fragment() {
     @SuppressLint("SetTextI18n")
     private fun initGetTlTime() {
         binding.zz.visibility = View.VISIBLE
-        getTlTime = 30
+        getTlTime = 20
         binding.zz.text = "${getTlTime}s"
         getTlCountDownTimer?.start()
     }
@@ -290,8 +388,9 @@ class DatiFragment : Fragment() {
     @SuppressLint("SetTextI18n")
     private fun initGetTlBtnTime() {
         binding.dialotGettlBtnTx.visibility = View.GONE
+        binding.getTlDialogClose.visibility = View.GONE
         binding.dialgoGettlTime.visibility = View.VISIBLE
-        getTlShowBtnTime = 10
+        getTlShowBtnTime = 8
         binding.dialgoGettlTime.text = "${getTlShowBtnTime}s"
     }
 
@@ -300,7 +399,7 @@ class DatiFragment : Fragment() {
         if (getTlShowBtnCountDownTimer != null) {
             return
         }
-        this.getTlShowBtnTime = 10
+        this.getTlShowBtnTime = 8
         getTlShowBtnCountDownTimer =
             object : CountDownTimer((getTlShowBtnTime * 1000).toLong(), 1000) {
                 @SuppressLint("SetTextI18n")
@@ -313,6 +412,7 @@ class DatiFragment : Fragment() {
                 override fun onFinish() {
                     binding.dialgoGettlTime.visibility = View.GONE
                     binding.dialotGettlBtnTx.visibility = View.VISIBLE
+                    binding.getTlDialogClose.visibility = View.VISIBLE
                 }
             }
     }
@@ -323,7 +423,7 @@ class DatiFragment : Fragment() {
             return
         }
 
-        this.getTlTime = 30
+        this.getTlTime = 20
         getTlCountDownTimer = object : CountDownTimer((getTlTime * 1000).toLong(), 1000) {
             @SuppressLint("SetTextI18n")
             override fun onTick(millisUntilFinished: Long) {
@@ -338,6 +438,25 @@ class DatiFragment : Fragment() {
         }
     }
 
+    private fun startReloadRewardVideoAd() {
+
+        if (startReloadRewardVideoAd != null) {
+            return
+        }
+
+        startReloadRewardVideoAd = object : CountDownTimer((loadingTime * 1000).toLong(), 1000) {
+            @SuppressLint("SetTextI18n")
+            override fun onTick(millisUntilFinished: Long) {
+
+            }
+
+            override fun onFinish() {
+                ToastUtils.showShort("非法操作,请30秒后重新获取!")
+                if (loadDialog?.isShowing == true) loadDialog?.dismiss()
+            }
+        }
+    }
+
     private fun initLever() {
         val lastQuestionId = UserInfoSpUtils().getLastQuestionId()
         questions?.forEachIndexed { index, question ->
@@ -447,6 +566,8 @@ class DatiFragment : Fragment() {
         val questionId = item?.questionId
         val itemId = item?.itemList?.get(btnIndex)?.itemId
 
+
+
         if (questionId != null && itemId != null) {
             answer(questionId, itemId)
         } else {
@@ -509,8 +630,8 @@ class DatiFragment : Fragment() {
         }
     }
 
-    override fun onPause() {
-        super.onPause()
+    override fun onDestroy() {
+        super.onDestroy()
         getTlCountDownTimer?.cancel()
         getTlShowBtnCountDownTimer?.cancel()
         getTlCountDownTimer = null
@@ -521,8 +642,261 @@ class DatiFragment : Fragment() {
         scope = null
     }
 
-    override fun onDestroy() {
-        super.onDestroy()
-        job?.cancel()
+    private fun loadAd() {
+        if (mRewardVideoAd == null) {
+            mRewardVideoAd = ATRewardVideoAd(context, "b68400aae18fc0")
+        }
+        val userid = UserInfoSpUtils().getUserInfo().userId
+        val userdata = UserInfoSpUtils().getUserInfo().nickName
+        val localMap: MutableMap<String, Any> = HashMap()
+        localMap[ATAdConst.KEY.USER_ID] = userid
+        localMap[ATAdConst.KEY.USER_CUSTOM_DATA] = userdata
+        mRewardVideoAd?.setLocalExtra(localMap)
+        mRewardVideoAd?.setAdListener(this)
+        mRewardVideoAd?.load()
+    }
+
+    private var isReload = false
+
+    private fun showAd() {
+        if (mRewardVideoAd?.isAdReady == true) {
+            mRewardVideoAd?.show(activity)
+            return
+        }
+
+        // 在 Fragment 中使用
+        if (isAdded && activity != null && !requireActivity().isFinishing) {
+            loadDialog = LoadingDialog(activity)
+            loadDialog?.show()
+            startReloadRewardVideoAd()
+            startReloadRewardVideoAd?.start()
+        }
+        isReload = true
+        if (mRewardVideoAd?.checkAdStatus()?.isLoading != true) mRewardVideoAd?.load()
+
+    }
+
+    private var isRewardedVideoFinish = false
+
+    override fun onRewardedVideoAdLoaded() {
+        LogUtils.e("DFDFDF=onRewardedVideoAdLoaded")
+        startReloadRewardVideoAd?.cancel()
+        startReloadRewardVideoAd = null
+        if (loadDialog?.isShowing == true) loadDialog?.dismiss()
+        if (isReload) showAd()
+    }
+
+    override fun onRewardedVideoAdFailed(p0: AdError?) {
+        LogUtils.e("DFDFDF=onRewardedVideoAdFailed${p0?.code}")
+    }
+
+    override fun onRewardedVideoAdPlayStart(p0: ATAdInfo?) {
+        isReload = false
+        isRewardedVideoFinish = false
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            val current = LocalDateTime.now()
+            val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
+            startAdTime = current.format(formatter)
+        } else {
+            startAdTime = DateTimeUtils.getCurrentDateTime()
+        }
+
+        mRewardVideoAd?.load()
+        LogUtils.e("DFDFDF=onRewardedVideoAdPlayStart${p0.toString()}")
+    }
+
+    override fun onRewardedVideoAdPlayEnd(p0: ATAdInfo?) {
+        LogUtils.e("DFDFDF=onRewardedVideoAdPlayEnd${p0.toString()}")
+        isRewardedVideoFinish = true
+    }
+
+    override fun onRewardedVideoAdPlayFailed(p0: AdError?, p1: ATAdInfo?) {
+        LogUtils.e("DFDFDF=onRewardedVideoAdPlayFailed${p0?.code}===${p1.toString()}")
+    }
+
+    override fun onRewardedVideoAdClosed(p0: ATAdInfo?) {
+        LogUtils.e("DFDFDF=onRewardedVideoAdClosed${p0.toString()}")
+        if (!isRewardedVideoFinish) {
+            ToastUtils.showShort("请观看完广告再关闭!")
+        }
+    }
+
+    override fun onRewardedVideoAdPlayClicked(p0: ATAdInfo?) {
+        LogUtils.e("DFDFDF=onRewardedVideoAdPlayClicked${p0.toString()}")
+    }
+
+    override fun onReward(p0: ATAdInfo?) {
+
+        LogUtils.e("DFDFDF=onReward${p0.toString()}")
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            val current = LocalDateTime.now()
+            val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
+            endAdTime = current.format(formatter)
+        } else {
+            endAdTime = DateTimeUtils.getCurrentDateTime()
+        }
+
+        saveRecord(p0)
+    }
+
+    private fun saveRecord(p0: ATAdInfo?) {
+
+        if (p0 == null) return
+        val map = HashMap<String, Any>()
+        map["adSourceId"] = p0.adsourceId.toInt()
+        map["beginTime"] = startAdTime.toString()
+        map["finishTime"] = endAdTime.toString()
+        map["networkFormId"] = p0.networkFirmId
+        map["networkName"] = p0.networkName
+        map["networkPlacementId"] = p0.networkPlacementId
+        map["nickName"] = UserInfoSpUtils().getNickName()
+        map["placementId"] = p0.placementId
+        map["recordId"] = p0.requestId
+        map["revenue"] = p0.publisherRevenue.toDouble()
+        map["userId"] = UserInfoSpUtils().getUserId()
+        map["ecpm"] = p0.ecpm.toString()
+        map["adSourceIndex"] = p0.adsourceIndex
+        map["adSourceType"] = p0.adSourceAdType
+        map["resultJson"] = p0.toString()
+
+        val body = BaseRetrofit.getRequestBodyByMapToJson(map)
+
+        BaseRetrofit.getInstance().apiService.saveRecord(body).enqueue(object : Callback2<Any>() {
+            override fun success(body: Any?) {
+                addPower()
+                LogUtils.e("dfdfdfdf广告同步成功!")
+            }
+
+            override fun fail(msg: String?) {
+                ToastUtils.showShort(msg)
+            }
+        })
+    }
+
+    private fun loadNativeAd() {
+        if (atNative == null) {
+            atNative = ATNative(context, "b68400acd7390c", object : ATNativeNetworkListener {
+                override fun onNativeAdLoaded() {
+                    val nativeAd: NativeAd? = atNative?.getNativeAd(getATShowConfig())
+                    try {
+                        nativeAd?.renderAdContainer(binding.fragmentDatiContentAd, null)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                }
+
+                override fun onNativeAdLoadFail(adError: AdError) {
+                    LogUtils.e("onNativeAdLoadFail:" + adError.fullErrorInfo)
+                    atNative = null
+                    loadNativeAd()
+                }
+            })
+        }
+        binding.fragmentDatiContentAd.removeAllViews()
+        atNative?.makeAdRequest()
+    }
+
+    private fun loadInterstitial() {
+
+        interstitialAd = ATInterstitial(context, "b68400ac31936e")
+        interstitialAd?.setNativeAdCustomRender { mixNativeAd, atAdInfo ->
+            MediationNativeAdUtil.getViewFromNativeAd(
+                context,
+                mixNativeAd,
+                atAdInfo,
+                true
+            )
+        }
+        interstitialAd?.setAdListener(object : ATInterstitialListener {
+            override fun onInterstitialAdLoaded() {
+                LogUtils.e("==========onInterstitialAdLoaded")
+            }
+
+            override fun onInterstitialAdLoadFail(p0: AdError?) {
+                LogUtils.e("===========onInterstitialAdLoadFail")
+            }
+
+            override fun onInterstitialAdClicked(p0: ATAdInfo?) {
+                LogUtils.e("===========onInterstitialAdClicked")
+            }
+
+            override fun onInterstitialAdShow(p0: ATAdInfo?) {
+                LogUtils.e("=============onInterstitialAdShow")
+            }
+
+            override fun onInterstitialAdClose(p0: ATAdInfo?) {
+                initInAdTime()
+            }
+
+            override fun onInterstitialAdVideoStart(p0: ATAdInfo?) {
+                interstitialAd?.load()
+                LogUtils.e("===========onInterstitialAdVideoStart")
+            }
+
+            override fun onInterstitialAdVideoEnd(p0: ATAdInfo?) {
+                LogUtils.e("==============onInterstitialAdVideoEnd")
+            }
+
+            override fun onInterstitialAdVideoError(p0: AdError?) {
+                LogUtils.e("==========onInterstitialAdVideoError")
+            }
+
+        })
+        interstitialAd?.load()
+
+    }
+
+    private fun loadBannerAd() {
+        val mBannerView = ATBannerView(context)
+        mBannerView.setPlacementId("b68400aba2a385")
+        mBannerView.setShowConfig(getATShowConfig())
+        mBannerView.setBannerAdListener(this)
+        binding.fragmentDatiBanner.removeAllViews()
+        binding.fragmentDatiBanner.addView(mBannerView)
+        mBannerView.loadAd()
+    }
+
+    private fun getATShowConfig(): ATShowConfig {
+        val builder: ATShowConfig.Builder = ATShowConfig.Builder()
+        builder.scenarioId("banner_ad_show_1")
+        builder.showCustomExt("banner_ad_show_custom_ext")
+
+        return builder.build()
+    }
+
+    private fun getATShowConfig1(): ATShowConfig {
+        val builder = ATShowConfig.Builder()
+        builder.scenarioId("interstitial_ad_show_1")
+        builder.showCustomExt("interstitial_ad_show_custom_ext")
+
+        return builder.build()
+    }
+
+    override fun onBannerLoaded() {
+        LogUtils.e("dfdfdf onBannerLoaded")
+    }
+
+    override fun onBannerFailed(p0: AdError?) {
+        LogUtils.e("dfdfdf onBannerFailed")
+    }
+
+    override fun onBannerClicked(p0: ATAdInfo?) {
+        LogUtils.e("dfdfdf onBannerClicked")
+    }
+
+    override fun onBannerShow(p0: ATAdInfo?) {
+        LogUtils.e("dfdfdf onBannerShow")
+    }
+
+    override fun onBannerClose(p0: ATAdInfo?) {
+        LogUtils.e("dfdfdf onBannerClose")
+    }
+
+    override fun onBannerAutoRefreshed(p0: ATAdInfo?) {
+        LogUtils.e("dfdfdf onBannerAutoRefreshed")
+    }
+
+    override fun onBannerAutoRefreshFail(p0: AdError?) {
+        LogUtils.e("dfdfdf onBannerAutoRefreshFail")
     }
 }

+ 9 - 1
app/src/main/java/com/ytpm/hydtw/loading/GlobalLoading.java

@@ -1,12 +1,19 @@
 package com.ytpm.hydtw.loading;
 
+import android.app.Activity;
 import android.content.Context;
 
+import java.util.Timer;
+import java.util.TimerTask;
+
 public class GlobalLoading {
+    private Timer timer = null;
+    private TimerTask task = null;
     private static GlobalLoading instance;
     private LoadingDialog loadingDialog;
 
-    private GlobalLoading() {}
+    private GlobalLoading() {
+    }
 
     public static GlobalLoading getInstance() {
         if (instance == null) {
@@ -21,6 +28,7 @@ public class GlobalLoading {
 
     /**
      * 显示Loading
+     *
      * @param context 上下文
      * @param message 加载信息
      */

+ 1 - 4
app/src/main/java/com/ytpm/hydtw/network/BaseRetrofit.java

@@ -3,8 +3,6 @@ package com.ytpm.hydtw.network;
 import static com.ytpm.hydtw.network.api.api.BASE_URL_V2;
 
 import com.blankj.utilcode.util.LogUtils;
-import com.ytpm.hydtw.application.DatiApplication;
-import com.ytpm.hydtw.loading.GlobalLoading;
 import com.ytpm.hydtw.network.api.MRefrofitInterface;
 
 import org.json.JSONObject;
@@ -47,7 +45,6 @@ public class BaseRetrofit {
 
     private BaseRetrofit() {
 
-
         this.apiService = new Retrofit.Builder()
                 .baseUrl(BASE_URL_V2)
                 .addConverterFactory(GsonConverterFactory.create())
@@ -94,6 +91,7 @@ public class BaseRetrofit {
 
     public static RequestBody getRequestBodyByMapToJson(HashMap<String, Object> hashMap) {
         JSONObject jsonObject = new JSONObject(hashMap);
+        LogUtils.i("BaseRetrofit", jsonObject.toString());
         RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toString());
         return requestBody;
     }
@@ -113,5 +111,4 @@ public class BaseRetrofit {
         return requestBodyMap;
     }
 
-    //todo 缓存
 }

+ 13 - 8
app/src/main/java/com/ytpm/hydtw/network/Callback2.java

@@ -1,5 +1,7 @@
 package com.ytpm.hydtw.network;
 
+import com.blankj.utilcode.util.LogUtils;
+import com.google.gson.Gson;
 import com.ytpm.hydtw.loading.GlobalLoading;
 import com.ytpm.hydtw.network.api.Result;
 
@@ -26,11 +28,16 @@ public abstract class Callback2<T> implements Callback<Result<T>> {
 
     @Override
     public void onResponse(Call<Result<T>> call, Response<Result<T>> response) {
+
+        LogUtils.e("dfdfdf", call.request().url());
+        LogUtils.e("dfdfdf", response.code());
+
         GlobalLoading.getInstance().dismiss();
 
         Result<T> body = response.body();
         if (response.isSuccessful()) {
             if (body != null) {
+                LogUtils.e("dfdfdf response body", new Gson().toJson(response.body().getData()));
                 int code = body.getCode();
                 String reason = body.getMessage();
                 if (code == 200) {
@@ -51,30 +58,28 @@ public abstract class Callback2<T> implements Callback<Result<T>> {
                 msg = "参数错误";
                 break;
             case 403:
-                msg = "禁止访问, 请联系管理猿";
-                break;
-            case 404:
-                msg = "地址未找到, 请联系管理猿";
+                msg = "禁止访问, 请联系管理员";
                 break;
             default:
-                msg = "服务异常, 请联系管理猿";
+                msg = "操作失败,请联系管理员";
         }
         fail(msg);
     }
 
     @Override
     public void onFailure(Call<Result<T>> call, Throwable t) {
+        LogUtils.e("Call onFailure" + t.getMessage() +"||");
         GlobalLoading.getInstance().dismiss();
 
         if (t instanceof HttpError) {
             //用于convert函数直接抛出异常接收
             fail(t.getMessage());
         } else if (t instanceof UnknownHostException) {
-            fail("网络异常");
+            fail("网络异常,请查看手机网络连接");
         } else if (t instanceof ConnectException) {
-            fail("链接异常, 请联系管理猿");
+            fail("网络异常或服务器异常,请查看手机网络连接");
         } else if (t instanceof SocketException) {
-            fail("服务异常, 请联系管理");
+            fail("服务异常, 请联系管理");
         } else if (t instanceof SocketTimeoutException) {
             fail("响应超时");
         } else {

+ 24 - 1
app/src/main/java/com/ytpm/hydtw/network/api/MRefrofitInterface.java

@@ -20,6 +20,28 @@ import retrofit2.http.Query;
  */
 public interface MRefrofitInterface {
 
+
+    //--------------------------dev---------------------------//
+//    @GET("app-service/wx/defaultConfig")
+//    Call<Result<Config>> getConfigs();
+//
+//    @POST("app-service/wx/login")
+//    Call<Result<UserInfo>> login(@Body RequestBody requestBody);
+//
+//    @POST("app-service/question/answerQuestion")
+//    Call<Result<Object>> answerQuestion(@Body RequestBody requestBody);
+//
+//    @GET("app-service/question/list")
+//    Call<Result<List<Question>>> getQuestions();
+//
+//    @GET("app-service/wx/addPower")
+//    Call<Result<Object>> addPower(@Query("userId") String userId);
+//
+//    @POST("app-service/ad/saveRecord")
+//    Call<Result<Object>> saveRecord(@Body RequestBody requestBody);
+
+
+    //--------------------------prod---------------------------//
     @GET("yt-gateway/app-service/wx/defaultConfig")
     Call<Result<Config>> getConfigs();
 
@@ -35,5 +57,6 @@ public interface MRefrofitInterface {
     @GET("yt-gateway/app-service/wx/addPower")
     Call<Result<Object>> addPower(@Query("userId") String userId);
 
-
+    @POST("yt-gateway/app-service/ad/saveRecord")
+    Call<Result<Object>> saveRecord(@Body RequestBody requestBody);
 }

+ 2 - 1
app/src/main/java/com/ytpm/hydtw/network/api/api.java

@@ -6,5 +6,6 @@ package com.ytpm.hydtw.network.api;
  * @date :2025/06/12 10:22
  */
 public class api {
-    public static String BASE_URL_V2 = "http://119.45.71.139/";//测试
+    public static String BASE_URL_V2 = "https://test.book.ytpm.net/";//生产
+//    public static String BASE_URL_V2 = "http://192.168.1.9:25001/";//测试
 }

+ 60 - 0
app/src/main/java/com/ytpm/hydtw/utils/Base64Decoder.kt

@@ -0,0 +1,60 @@
+package com.ytpm.hydtw.utils
+
+import android.util.Base64
+import java.nio.charset.StandardCharsets
+
+/**
+ * Base64 解密工具类
+ */
+object Base64Decoder {
+    /**
+     * 简单 Base64 解密(适用于文本数据)
+     * @param base64String Base64 编码的字符串
+     * @return 解密后的字符串,失败返回空字符串
+     */
+    fun decodeToString(base64String: String): String {
+        return try {
+            // 使用 DEFAULT 模式,支持标准 Base64 字符集和填充符
+            val decodedBytes = Base64.decode(base64String, Base64.DEFAULT)
+            String(decodedBytes, StandardCharsets.UTF_8)
+        } catch (e: Exception) {
+            e.printStackTrace()
+            ""
+        }
+    }
+
+    /**
+     * 解密为字节数组(适用于二进制数据)
+     * @param base64String Base64 编码的字符串
+     * @return 解密后的字节数组,失败返回空数组
+     */
+    fun decodeToBytes(base64String: String): ByteArray {
+        return try {
+            Base64.decode(base64String, Base64.DEFAULT)
+        } catch (e: Exception) {
+            e.printStackTrace()
+            byteArrayOf()
+        }
+    }
+
+    /**
+     * 带填充符的 Base64 解密(某些服务端可能省略填充符)
+     */
+    fun decodeWithPadding(base64String: String): String {
+        // 补全填充符(=)
+        val paddedString = padBase64(base64String)
+        return decodeToString(paddedString)
+    }
+
+    /**
+     * 补全 Base64 填充符
+     */
+    private fun padBase64(base64String: String): String {
+        var result = base64String
+        val missingPadding = 4 - (result.length % 4)
+        if (missingPadding != 4 && missingPadding != 0) {
+            result += "=".repeat(missingPadding)
+        }
+        return result
+    }
+}

+ 61 - 0
app/src/main/java/com/ytpm/hydtw/utils/DateTimeUtils.kt

@@ -0,0 +1,61 @@
+package com.ytpm.hydtw.utils
+
+import org.threeten.bp.LocalDateTime
+import org.threeten.bp.format.DateTimeFormatter
+import org.threeten.bp.ZoneId
+import org.threeten.bp.Instant
+
+/**
+ * Android API < 26 下的时间工具类
+ */
+object DateTimeUtils {
+    // 标准时间格式 yyyy-MM-dd HH:mm:ss
+    private const val STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss"
+
+    /**
+     * 获取当前时间字符串
+     */
+    fun getCurrentDateTime(): String {
+        val now = LocalDateTime.now()
+        val formatter = DateTimeFormatter.ofPattern(STANDARD_FORMAT)
+        return now.format(formatter)
+    }
+
+    /**
+     * 获取指定时区的当前时间
+     */
+    fun getCurrentDateTimeInZone(zoneId: String = "Asia/Shanghai"): String {
+        val now = Instant.now().atZone(ZoneId.of(zoneId))
+        val formatter = DateTimeFormatter.ofPattern(STANDARD_FORMAT)
+        return now.format(formatter)
+    }
+
+    fun getCurrentDateTimeIso(): String? {
+        val instant = Instant.now()
+        val formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME
+        val answerTime = instant.atZone(ZoneId.of("UTC")).format(formatter)
+        return answerTime
+    }
+
+    /**
+     * 时间戳转换为指定格式
+     */
+    fun timestampToFormattedString(timestamp: Long): String {
+        val instant = Instant.ofEpochMilli(timestamp)
+        val localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime()
+        val formatter = DateTimeFormatter.ofPattern(STANDARD_FORMAT)
+        return localDateTime.format(formatter)
+    }
+
+    /**
+     * 解析时间字符串
+     */
+    fun parseDateTime(dateTimeString: String): LocalDateTime? {
+        return try {
+            val formatter = DateTimeFormatter.ofPattern(STANDARD_FORMAT)
+            LocalDateTime.parse(dateTimeString, formatter)
+        } catch (e: Exception) {
+            null
+        }
+    }
+}

+ 120 - 0
app/src/main/java/com/ytpm/hydtw/utils/GameNetworkUtils.kt

@@ -0,0 +1,120 @@
+package com.ytpm.hydtw.utils
+
+import android.content.Context
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities
+import android.net.wifi.WifiManager
+import android.os.Build
+import android.text.format.Formatter
+import java.net.Inet4Address
+import java.net.NetworkInterface
+import java.util.*
+
+class GameNetworkUtils(private val context: Context) {
+
+    /**
+     * 获取当前连接的网络类型
+     */
+    fun getConnectionType(): String {
+        val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            val network = connectivityManager.activeNetwork ?: return "无连接"
+            val capabilities = connectivityManager.getNetworkCapabilities(network) ?: return "无连接"
+
+            when {
+                capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> "Wi-Fi"
+                capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> "移动数据"
+                capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> "以太网"
+                else -> "其他网络"
+            }
+        } else {
+            @Suppress("DEPRECATION")
+            val networkInfo = connectivityManager.activeNetworkInfo
+            networkInfo?.typeName ?: "无连接"
+        }
+    }
+
+    /**
+     * 获取 Wi-Fi 连接的 IP 地址
+     */
+    fun getWifiIpAddress(): String? {
+        val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
+        if (!wifiManager.isWifiEnabled) {
+            return null
+        }
+
+        val ipAddress = wifiManager.connectionInfo.ipAddress
+
+        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+            Formatter.formatIpAddress(ipAddress)
+        } else {
+            String.format(
+                "%d.%d.%d.%d",
+                (ipAddress and 0xff),
+                (ipAddress shr 8 and 0xff),
+                (ipAddress shr 16 and 0xff),
+                (ipAddress shr 24 and 0xff)
+            )
+        }
+    }
+
+    /**
+     * 获取移动数据连接的 IP 地址
+     */
+    fun getMobileIpAddress(): String? {
+        return try {
+            val interfaces = Collections.list(NetworkInterface.getNetworkInterfaces())
+            for (intf in interfaces) {
+                // 查找移动数据接口(通常以 rmnet 或 ppp 开头)
+                if (intf.name.startsWith("rmnet") || intf.name.startsWith("ppp")) {
+                    val addrs = Collections.list(intf.inetAddresses)
+                    for (addr in addrs) {
+                        if (!addr.isLoopbackAddress && addr is Inet4Address) {
+                            return addr.hostAddress
+                        }
+                    }
+                }
+            }
+            null
+        } catch (e: Exception) {
+            e.printStackTrace()
+            null
+        }
+    }
+
+    /**
+     * 获取当前连接的 IP 地址(自动判断网络类型)
+     */
+    fun getCurrentIpAddress(): String? {
+        return when (getConnectionType()) {
+            "Wi-Fi" -> getWifiIpAddress()
+            "移动数据" -> getMobileIpAddress()
+            else -> null
+        }
+    }
+
+    /**
+     * 获取所有网络接口的 IP 地址
+     */
+    fun getAllIpAddresses(): List<String> {
+        val ipAddresses = mutableListOf<String>()
+
+        try {
+            val interfaces = Collections.list(NetworkInterface.getNetworkInterfaces())
+            for (intf in interfaces) {
+                val addrs = Collections.list(intf.inetAddresses)
+                for (addr in addrs) {
+                    if (!addr.isLoopbackAddress) {
+                        val sAddr = addr.hostAddress
+                        ipAddresses.add(sAddr)
+                    }
+                }
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+
+        return ipAddresses
+    }
+}

+ 525 - 0
app/src/main/java/com/ytpm/hydtw/utils/MediationNativeAdUtil.java

@@ -0,0 +1,525 @@
+package com.ytpm.hydtw.utils;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.anythink.core.api.ATAdAppInfo;
+import com.anythink.core.api.ATAdInfo;
+import com.anythink.core.api.ATNativeAdInfo;
+import com.anythink.core.api.ATShakeViewListener;
+import com.anythink.core.api.IATThirdPartyMaterial;
+import com.anythink.nativead.api.ATNativeImageView;
+import com.anythink.nativead.api.ATNativeMaterial;
+import com.anythink.nativead.api.ATNativePrepareExInfo;
+import com.anythink.nativead.api.ATNativePrepareInfo;
+import com.anythink.nativead.unitgroup.api.CustomNativeAd;
+import com.ytpm.hydtw.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MediationNativeAdUtil {
+    private static final String TAG = MediationNativeAdUtil.class.getSimpleName();
+
+    public static View getViewFromNativeAd(Context context, ATNativeAdInfo mixNativeAd, ATAdInfo atAdInfo, boolean isInterstitialAd) {
+        if (mixNativeAd == null || atAdInfo == null) {
+            return null;
+        }
+        View layoutView = LayoutInflater.from(context).inflate(R.layout.layout_native_self_mix, null, false);
+        if (isInterstitialAd) {
+            //注意:当使用插屏混用原生广告时,最底层布局颜色是全透明的,开发者可根据以下配置实现全屏展示和半屏展示
+            setFullScreenLayoutParams(layoutView);
+//            setHalfScreenLayoutParams(layoutView);
+        }
+        //将信息流自渲染素材转换成view的代码
+        ATNativeAdInfo.AdPrepareInfo prepareInfo = bindSelfRenderView(context, mixNativeAd, layoutView);
+        mixNativeAd.prepare(prepareInfo);
+
+        //获取广告控制器,部分广告平台支持:腾讯广告
+//        ATNativeAdInfo.AdController adController = mixNativeAd.getAdController();
+//        adController.setVideoMute(false);
+//        adController.pauseVideo();
+//        adController.resumeVideo();
+
+        Log.d(TAG, "AdSourceAdType: " + atAdInfo.getAdSourceAdType() + " AdSourceCustomExt: " + atAdInfo.getAdSourceCustomExt());
+
+        return layoutView;
+    }
+
+    /**
+     * 设置全屏显示
+     *
+     * @param layoutView 广告布局
+     */
+    private static void setFullScreenLayoutParams(View layoutView) {
+        //插屏混用原生广告时,设置全屏显示
+        layoutView.setBackgroundColor(Color.GRAY);  //广告View设置背景色
+        FrameLayout.LayoutParams layoutViewParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+        layoutViewParams.gravity = Gravity.CENTER;
+        layoutView.setLayoutParams(layoutViewParams);
+    }
+
+    /**
+     * 插屏混用原生广告时,设置半屏显示
+     *
+     * @param layoutView 广告布局
+     */
+    private static void setHalfScreenLayoutParams(View layoutView) {
+        //设置布局背景
+        layoutView.setBackgroundColor(Color.parseColor("#99000000"));
+        //设置布局位置参数
+        FrameLayout.LayoutParams layoutViewParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+        layoutView.setLayoutParams(layoutViewParams);
+        //设置左右间距
+        View adRootLayout = layoutView.findViewById(R.id.rl_ad_root);
+        FrameLayout.LayoutParams rootLayoutParams = (FrameLayout.LayoutParams) adRootLayout.getLayoutParams();
+        int padding = dip2px(layoutView.getContext(), 20f);
+        rootLayoutParams.leftMargin = padding;
+        rootLayoutParams.rightMargin = padding;
+        adRootLayout.setLayoutParams(rootLayoutParams);
+    }
+
+    public static ATNativeAdInfo.AdPrepareInfo bindSelfRenderView(Context context, ATNativeAdInfo mixNativeAd, View selfRenderView) {
+        IATThirdPartyMaterial adMaterial = mixNativeAd.getAdMaterial();
+        ATNativeAdInfo.AdPrepareInfo nativePrepareInfo = new ATNativeAdInfo.AdPrepareInfo();
+        //log
+        printNativeAdMaterial(adMaterial);
+
+        int padding = dip2px(context, 5);
+        selfRenderView.setPadding(padding, padding, padding, padding);
+        TextView titleView = (TextView) selfRenderView.findViewById(R.id.native_ad_title);
+        TextView descView = (TextView) selfRenderView.findViewById(R.id.native_ad_desc);
+        TextView ctaView = (TextView) selfRenderView.findViewById(R.id.native_ad_install_btn);
+        TextView adFromView = (TextView) selfRenderView.findViewById(R.id.native_ad_from);
+        FrameLayout iconArea = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_image);
+        FrameLayout contentArea = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_content_image_area);
+        final ATNativeImageView logoView = (ATNativeImageView) selfRenderView.findViewById(R.id.native_ad_logo);
+        View closeView = selfRenderView.findViewById(R.id.native_ad_close);
+        FrameLayout shakeViewContainer = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_shake_view_container);
+        FrameLayout slideViewContainer = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_slide_view_container);
+        FrameLayout adLogoContainer = selfRenderView.findViewById(R.id.native_ad_logo_container);   //v6.1.52+
+
+        // bind view
+        List<View> clickViewList = new ArrayList<>();//click views
+
+        String title = adMaterial.getTitle();
+        // title
+        if (!TextUtils.isEmpty(title)) {
+            titleView.setText(title);
+            nativePrepareInfo.setTitleView(titleView);//bind title
+            clickViewList.add(titleView);
+            titleView.setVisibility(View.VISIBLE);
+        } else {
+            titleView.setVisibility(View.GONE);
+        }
+
+
+        String descriptionText = adMaterial.getDescriptionText();
+        if (!TextUtils.isEmpty(descriptionText)) {
+            // desc
+            descView.setText(descriptionText);
+            nativePrepareInfo.setDescView(descView);//bind desc
+            clickViewList.add(descView);
+            descView.setVisibility(View.VISIBLE);
+        } else {
+            descView.setVisibility(View.GONE);
+        }
+
+        // icon
+        View adIconView = adMaterial.getAdIconView();
+        String iconImageUrl = adMaterial.getIconImageUrl();
+        iconArea.removeAllViews();
+        final ATNativeImageView iconView = new ATNativeImageView(context);
+        if (adIconView != null) {
+            iconArea.addView(adIconView);
+            nativePrepareInfo.setIconView(adIconView);//bind icon
+            clickViewList.add(adIconView);
+            iconArea.setVisibility(View.VISIBLE);
+        } else if (!TextUtils.isEmpty(iconImageUrl)) {
+            iconArea.addView(iconView);
+            iconView.setImage(iconImageUrl);
+            nativePrepareInfo.setIconView(iconView);//bind icon
+            clickViewList.add(iconView);
+            iconArea.setVisibility(View.VISIBLE);
+        } else {
+            iconArea.setVisibility(View.INVISIBLE);
+        }
+
+        // cta button
+        String callToActionText = adMaterial.getCallToActionText();
+        if (!TextUtils.isEmpty(callToActionText)) {
+            ctaView.setText(callToActionText);
+            nativePrepareInfo.setCtaView(ctaView);//bind cta button
+            clickViewList.add(ctaView);
+            ctaView.setVisibility(View.VISIBLE);
+        } else {
+            ctaView.setVisibility(View.GONE);
+        }
+
+        // AppDownloadButton(Only Huawei Ads support)
+        //View lastView = ((ViewGroup) selfRenderView).getChildAt(((ViewGroup) selfRenderView).getChildCount() - 1);
+        // Remove AppDownloadButton since last time added
+        //if (lastView instanceof AppDownloadButton) {
+        //    ((ViewGroup) selfRenderView).removeView(lastView);
+        //}
+        //View appDownloadButton = adMaterial.getAppDownloadButton();
+        //if (appDownloadButton != null) {
+        //    if (appDownloadButton instanceof AppDownloadButton) {
+        //        ((AppDownloadButton) appDownloadButton).setTextSize(dip2px(context, 12));
+        //    }
+        //    ViewGroup.LayoutParams ctaParams = ctaView.getLayoutParams();
+        //    ((ViewGroup) selfRenderView).addView(appDownloadButton, ctaParams);
+        //    appDownloadButton.setVisibility(View.VISIBLE);
+        //    ctaView.setVisibility(View.INVISIBLE);
+        //}
+
+        // media view
+        View mediaView = adMaterial.getAdMediaView(contentArea);
+        int mainImageHeight = adMaterial.getMainImageHeight();
+        int mainImageWidth = adMaterial.getMainImageWidth();
+        FrameLayout.LayoutParams mainImageParam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT
+                , FrameLayout.LayoutParams.WRAP_CONTENT);
+        if (mediaView == null) {
+            ViewTreeObserver viewTreeObserver = selfRenderView.getViewTreeObserver();
+            viewTreeObserver.addOnGlobalLayoutListener(
+                    new ViewTreeObserver.OnGlobalLayoutListener() {
+                        @Override
+                        public void onGlobalLayout() {
+                            // 移除监听器
+                            selfRenderView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+
+                            int realMainImageWidth = selfRenderView.getWidth() - dip2px(context,
+                                    10);
+                            int realMainHeight = 0;
+
+                            if (mainImageWidth > 0 && mainImageHeight > 0 && mainImageWidth > mainImageHeight) {
+                                realMainHeight = realMainImageWidth * mainImageHeight / mainImageWidth;
+                                mainImageParam.width = realMainImageWidth;
+                                mainImageParam.height = realMainHeight;
+                            } else {
+                                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+                                mainImageParam.height = realMainImageWidth * 600 / 1024;
+                            }
+                        }
+                    });
+        } else {
+            int realMainImageWidth = context.getResources()
+                    .getDisplayMetrics().widthPixels - dip2px(context, 10);
+            if (context.getResources().getDisplayMetrics().widthPixels > context.getResources()
+                    .getDisplayMetrics().heightPixels) {//Horizontal screen
+                realMainImageWidth = context.getResources()
+                        .getDisplayMetrics().widthPixels - dip2px(context, 10) - dip2px(context,
+                        330) - dip2px(context, 130);
+            }
+            if (mainImageWidth > 0 && mainImageHeight > 0 && mainImageWidth > mainImageHeight) {
+                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+                mainImageParam.height = realMainImageWidth * mainImageHeight / mainImageWidth;
+            } else {
+                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+                mainImageParam.height = realMainImageWidth * 600 / 1024;
+            }
+        }
+
+        List<String> imageList = adMaterial.getImageUrlList();
+
+        contentArea.removeAllViews();
+        if (mediaView != null) {
+            if (mediaView.getParent() != null) {
+                ((ViewGroup) mediaView.getParent()).removeView(mediaView);
+            }
+            mainImageParam.gravity = Gravity.CENTER;
+            mediaView.setLayoutParams(mainImageParam);
+            contentArea.addView(mediaView, mainImageParam);
+            //clickViewList.add(mediaView);
+            contentArea.setVisibility(View.VISIBLE);
+        } else if (imageList != null && imageList.size() > 1) {
+            MutiImageView mutiImageView = new MutiImageView(context);
+            mutiImageView.setImageList(imageList, mainImageWidth, mainImageHeight);
+            nativePrepareInfo.setMainImageView(mutiImageView);//bind main image
+            contentArea.addView(mutiImageView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+            clickViewList.add(mutiImageView);
+        } else if (!TextUtils.isEmpty(adMaterial.getMainImageUrl())) {
+            ATNativeImageView imageView = new ATNativeImageView(context);
+            imageView.setImage(adMaterial.getMainImageUrl());
+            imageView.setLayoutParams(mainImageParam);
+            contentArea.addView(imageView, mainImageParam);
+
+            nativePrepareInfo.setMainImageView(imageView);//bind main image
+            clickViewList.add(imageView);
+            contentArea.setVisibility(View.VISIBLE);
+        } else {
+            contentArea.removeAllViews();
+            contentArea.setVisibility(View.GONE);
+        }
+
+
+        //Ad Logo
+        View adLogoView = adMaterial.getAdLogoView();
+        if (adLogoView != null) {
+            adLogoContainer.setVisibility(View.VISIBLE);
+            adLogoContainer.removeAllViews();
+            adLogoContainer.addView(adLogoView);
+        } else {
+            adLogoContainer.setVisibility(View.GONE);
+
+            String adChoiceIconUrl = adMaterial.getAdChoiceIconUrl();
+            Bitmap adLogoBitmap = adMaterial.getAdLogo();
+            if (!TextUtils.isEmpty(adChoiceIconUrl)) {
+                logoView.setImage(adChoiceIconUrl);
+                nativePrepareInfo.setAdLogoView(logoView);//bind ad choice
+                logoView.setVisibility(View.VISIBLE);
+            } else if (adLogoBitmap != null) {
+                logoView.setImageBitmap(adLogoBitmap);
+                logoView.setVisibility(View.VISIBLE);
+            } else {
+                logoView.setImageBitmap(null);
+                logoView.setVisibility(View.GONE);
+            }
+        }
+
+        String adFrom = adMaterial.getAdFrom();
+
+        // ad from
+        if (!TextUtils.isEmpty(adFrom)) {
+            adFromView.setText(adFrom);
+            adFromView.setVisibility(View.VISIBLE);
+        } else {
+            adFromView.setVisibility(View.GONE);
+        }
+        nativePrepareInfo.setAdFromView(adFromView);//bind ad from
+
+        //渲染摇一摇组件,若广告不支持摇一摇能力则返回null,目前只有百度广告平台支持
+        renderShakeView(context, adMaterial, shakeViewContainer);
+        //渲染滑一滑组件,若广告不支持则返回null,滑动区域受容器大小控制,目前只有百度广告平台支持
+        renderSlideView(context, adMaterial, slideViewContainer);
+
+        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(dip2px(context, 40), dip2px(context, 10));//ad choice
+        layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
+        nativePrepareInfo.setChoiceViewLayoutParams(layoutParams);//bind layout params for ad choice
+
+        //关闭按钮渲染方式有两种:
+        // 1.开发者自渲染,通过AdPrepareInfo的setCloseView()方法设置;
+        // 2.如果没有设置AdPrepareInfo的setCloseView(),则Taku SDK默认会在布局右上角添加关闭按钮。
+        boolean closeBtnCustomRender = false;
+        if (closeBtnCustomRender) {
+            //方式1,通过AdPrepareInfo的setCloseView()设置关闭按钮
+            nativePrepareInfo.setCloseView(closeView);//bind close button
+        } else {
+            //方式2,隐藏布局的关闭按钮,不通过AdPrepareInfo的setCloseView()设置关闭按钮
+            closeView.setVisibility(View.GONE);
+        }
+
+        nativePrepareInfo.setClickViewList(clickViewList);//bind click view list
+
+        //if (nativePrepareInfo instanceof ATNativePrepareExInfo) {
+        //    List<View> creativeClickViewList = new ArrayList<>();//click views
+        //    creativeClickViewList.add(ctaView);
+        //    ((ATNativePrepareExInfo) nativePrepareInfo).setCreativeClickViewList(creativeClickViewList);//bind custom view list
+        //}
+
+        View sixInfoView = selfRenderView.findViewById(R.id.six_info);
+        ATAdAppInfo adAppInfo = adMaterial.getAdAppInfo();
+        if (adAppInfo != null) {
+            sixInfoView.setVisibility(View.VISIBLE);
+            TextView functionTextView = sixInfoView.findViewById(R.id.function_test);
+            TextView developerTextView = sixInfoView.findViewById(R.id.developer_test);
+            TextView versionTextView = sixInfoView.findViewById(R.id.version_test);
+            TextView privacyTextView = sixInfoView.findViewById(R.id.privacy_test);
+            TextView permissionTextView = sixInfoView.findViewById(R.id.permission_test);
+
+            List<View> appInfoClickViewList = new ArrayList<>();
+            List<View> privacyClickViewList = new ArrayList<>();
+            List<View> permissionClickViewList = new ArrayList<>();
+
+            developerTextView.setText(
+                    TextUtils.isEmpty(adAppInfo.getPublisher()) ? "" : adAppInfo.getPublisher());
+            versionTextView.setText(
+                    TextUtils.isEmpty(adAppInfo.getAppVersion()) ? "" : adAppInfo.getAppVersion());
+            appInfoClickViewList.add(developerTextView);
+            appInfoClickViewList.add(versionTextView);
+
+            if (!TextUtils.isEmpty(adAppInfo.getFunctionUrl())) {
+                functionTextView.setVisibility(View.VISIBLE);
+                appInfoClickViewList.add(functionTextView);
+                setOpenUrlClickListener(functionTextView, adAppInfo.getFunctionUrl());
+            } else {
+                functionTextView.setOnClickListener(null);
+                functionTextView.setVisibility(View.GONE);
+            }
+
+            if (!TextUtils.isEmpty(adAppInfo.getAppPrivacyUrl())) {
+                privacyTextView.setVisibility(View.VISIBLE);
+                privacyClickViewList.add(privacyTextView);
+                setOpenUrlClickListener(privacyTextView, adAppInfo.getAppPrivacyUrl());
+            } else {
+                privacyTextView.setVisibility(View.GONE);
+                privacyTextView.setOnClickListener(null);
+            }
+
+            if (!TextUtils.isEmpty(adAppInfo.getAppPermissonUrl())) {
+                permissionTextView.setVisibility(View.VISIBLE);
+                permissionClickViewList.add(permissionTextView);
+                setOpenUrlClickListener(permissionTextView, adAppInfo.getAppPermissonUrl());
+            } else {
+                permissionTextView.setVisibility(View.GONE);
+                permissionTextView.setOnClickListener(null);
+            }
+
+            nativePrepareInfo.setAppInfoClickViewList(appInfoClickViewList);
+            nativePrepareInfo.setPermissionClickViewList(permissionClickViewList);
+            nativePrepareInfo.setPrivacyClickViewList(privacyClickViewList);
+        } else {
+            sixInfoView.setVisibility(View.GONE);
+        }
+        return nativePrepareInfo;
+    }
+
+    private static void renderShakeView(Context context, IATThirdPartyMaterial adMaterial, FrameLayout shakeViewContainer) {
+        int shakeViewWidth = dip2px(context, 100);  //组件的宽,不小于80dp
+        int shakeViewHeight = dip2px(context, 100); //组件的高,不小于80dp
+        View shakeView = adMaterial.getShakeView(shakeViewWidth, shakeViewHeight, new ATShakeViewListener() {
+            @Override
+            public void onDismiss() {
+                shakeViewContainer.setVisibility(View.GONE);
+            }
+        });
+        if (shakeView != null && shakeViewContainer != null) {
+            shakeViewContainer.setVisibility(View.VISIBLE);
+            shakeViewContainer.removeAllViews();
+            FrameLayout.LayoutParams shakeViewLayoutParams = new FrameLayout.LayoutParams(shakeViewWidth, shakeViewHeight);
+            shakeViewLayoutParams.gravity = Gravity.CENTER;
+            shakeViewContainer.addView(shakeView, shakeViewLayoutParams);
+        }
+    }
+
+    private static void renderSlideView(Context context, IATThirdPartyMaterial adMaterial, FrameLayout slideViewContainer) {
+        int slideViewWidth = dip2px(context, 120);  //滑动引导区域的宽
+        int slideViewHeight = dip2px(context, 50); // 滑动引导区域的高
+        int repeat = 5; //动画的重复次数,结束后自动隐藏组件
+        View slideView = adMaterial.getSlideView(slideViewWidth, slideViewHeight, repeat, new ATShakeViewListener() {
+            @Override
+            public void onDismiss() {
+                slideViewContainer.setVisibility(View.GONE);
+            }
+        });
+        if (slideView != null && slideViewContainer != null) {
+            slideViewContainer.setVisibility(View.VISIBLE);
+            slideViewContainer.removeAllViews();
+            FrameLayout.LayoutParams slideViewLayoutParams = new FrameLayout.LayoutParams(slideViewWidth, slideViewHeight + dip2px(context, 50));
+            slideViewLayoutParams.gravity = Gravity.CENTER;
+            slideViewContainer.addView(slideView, slideViewLayoutParams);
+        }
+    }
+
+    private static void setOpenUrlClickListener(View view, final String url) {
+        view.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                try {
+                    Intent intent = new Intent(Intent.ACTION_VIEW,
+                            Uri.parse(url));
+                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
+                            | Intent.FLAG_ACTIVITY_NEW_TASK);
+                    Context context = view.getContext();
+                    if (context != null) {
+                        context.startActivity(intent);
+                    }
+                } catch (Throwable e2) {
+                    e2.printStackTrace();
+                }
+            }
+        });
+
+    }
+
+//    private static View initializePlayer(Context context, String url) {
+//        VideoView videoView = new VideoView(context);
+//        videoView.setVideoURI(Uri.parse(url));
+//        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+//            @Override
+//            public void onPrepared(MediaPlayer mediaPlayer) {
+//            }
+//        });
+//        videoView.start();
+//
+//        return videoView;
+//    }
+
+    public static int dip2px(Context context, float dipValue) {
+        float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (dipValue * scale + 0.5f);
+    }
+
+    private static void printNativeAdMaterial(IATThirdPartyMaterial adMaterial) {
+        if (adMaterial == null) return;
+
+        String adType = adMaterial.getAdType();
+        switch (adType) {
+            case CustomNativeAd.NativeAdConst.VIDEO_TYPE:
+                Log.i(TAG, "Ad source type: Video" + ", video duration: " + adMaterial.getVideoDuration());
+                break;
+            case CustomNativeAd.NativeAdConst.IMAGE_TYPE:
+                Log.i(TAG, "Ad source type: Image");
+                break;
+            default:
+                Log.i(TAG, "Ad source type: Unknown");
+                break;
+        }
+        switch (adMaterial.getNativeType()) {
+            case CustomNativeAd.NativeType.FEED:
+                Log.i(TAG, "Native type: Feed");
+                break;
+            case CustomNativeAd.NativeType.PATCH:
+                Log.i(TAG, "Native type: Patch");
+                break;
+        }
+
+        Log.i(TAG, "show native material:" + "\n" +
+                "adMaterial: " + adMaterial + "\n" +
+                "getTitle:" + adMaterial.getTitle() + "\n" +
+                "getDescriptionText:" + adMaterial.getDescriptionText() + "\n" +
+                "getNativeType:" + adMaterial.getNativeType() + "\n" +
+                "getAdMediaView:" + adMaterial.getAdMediaView() + "\n" +
+                "getAdIconView:" + adMaterial.getAdIconView() + "\n" +
+                "getIconImageUrl:" + adMaterial.getIconImageUrl() + "\n" +
+                "getMainImageUrl:" + adMaterial.getMainImageUrl() + "\n" +
+                "getMainImageWidth:" + adMaterial.getMainImageWidth() + "\n" +
+                "getMainImageHeight:" + adMaterial.getMainImageHeight() + "\n" +
+                "getVideoWidth:" + adMaterial.getVideoWidth() + "\n" +
+                "getVideoHeight:" + adMaterial.getVideoHeight() + "\n" +
+                "getAppPrice:" + adMaterial.getAppPrice() + "\n" +
+                "getAppCommentNum:" + adMaterial.getAppCommentNum() + "\n" +
+                "getCallToActionText:" + adMaterial.getCallToActionText() + "\n" +
+                "getStarRating:" + adMaterial.getStarRating() + "\n" +
+                "getVideoUrl:" + adMaterial.getVideoUrl() + "\n" +
+                "getAdChoiceIconUrl:" + adMaterial.getAdChoiceIconUrl() + "\n" +
+                "getAdFrom:" + adMaterial.getAdFrom() + "\n" +
+                "getImageUrlList:" + adMaterial.getImageUrlList() + "\n" +
+                "getNetworkInfoMap:" + adMaterial.getNetworkInfoMap() + "\n" +
+                "getAdAppInfo:" + adMaterial.getAdAppInfo() + "\n" +
+                "getNativeAdInteractionType:" + (adMaterial.getNativeAdInteractionType()) + "\n" +
+                "getVideoDuration:" + adMaterial.getVideoDuration() + "\n" +
+                "getAdvertiserName:" + adMaterial.getAdvertiserName() + "\n" +
+                "getNativeType:" + adMaterial.getNativeType() + "\n" +
+                "getAdType:" + adMaterial.getAdType() + "\n" +
+                "getNativeCustomVideo:" + adMaterial.getNativeCustomVideo() + "\n" +
+                "getAdLogo:" + adMaterial.getAdLogo() + "\n" +
+                "getNativeExpressWidth:" + adMaterial.getNativeExpressWidth() + "\n" +
+                "getNativeExpressHeight" + adMaterial.getNativeExpressHeight() + "\n"
+        );
+    }
+}

+ 39 - 0
app/src/main/java/com/ytpm/hydtw/utils/MutiImageView.java

@@ -0,0 +1,39 @@
+package com.ytpm.hydtw.utils;
+
+import android.content.Context;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+
+import com.anythink.nativead.api.ATNativeImageView;
+
+import java.util.List;
+
+public class MutiImageView extends LinearLayout {
+    int padding;
+
+    public MutiImageView(Context context) {
+        super(context);
+        setOrientation(HORIZONTAL);
+        padding = SelfRenderViewUtil.dip2px(context, 5);
+//        setPadding(padding, padding, padding, padding);
+    }
+
+    public void setImageList(List<String> imageList, int imageWidth, int imageHeight) {
+        removeAllViews();
+        int size = imageList.size();
+        for (String url : imageList) {
+            int width = getResources().getDisplayMetrics().widthPixels;
+
+            ATNativeImageView atNativeImageView = new ATNativeImageView(getContext());
+            atNativeImageView.setImage(url);
+            atNativeImageView.setPadding(padding, padding, padding, padding);
+            LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, width * 600 / size / 1024);
+            if (imageWidth > 0 && imageHeight > 0) {
+                layoutParams.height = width * imageHeight / size / imageWidth;
+            }
+            layoutParams.weight = 1;
+
+            addView(atNativeImageView, layoutParams);
+        }
+    }
+}

+ 459 - 0
app/src/main/java/com/ytpm/hydtw/utils/SelfRenderViewUtil.java

@@ -0,0 +1,459 @@
+package com.ytpm.hydtw.utils;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+import com.anythink.core.api.ATAdAppInfo;
+import com.anythink.core.api.ATShakeViewListener;
+import com.anythink.nativead.api.ATNativeImageView;
+import com.anythink.nativead.api.ATNativeMaterial;
+import com.anythink.nativead.api.ATNativePrepareExInfo;
+import com.anythink.nativead.api.ATNativePrepareInfo;
+import com.anythink.nativead.unitgroup.api.CustomNativeAd;
+import com.ytpm.hydtw.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SelfRenderViewUtil {
+    private static final String TAG = SelfRenderViewUtil.class.getSimpleName();
+
+//    public static void bindSelfRenderView(Context context, ATNativeMaterial adMaterial, View selfRenderView, ATNativePrepareInfo nativePrepareInfo) {
+//        //log
+//        printNativeAdMaterial(adMaterial);
+//
+//        int padding = dip2px(context, 5);
+//        selfRenderView.setPadding(padding, padding, padding, padding);
+//        TextView titleView = (TextView) selfRenderView.findViewById(R.id.native_ad_title);
+//        TextView descView = (TextView) selfRenderView.findViewById(R.id.native_ad_desc);
+//        TextView ctaView = (TextView) selfRenderView.findViewById(R.id.native_ad_install_btn);
+//        TextView adFromView = (TextView) selfRenderView.findViewById(R.id.native_ad_from);
+//        FrameLayout iconArea = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_image);
+//        FrameLayout contentArea = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_content_image_area);
+//        final ATNativeImageView logoView = (ATNativeImageView) selfRenderView.findViewById(R.id.native_ad_logo);
+//        View closeView = selfRenderView.findViewById(R.id.native_ad_close);
+//        FrameLayout shakeViewContainer = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_shake_view_container);
+//        FrameLayout slideViewContainer = (FrameLayout) selfRenderView.findViewById(R.id.native_ad_slide_view_container);
+//        FrameLayout adLogoContainer = selfRenderView.findViewById(R.id.native_ad_logo_container);   //v6.1.52+
+//
+//        // bind view
+//        if (nativePrepareInfo == null) {
+//            nativePrepareInfo = new ATNativePrepareInfo();
+//        }
+//        List<View> clickViewList = new ArrayList<>();//click views
+//
+//
+//        String title = adMaterial.getTitle();
+//        // title
+//        if (!TextUtils.isEmpty(title)) {
+//            titleView.setText(title);
+//            nativePrepareInfo.setTitleView(titleView);//bind title
+//            clickViewList.add(titleView);
+//            titleView.setVisibility(View.VISIBLE);
+//        } else {
+//            titleView.setVisibility(View.GONE);
+//        }
+//
+//
+//        String descriptionText = adMaterial.getDescriptionText();
+//        if (!TextUtils.isEmpty(descriptionText)) {
+//            // desc
+//            descView.setText(descriptionText);
+//            nativePrepareInfo.setDescView(descView);//bind desc
+//            clickViewList.add(descView);
+//            descView.setVisibility(View.VISIBLE);
+//        } else {
+//            descView.setVisibility(View.GONE);
+//        }
+//
+//        // icon
+//        View adIconView = adMaterial.getAdIconView();
+//        String iconImageUrl = adMaterial.getIconImageUrl();
+//        iconArea.removeAllViews();
+//        final ATNativeImageView iconView = new ATNativeImageView(context);
+//        if (adIconView != null) {
+//            iconArea.addView(adIconView);
+//            nativePrepareInfo.setIconView(adIconView);//bind icon
+//            clickViewList.add(adIconView);
+//            iconArea.setVisibility(View.VISIBLE);
+//        } else if (!TextUtils.isEmpty(iconImageUrl)) {
+//            iconArea.addView(iconView);
+//            iconView.setImage(iconImageUrl);
+//            nativePrepareInfo.setIconView(iconView);//bind icon
+//            clickViewList.add(iconView);
+//            iconArea.setVisibility(View.VISIBLE);
+//        } else {
+//            iconArea.setVisibility(View.INVISIBLE);
+//        }
+//
+//        // cta button
+//        String callToActionText = adMaterial.getCallToActionText();
+//        if (!TextUtils.isEmpty(callToActionText)) {
+//            ctaView.setText(callToActionText);
+//            nativePrepareInfo.setCtaView(ctaView);//bind cta button
+//            clickViewList.add(ctaView);
+//            ctaView.setVisibility(View.VISIBLE);
+//        } else {
+//            ctaView.setVisibility(View.GONE);
+//        }
+//
+//        // AppDownloadButton(Only Huawei Ads support)
+//        //View lastView = ((ViewGroup) selfRenderView).getChildAt(((ViewGroup) selfRenderView).getChildCount() - 1);
+//        // Remove AppDownloadButton since last time added
+//        //if (lastView instanceof AppDownloadButton) {
+//        //    ((ViewGroup) selfRenderView).removeView(lastView);
+//        //}
+//        //View appDownloadButton = adMaterial.getAppDownloadButton();
+//        //if (appDownloadButton != null) {
+//        //    if (appDownloadButton instanceof AppDownloadButton) {
+//        //        ((AppDownloadButton) appDownloadButton).setTextSize(dip2px(context, 12));
+//        //        appDownloadButton.setPadding(dip2px(context, 46),dip2px(context, 24),dip2px(context, 46),dip2px(context, 24));
+//        //    }
+//        //    ViewGroup.LayoutParams ctaParams = ctaView.getLayoutParams();
+//        //    ((ViewGroup) selfRenderView).addView(appDownloadButton, ctaParams);
+//        //    appDownloadButton.setVisibility(View.VISIBLE);
+//        //    ctaView.setVisibility(View.INVISIBLE);
+//        //}
+//
+//        // media view
+//        View mediaView = adMaterial.getAdMediaView(contentArea);
+//        int mainImageHeight = adMaterial.getMainImageHeight();
+//        int mainImageWidth = adMaterial.getMainImageWidth();
+//        FrameLayout.LayoutParams mainImageParam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT
+//                , FrameLayout.LayoutParams.WRAP_CONTENT);
+//        if (mediaView == null) {
+//            ViewTreeObserver viewTreeObserver = selfRenderView.getViewTreeObserver();
+//            viewTreeObserver.addOnGlobalLayoutListener(
+//                    new ViewTreeObserver.OnGlobalLayoutListener() {
+//                        @Override
+//                        public void onGlobalLayout() {
+//                            // 移除监听器
+//                            selfRenderView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+//
+//                            int realMainImageWidth = selfRenderView.getWidth() - dip2px(context,
+//                                    10);
+//                            int realMainHeight = 0;
+//
+//                            if (mainImageWidth > 0 && mainImageHeight > 0 && mainImageWidth > mainImageHeight) {
+//                                realMainHeight = realMainImageWidth * mainImageHeight / mainImageWidth;
+//                                mainImageParam.width = realMainImageWidth;
+//                                mainImageParam.height = realMainHeight;
+//                            } else {
+//                                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+//                                mainImageParam.height = realMainImageWidth * 600 / 1024;
+//                            }
+//                        }
+//                    });
+//        } else {
+//            int realMainImageWidth = context.getResources()
+//                    .getDisplayMetrics().widthPixels - dip2px(context, 10);
+//            if (context.getResources().getDisplayMetrics().widthPixels > context.getResources()
+//                    .getDisplayMetrics().heightPixels) {//Horizontal screen
+//                realMainImageWidth = context.getResources()
+//                        .getDisplayMetrics().widthPixels - dip2px(context, 10) - dip2px(context,
+//                        330) - dip2px(context, 130);
+//            }
+//            if (mainImageWidth > 0 && mainImageHeight > 0 && mainImageWidth > mainImageHeight) {
+//                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+//                mainImageParam.height = realMainImageWidth * mainImageHeight / mainImageWidth;
+//            } else {
+//                mainImageParam.width = FrameLayout.LayoutParams.MATCH_PARENT;
+//                mainImageParam.height = realMainImageWidth * 600 / 1024;
+//            }
+//        }
+//
+//        List<String> imageList = adMaterial.getImageUrlList();
+//
+//        contentArea.removeAllViews();
+//        if (mediaView != null) {
+//            if (mediaView.getParent() != null) {
+//                ((ViewGroup) mediaView.getParent()).removeView(mediaView);
+//            }
+//            mainImageParam.gravity = Gravity.CENTER;
+//            mediaView.setLayoutParams(mainImageParam);
+//            contentArea.addView(mediaView, mainImageParam);
+//            //clickViewList.add(mediaView);
+//            contentArea.setVisibility(View.VISIBLE);
+//        } else if (imageList != null && imageList.size() > 1) {
+//            MutiImageView mutiImageView = new MutiImageView(context);
+//            mutiImageView.setImageList(imageList, mainImageWidth, mainImageHeight);
+//            nativePrepareInfo.setMainImageView(mutiImageView);//bind main image
+//            contentArea.addView(mutiImageView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+//            clickViewList.add(mutiImageView);
+//        } else if (!TextUtils.isEmpty(adMaterial.getMainImageUrl())) {
+//            ATNativeImageView imageView = new ATNativeImageView(context);
+//            imageView.setImage(adMaterial.getMainImageUrl());
+//            imageView.setLayoutParams(mainImageParam);
+//            contentArea.addView(imageView, mainImageParam);
+//
+//            nativePrepareInfo.setMainImageView(imageView);//bind main image
+//            clickViewList.add(imageView);
+//            contentArea.setVisibility(View.VISIBLE);
+//        } else {
+//            contentArea.removeAllViews();
+//            contentArea.setVisibility(View.GONE);
+//        }
+//
+//
+//        //Ad Logo
+//        View adLogoView = adMaterial.getAdLogoView();
+//        if (adLogoView != null) {
+//            adLogoContainer.setVisibility(View.VISIBLE);
+//            adLogoContainer.removeAllViews();
+//            adLogoContainer.addView(adLogoView);
+//        } else {
+//            adLogoContainer.setVisibility(View.GONE);
+//
+//            String adChoiceIconUrl = adMaterial.getAdChoiceIconUrl();
+//            Bitmap adLogoBitmap = adMaterial.getAdLogo();
+//            if (!TextUtils.isEmpty(adChoiceIconUrl)) {
+//                logoView.setImage(adChoiceIconUrl);
+//                nativePrepareInfo.setAdLogoView(logoView);//bind ad choice
+//                logoView.setVisibility(View.VISIBLE);
+//            } else if (adLogoBitmap != null) {
+//                logoView.setImageBitmap(adLogoBitmap);
+//                logoView.setVisibility(View.VISIBLE);
+//            } else {
+//                logoView.setImageBitmap(null);
+//                logoView.setVisibility(View.GONE);
+//            }
+//        }
+//
+//        String adFrom = adMaterial.getAdFrom();
+//
+//        // ad from
+//        if (!TextUtils.isEmpty(adFrom)) {
+//            adFromView.setText(adFrom);
+//            adFromView.setVisibility(View.VISIBLE);
+//        } else {
+//            adFromView.setVisibility(View.GONE);
+//        }
+//        nativePrepareInfo.setAdFromView(adFromView);//bind ad from
+//
+//        //渲染摇一摇组件,若广告不支持摇一摇能力则返回null,目前只有百度广告平台支持
+//        renderShakeView(context, adMaterial, shakeViewContainer);
+//        //渲染滑一滑组件,若广告不支持则返回null,滑动区域受容器大小控制,目前只有百度广告平台支持
+//        renderSlideView(context, adMaterial, slideViewContainer);
+//
+//        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(dip2px(context, 40), dip2px(context, 10));//ad choice
+//        layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
+//        nativePrepareInfo.setChoiceViewLayoutParams(layoutParams);//bind layout params for ad choice
+//        nativePrepareInfo.setCloseView(closeView);//bind close button
+//
+//        nativePrepareInfo.setClickViewList(clickViewList);//bind click view list
+//
+//        //if (nativePrepareInfo instanceof ATNativePrepareExInfo) {
+//        //    List<View> creativeClickViewList = new ArrayList<>();//click views
+//        //    creativeClickViewList.add(ctaView);
+//        //    ((ATNativePrepareExInfo) nativePrepareInfo).setCreativeClickViewList(creativeClickViewList);//bind custom view list
+//        //}
+//
+//        View sixInfoView = selfRenderView.findViewById(R.id.six_info);
+//        ATAdAppInfo adAppInfo = adMaterial.getAdAppInfo();
+//        if (adAppInfo != null) {
+//            sixInfoView.setVisibility(View.VISIBLE);
+//            TextView functionTextView = sixInfoView.findViewById(R.id.function_test);
+//            TextView developerTextView = sixInfoView.findViewById(R.id.developer_test);
+//            TextView versionTextView = sixInfoView.findViewById(R.id.version_test);
+//            TextView privacyTextView = sixInfoView.findViewById(R.id.privacy_test);
+//            TextView permissionTextView = sixInfoView.findViewById(R.id.permission_test);
+//
+//            List<View> appInfoClickViewList = new ArrayList<>();
+//            List<View> privacyClickViewList = new ArrayList<>();
+//            List<View> permissionClickViewList = new ArrayList<>();
+//
+//            developerTextView.setText(
+//                    TextUtils.isEmpty(adAppInfo.getPublisher()) ? "" : adAppInfo.getPublisher());
+//            versionTextView.setText(
+//                    TextUtils.isEmpty(adAppInfo.getAppVersion()) ? "" : adAppInfo.getAppVersion());
+//            appInfoClickViewList.add(developerTextView);
+//            appInfoClickViewList.add(versionTextView);
+//
+//            if (!TextUtils.isEmpty(adAppInfo.getFunctionUrl())) {
+//                functionTextView.setVisibility(View.VISIBLE);
+//                appInfoClickViewList.add(functionTextView);
+//                setOpenUrlClickListener(functionTextView, adAppInfo.getFunctionUrl());
+//            } else {
+//                functionTextView.setOnClickListener(null);
+//                functionTextView.setVisibility(View.GONE);
+//            }
+//
+//            if (!TextUtils.isEmpty(adAppInfo.getAppPrivacyUrl())) {
+//                privacyTextView.setVisibility(View.VISIBLE);
+//                privacyClickViewList.add(privacyTextView);
+//                setOpenUrlClickListener(privacyTextView, adAppInfo.getAppPrivacyUrl());
+//            } else {
+//                privacyTextView.setVisibility(View.GONE);
+//                privacyTextView.setOnClickListener(null);
+//            }
+//
+//            if (!TextUtils.isEmpty(adAppInfo.getAppPermissonUrl())) {
+//                permissionTextView.setVisibility(View.VISIBLE);
+//                permissionClickViewList.add(permissionTextView);
+//                setOpenUrlClickListener(permissionTextView, adAppInfo.getAppPermissonUrl());
+//            } else {
+//                permissionTextView.setVisibility(View.GONE);
+//                permissionTextView.setOnClickListener(null);
+//            }
+//
+//            if (nativePrepareInfo instanceof ATNativePrepareExInfo) {
+//                ((ATNativePrepareExInfo) nativePrepareInfo).setAppInfoClickViewList(
+//                        appInfoClickViewList);
+//                ((ATNativePrepareExInfo) nativePrepareInfo).setPermissionClickViewList(
+//                        permissionClickViewList);
+//                ((ATNativePrepareExInfo) nativePrepareInfo).setPrivacyClickViewList(
+//                        privacyClickViewList);
+//            }
+//        } else {
+//            sixInfoView.setVisibility(View.GONE);
+//        }
+//    }
+
+    private static void renderShakeView(Context context, ATNativeMaterial adMaterial, FrameLayout shakeViewContainer) {
+        shakeViewContainer.removeAllViews();
+        int shakeViewWidth = dip2px(context, 100);  //组件的宽,不小于80dp
+        int shakeViewHeight = dip2px(context, 100); //组件的高,不小于80dp
+        View shakeView = adMaterial.getShakeView(shakeViewWidth, shakeViewHeight, new ATShakeViewListener() {
+            @Override
+            public void onDismiss() {
+                shakeViewContainer.setVisibility(View.GONE);
+            }
+        });
+        if (shakeView != null && shakeViewContainer != null) {
+            shakeViewContainer.setVisibility(View.VISIBLE);
+            shakeViewContainer.removeAllViews();
+            FrameLayout.LayoutParams shakeViewLayoutParams = new FrameLayout.LayoutParams(shakeViewWidth, shakeViewHeight);
+            shakeViewLayoutParams.gravity = Gravity.CENTER;
+            shakeViewContainer.addView(shakeView, shakeViewLayoutParams);
+        }
+    }
+
+    private static void renderSlideView(Context context, ATNativeMaterial adMaterial, FrameLayout slideViewContainer) {
+        slideViewContainer.removeAllViews();
+        int slideViewWidth = dip2px(context, 120);  //滑动引导区域的宽
+        int slideViewHeight = dip2px(context, 50); // 滑动引导区域的高
+        int repeat = 5; //动画的重复次数,结束后自动隐藏组件
+        View slideView = adMaterial.getSlideView(slideViewWidth, slideViewHeight, repeat, new ATShakeViewListener() {
+            @Override
+            public void onDismiss() {
+                slideViewContainer.setVisibility(View.GONE);
+            }
+        });
+        if (slideView != null && slideViewContainer != null) {
+            slideViewContainer.setVisibility(View.VISIBLE);
+            slideViewContainer.removeAllViews();
+            FrameLayout.LayoutParams slideViewLayoutParams = new FrameLayout.LayoutParams(slideViewWidth, slideViewHeight + dip2px(context, 50));
+            slideViewLayoutParams.gravity = Gravity.CENTER;
+            slideViewContainer.addView(slideView, slideViewLayoutParams);
+        }
+    }
+
+    private static void setOpenUrlClickListener(View view, final String url) {
+        view.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                try {
+                    Intent intent = new Intent(Intent.ACTION_VIEW,
+                            Uri.parse(url));
+                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
+                            | Intent.FLAG_ACTIVITY_NEW_TASK);
+                    Context context = view.getContext();
+                    if (context != null) {
+                        context.startActivity(intent);
+                    }
+                } catch (Throwable e2) {
+                    e2.printStackTrace();
+                }
+            }
+        });
+
+    }
+
+//    private static View initializePlayer(Context context, String url) {
+//        VideoView videoView = new VideoView(context);
+//        videoView.setVideoURI(Uri.parse(url));
+//        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+//            @Override
+//            public void onPrepared(MediaPlayer mediaPlayer) {
+//            }
+//        });
+//        videoView.start();
+//
+//        return videoView;
+//    }
+
+    public static int dip2px(Context context, float dipValue) {
+        float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (dipValue * scale + 0.5f);
+    }
+
+    private static void printNativeAdMaterial(ATNativeMaterial adMaterial) {
+        if (adMaterial == null) return;
+
+        String adType = adMaterial.getAdType();
+        switch (adType) {
+            case CustomNativeAd.NativeAdConst.VIDEO_TYPE:
+                Log.i(TAG, "Ad source type: Video" + ", video duration: " + adMaterial.getVideoDuration());
+                break;
+            case CustomNativeAd.NativeAdConst.IMAGE_TYPE:
+                Log.i(TAG, "Ad source type: Image");
+                break;
+            default:
+                Log.i(TAG, "Ad source type: Unknown");
+                break;
+        }
+        switch (adMaterial.getNativeType()) {
+            case CustomNativeAd.NativeType.FEED:
+                Log.i(TAG, "Native type: Feed");
+                break;
+            case CustomNativeAd.NativeType.PATCH:
+                Log.i(TAG, "Native type: Patch");
+                break;
+        }
+
+        Log.i(TAG, "show native material:" + "\n" +
+                "adMaterial: " + adMaterial + "\n" +
+                "getTitle:" + adMaterial.getTitle() + "\n" +
+                "getDescriptionText:" + adMaterial.getDescriptionText() + "\n" +
+                "getNativeType:" + adMaterial.getNativeType() + "\n" +
+                "getAdMediaView:" + adMaterial.getAdMediaView() + "\n" +
+                "getAdIconView:" + adMaterial.getAdIconView() + "\n" +
+                "getIconImageUrl:" + adMaterial.getIconImageUrl() + "\n" +
+                "getMainImageUrl:" + adMaterial.getMainImageUrl() + "\n" +
+                "getMainImageWidth:" + adMaterial.getMainImageWidth() + "\n" +
+                "getMainImageHeight:" + adMaterial.getMainImageHeight() + "\n" +
+                "getVideoWidth:" + adMaterial.getVideoWidth() + "\n" +
+                "getVideoHeight:" + adMaterial.getVideoHeight() + "\n" +
+                "getAppPrice:" + adMaterial.getAppPrice() + "\n" +
+                "getAppCommentNum:" + adMaterial.getAppCommentNum() + "\n" +
+                "getCallToActionText:" + adMaterial.getCallToActionText() + "\n" +
+                "getStarRating:" + adMaterial.getStarRating() + "\n" +
+                "getVideoUrl:" + adMaterial.getVideoUrl() + "\n" +
+                "getAdChoiceIconUrl:" + adMaterial.getAdChoiceIconUrl() + "\n" +
+                "getAdFrom:" + adMaterial.getAdFrom() + "\n" +
+                "getImageUrlList:" + adMaterial.getImageUrlList() + "\n" +
+                "getNetworkInfoMap:" + adMaterial.getNetworkInfoMap() + "\n" +
+                "getAdAppInfo:" + adMaterial.getAdAppInfo() + "\n" +
+                "getNativeAdInteractionType:" + (adMaterial.getNativeAdInteractionType()) + "\n" +
+                "getVideoDuration:" + adMaterial.getVideoDuration() + "\n" +
+                "getAdvertiserName:" + adMaterial.getAdvertiserName() + "\n" +
+                "getNativeType:" + adMaterial.getNativeType() + "\n" +
+                "getAdType:" + adMaterial.getAdType() + "\n" +
+                "getNativeCustomVideo:" + adMaterial.getNativeCustomVideo() + "\n" +
+                "getAdLogo:" + adMaterial.getAdLogo() + "\n" +
+                "getNativeExpressWidth:" + adMaterial.getNativeExpressWidth() + "\n" +
+                "getNativeExpressHeight" + adMaterial.getNativeExpressHeight() + "\n"
+        );
+    }
+
+}

+ 192 - 116
app/src/main/res/layout/activity_login.xml

@@ -1,166 +1,242 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@drawable/bg1"
-    android:orientation="vertical">
-
-    <ImageView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal"
-        android:layout_marginTop="95dp"
-        android:background="@mipmap/icon_title1" />
+    android:layout_height="match_parent">
 
     <LinearLayout
-        android:id="@+id/login_btn_ll"
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:layout_marginStart="65dp"
-        android:layout_marginEnd="65dp"
-        android:background="@drawable/login_btn_bg"
-        android:gravity="center"
-        android:orientation="horizontal"
-        android:visibility="gone">
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:drawableStart="@mipmap/icon_wx"
-            android:drawablePadding="10dp"
-            android:text="微信登录"
-            android:textColor="#FF000000"
-            android:textSize="20sp" />
-    </LinearLayout>
+        android:layout_height="match_parent"
+        android:background="@drawable/bg1"
+        android:orientation="vertical">
 
-    <LinearLayout
-        android:id="@+id/progress_ll"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="60dp"
-        android:layout_marginEnd="60dp"
-        android:gravity="center"
-        android:orientation="vertical"
-        android:visibility="visible">
+        <ImageView
+            android:layout_width="300dp"
+            android:layout_height="300dp"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="29dp"
+            android:background="@mipmap/icon_title1" />
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="18dp"
-            android:text="红包加载中..."
-            android:textColor="#FFFFFFFF"
-            android:textSize="14sp" />
-
-        <RelativeLayout
+        <LinearLayout
+            android:id="@+id/login_btn_ll"
             android:layout_width="match_parent"
-            android:layout_height="match_parent">
-
-            <ProgressBar
-                android:id="@+id/activity_login_progress"
-                style="@android:style/Widget.ProgressBar.Horizontal"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:max="100"
-                android:progress="10"
-                android:progressDrawable="@drawable/custom_progress_bar" />
-
+            android:layout_height="50dp"
+            android:layout_marginStart="65dp"
+            android:layout_marginTop="30dp"
+            android:layout_marginEnd="65dp"
+            android:background="@drawable/login_btn_bg"
+            android:gravity="center"
+            android:orientation="horizontal"
+            android:visibility="gone">
 
             <TextView
-                android:id="@+id/activity_login_progress_tx"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_centerInParent="true"
-                android:text="0%"
-                android:textColor="#FFC14F05"
-                android:textSize="10sp"
-                android:textStyle="bold" />
-        </RelativeLayout>
-
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="bottom"
-        android:orientation="vertical"
-        android:paddingStart="25dp"
-        android:paddingEnd="25dp"
-        android:paddingBottom="50dp">
+                android:drawableStart="@mipmap/icon_wx"
+                android:drawablePadding="10dp"
+                android:text="微信登录"
+                android:textColor="#FF000000"
+                android:textSize="20sp" />
+        </LinearLayout>
 
         <LinearLayout
+            android:id="@+id/progress_ll"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:background="@drawable/border_ys"
+            android:layout_marginStart="60dp"
+            android:layout_marginTop="30dp"
+            android:layout_marginEnd="60dp"
+            android:gravity="center"
             android:orientation="vertical"
-            android:paddingTop="10dp"
-            android:paddingBottom="20dp">
+            android:visibility="gone">
 
-            <LinearLayout
-                android:layout_width="match_parent"
+            <TextView
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center"
-                android:orientation="horizontal">
+                android:layout_marginBottom="18dp"
+                android:text="红包加载中..."
+                android:textColor="#FFFFFFFF"
+                android:textSize="14sp" />
 
-                <CheckBox
-                    android:id="@+id/activity_login_check_box"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content" />
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
 
-                <TextView
-                    android:layout_width="wrap_content"
+                <ProgressBar
+                    android:id="@+id/activity_login_progress"
+                    style="@android:style/Widget.ProgressBar.Horizontal"
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:text="我已详细阅读并同意"
-                    android:textColor="#333333"
-                    android:textSize="10sp"
-                    android:textStyle="bold" />
+                    android:max="100"
+                    android:progress="10"
+                    android:progressDrawable="@drawable/custom_progress_bar" />
+
 
                 <TextView
-                    android:id="@+id/yhxy"
+                    android:id="@+id/activity_login_progress_tx"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="《用户许可协议》"
-                    android:textColor="@color/red"
+                    android:layout_centerInParent="true"
+                    android:text="0%"
+                    android:textColor="#FFC14F05"
                     android:textSize="10sp"
                     android:textStyle="bold" />
+            </RelativeLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="bottom"
+            android:orientation="vertical"
+            android:paddingStart="25dp"
+            android:paddingEnd="25dp"
+            android:paddingBottom="50dp">
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@drawable/border_ys"
+                android:orientation="vertical"
+                android:paddingTop="10dp"
+                android:paddingBottom="20dp">
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center"
+                    android:orientation="horizontal">
+
+                    <CheckBox
+                        android:id="@+id/activity_login_check_box"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="我已详细阅读并同意"
+                        android:textColor="#333333"
+                        android:textSize="10sp"
+                        android:textStyle="bold" />
+
+                    <TextView
+                        android:id="@+id/yhxy"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="《用户许可协议》"
+                        android:textColor="@color/red"
+                        android:textSize="10sp"
+                        android:textStyle="bold" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="和"
+                        android:textColor="#333333"
+                        android:textSize="10sp"
+                        android:textStyle="bold" />
+
+                    <TextView
+                        android:id="@+id/yszc"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="《隐私协议》"
+                        android:textColor="@color/red"
+                        android:textSize="10sp"
+                        android:textStyle="bold" />
+
+                </LinearLayout>
 
                 <TextView
-                    android:layout_width="wrap_content"
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:text="和"
+                    android:gravity="center_horizontal"
+                    android:text="抵制不良游戏,拒绝盗版游戏           注意自我保护,谨防上当受骗"
                     android:textColor="#333333"
                     android:textSize="10sp"
                     android:textStyle="bold" />
 
                 <TextView
-                    android:id="@+id/yszc"
-                    android:layout_width="wrap_content"
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:text="《隐私协议》"
-                    android:textColor="@color/red"
+                    android:layout_marginTop="3dp"
+                    android:gravity="center_horizontal"
+                    android:text="适度游戏益脑,沉迷游戏伤身          合理安排时间,享受健康生活"
+                    android:textColor="#333333"
                     android:textSize="10sp"
                     android:textStyle="bold" />
-
             </LinearLayout>
 
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/dialog_ys"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/tran2"
+        android:gravity="center"
+        android:orientation="vertical"
+        android:visibility="gone">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="30dp"
+            android:layout_marginEnd="30dp"
+            android:background="@drawable/border"
+            android:orientation="vertical"
+            android:padding="15dp">
+
             <TextView
-                android:layout_width="match_parent"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:gravity="center_horizontal"
-                android:text="抵制不良游戏,拒绝盗版游戏           注意自我保护,谨防上当受骗"
-                android:textColor="#333333"
-                android:textSize="10sp"
+                android:text="好运答题王服务协议与隐私政策"
+                android:textColor="@color/black"
+                android:textSize="18sp"
                 android:textStyle="bold" />
 
             <TextView
-                android:layout_width="match_parent"
+                android:id="@+id/login_ts"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginTop="3dp"
-                android:gravity="center_horizontal"
-                android:text="适度游戏益脑,沉迷游戏伤身          合理安排时间,享受健康生活"
-                android:textColor="#333333"
-                android:textSize="10sp"
+                android:layout_marginTop="10dp"
+                android:text="感谢您使用好运答题王APP,在您使用本软件过程中,我们可能会对您的部分个人信息进行收集、使用和共享。请您仔细阅读《服务协议》与《隐私政策》,并确定完全了解我们对您个人信息的处理规则。如您同意《服务协议》与《隐私政策》,请点击“同意”开始使用好运答题王,我们会尽全力保护您的个人信息安全。"
+                android:textColor="@color/black"
+                android:textSize="14sp"
                 android:textStyle="bold" />
-        </LinearLayout>
 
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="15dp"
+                android:layout_marginTop="30dp"
+                android:layout_marginEnd="15dp"
+                android:orientation="horizontal">
+
+                <TextView
+                    android:id="@+id/cancel"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:background="@mipmap/icon_btn1"
+                    android:gravity="center"
+                    android:text="不同意"
+                    android:textColor="@color/white" />
+
+                <TextView
+                    android:id="@+id/agree"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="30dp"
+                    android:layout_weight="1"
+                    android:background="@mipmap/icon_btn1"
+                    android:gravity="center"
+                    android:text="同意"
+                    android:textColor="@color/white" />
+            </LinearLayout>
+        </LinearLayout>
     </LinearLayout>
-</LinearLayout>
+
+</RelativeLayout>

+ 2 - 0
app/src/main/res/layout/activity_main.xml

@@ -13,12 +13,14 @@
     <View
         android:layout_width="match_parent"
         android:layout_height="1dp"
+        android:visibility="gone"
         android:background="@color/grey" />
 
     <RadioGroup
         android:id="@+id/rg"
         android:layout_width="match_parent"
         android:layout_height="60dp"
+        android:visibility="gone"
         android:background="@color/white"
         android:gravity="center_vertical"
         android:orientation="horizontal">

+ 40 - 0
app/src/main/res/layout/activity_splash.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:id="@+id/ddc"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:gravity="center"
+        android:orientation="horizontal"
+        android:padding="35dp">
+
+        <ImageView
+            android:layout_width="50dp"
+            android:layout_height="50dp"
+            android:background="@mipmap/logo" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="20dp"
+            android:text="@string/app_name"
+            android:textColor="@color/white"
+            android:textSize="28sp"
+            android:textStyle="bold" />
+    </LinearLayout>
+
+    <FrameLayout
+        android:id="@+id/splash_ad_fl"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white" />
+
+    <FrameLayout
+        android:id="@+id/close"
+        android:layout_width="match_parent"
+        android:layout_height="150dp" />
+</RelativeLayout>

+ 26 - 2
app/src/main/res/layout/fragment_dati.xml

@@ -5,6 +5,13 @@
     android:layout_height="match_parent"
     android:orientation="vertical">
 
+    <FrameLayout
+        android:id="@+id/fragment_dati_banner"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="30dp"
+        android:background="@color/white" />
+
     <LinearLayout
         android:id="@+id/top"
         android:layout_width="match_parent"
@@ -62,6 +69,7 @@
             android:orientation="vertical">
 
             <androidx.constraintlayout.widget.ConstraintLayout
+                android:id="@+id/getTlCl"
                 android:layout_width="110dp"
                 android:layout_height="37dp">
 
@@ -215,7 +223,7 @@
         android:layout_below="@id/center"
         android:layout_marginTop="10dp"
         android:orientation="vertical"
-        android:visibility="visible">
+        android:visibility="gone">
 
         <RelativeLayout
             android:id="@+id/a1Rl"
@@ -603,9 +611,9 @@
                                     android:layout_width="wrap_content"
                                     android:layout_height="24dp"
                                     android:background="@mipmap/icon11"
+                                    android:ellipsize="end"
                                     android:gravity="center"
                                     android:maxLines="1"
-                                    android:ellipsize="end"
                                     android:paddingStart="15dp"
                                     android:paddingEnd="15dp"
                                     android:textColor="#FFE28814"
@@ -753,6 +761,22 @@
                     android:textSize="16sp" />
             </RelativeLayout>
 
+            <ImageView
+                android:id="@+id/getTlDialogClose"
+                android:layout_width="30dp"
+                android:layout_height="30dp"
+                android:layout_alignParentEnd="true"
+                android:layout_marginEnd="10dp"
+                android:background="@mipmap/icon2"
+                android:visibility="gone" />
         </RelativeLayout>
     </LinearLayout>
+
+    <com.anythink.nativead.api.ATNativeAdView
+        android:id="@+id/fragment_dati_content_ad"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/answerCl"
+        android:background="@color/white" />
+
 </RelativeLayout>

+ 193 - 0
app/src/main/res/layout/layout_native_self_mix.xml

@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:background="@android:color/darker_gray">
+
+    <RelativeLayout
+        android:id="@+id/rl_ad_root"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:background="#ffffff">
+
+        <FrameLayout
+            android:id="@+id/native_ad_content_image_area"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            tools:layout_height="200dp" />
+
+        <FrameLayout
+            android:id="@+id/native_ad_image"
+            android:layout_width="45dp"
+            android:layout_height="45dp"
+            android:layout_below="@id/native_ad_content_image_area"
+            android:layout_marginTop="10dp"
+            android:layout_marginRight="10dp"
+            android:scaleType="fitCenter" />
+
+        <FrameLayout
+            android:id="@+id/native_ad_shake_view_container"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/native_ad_content_image_area"
+            android:layout_alignBottom="@id/native_ad_content_image_area"
+            android:layout_centerHorizontal="true"
+            android:visibility="gone" />
+
+        <FrameLayout
+            android:id="@+id/native_ad_slide_view_container"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/native_ad_content_image_area"
+            android:layout_alignBottom="@id/native_ad_content_image_area"
+            android:layout_centerHorizontal="true"
+            android:visibility="gone"
+            tools:visibility="visible" />
+
+        <FrameLayout
+            android:id="@+id/native_ad_logo_container"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_above="@+id/native_ad_image"
+            android:layout_alignParentRight="true"
+            android:layout_marginRight="2dp"
+            android:layout_marginBottom="2dp"
+            android:visibility="gone" />
+
+        <ImageView
+            android:id="@+id/native_self_adlogo"
+            android:layout_width="10dp"
+            android:layout_height="10dp"
+            android:layout_marginLeft="2dp"
+            android:src="@drawable/ad_logo" />
+
+        <ImageView
+            android:id="@+id/native_ad_close"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_alignParentRight="true"
+            android:layout_marginTop="2dp"
+            android:layout_marginRight="2dp"
+            android:padding="5dp"
+            android:src="@mipmap/ad_close" />
+
+
+        <LinearLayout
+            android:id="@+id/six_info"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/native_ad_image"
+            android:layout_marginTop="5dp"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/function_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="5dp"
+                android:text="功能"
+                android:textSize="12dp" />
+
+            <TextView
+                android:id="@+id/privacy_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="5dp"
+                android:text="隐私"
+                android:textSize="12dp" />
+
+            <TextView
+                android:id="@+id/permission_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="5dp"
+                android:text="权限"
+                android:textSize="12dp" />
+
+            <TextView
+                android:id="@+id/developer_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="5dp"
+                android:text="开发者"
+                android:textSize="12dp" />
+
+            <TextView
+                android:id="@+id/version_test"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="5dp"
+                android:text="版本"
+                android:textSize="12dp" />
+
+
+        </LinearLayout>
+
+        <TextView
+            android:id="@+id/native_ad_install_btn"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/native_ad_image"
+            android:layout_alignBottom="@id/native_ad_image"
+            android:layout_alignParentRight="true"
+            android:layout_marginLeft="10dp"
+            android:background="#2095F1"
+            android:gravity="center"
+            android:paddingLeft="20dp"
+            android:paddingRight="20dp"
+            android:textColor="#ffffff" />
+
+        <TextView
+            android:id="@+id/native_ad_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/native_ad_image"
+            android:layout_toLeftOf="@id/native_ad_install_btn"
+            android:layout_toRightOf="@id/native_ad_image"
+            android:ellipsize="end"
+            android:maxLines="1"
+            android:textColor="#000000"
+            android:textSize="15dp"
+            android:textStyle="bold" />
+
+        <TextView
+            android:id="@+id/native_ad_desc"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignBottom="@id/native_ad_image"
+            android:layout_toLeftOf="@id/native_ad_install_btn"
+            android:layout_toRightOf="@id/native_ad_image"
+            android:ellipsize="end"
+            android:maxLines="1"
+            android:textColor="#777777"
+            android:textSize="12dp" />
+
+        <TextView
+            android:id="@+id/native_ad_from"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/native_self_adlogo"
+            android:layout_marginLeft="2dp"
+            android:layout_marginRight="2dp"
+            android:layout_toRightOf="@id/native_self_adlogo"
+            android:background="#888888"
+            android:gravity="center"
+            android:paddingLeft="2dp"
+            android:paddingRight="2dp"
+            android:textColor="#ffffff"
+            android:textSize="6dp" />
+
+        <com.anythink.nativead.api.ATNativeImageView
+            android:id="@+id/native_ad_logo"
+            android:layout_width="40dp"
+            android:layout_height="20dp"
+            android:layout_above="@+id/native_ad_image"
+            android:layout_alignParentRight="true"
+            android:layout_marginRight="2dp"
+            android:layout_marginBottom="2dp"
+            android:visibility="gone" />
+    </RelativeLayout>
+</FrameLayout>

BIN
app/src/main/res/mipmap-xxhdpi/close.png


+ 4 - 4
app/src/main/res/xml/network_security_config.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <network-security-config>
-    <base-config cleartextTrafficPermitted="true">
+    <base-config cleartextTrafficPermitted="true" />
+    <debug-overrides>
         <trust-anchors>
-            <certificates src="system" overridePins="true" /> <!--信任系统证书-->
-            <certificates src="user" overridePins="true" /> <!--信任用户证书-->
+            <certificates src="user" />
         </trust-anchors>
-    </base-config>
+    </debug-overrides>
 </network-security-config>

+ 0 - 1
build.gradle.kts

@@ -1,4 +1,3 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
 plugins {
     alias(libs.plugins.android.application) apply false
     alias(libs.plugins.kotlin.android) apply false

+ 1 - 19
gradle.properties

@@ -1,24 +1,6 @@
-# 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=-Xmx2048m -Dfile.encoding=UTF-8
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. For more details, visit
-# https://developer.android.com/r/tools/gradle-multi-project-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
 android.enableJetifier=true
-# Kotlin code style for this project: "official" or "obsolete":
 kotlin.code.style=official
-# Enables namespacing of each library's R class so that its R class includes only the
-# resources declared in the library itself and none from the library's dependencies,
-# thereby reducing the size of the R class for that library
 android.nonTransitiveRClass=true

+ 12 - 1
settings.gradle.kts

@@ -17,10 +17,21 @@ dependencyResolutionManagement {
         flatDir {
             dirs("libs") // 指向项目根目录下的 libs 文件夹
         }
+        maven { url = uri("https://maven.aliyun.com/repository/public/") }
         jcenter()
-        maven { url=uri("https://jitpack.io") }
+        maven { url = uri("https://jitpack.io") }
         google()
         mavenCentral()
+
+        //Anythink(Core)
+        maven {
+            url = uri("https://jfrog.takuad.com/artifactory/china_sdk")
+        }
+
+        //Csj
+        maven {
+            url = uri("https://artifact.bytedance.com/repository/pangle")
+        }
     }
 }
 

Some files were not shown because too many files changed in this diff