Commit 79f9db83 authored by wanglei's avatar wanglei

...

parent 1b63ddae
......@@ -53,6 +53,7 @@ dependencies {
implementation("com.github.angcyo.DslTablayout:TabLayout:3.5.5")
implementation("de.hdodenhof:circleimageview:3.1.0")
implementation("com.github.pokercc:ExpandableRecyclerView:0.9.3")
implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
//相机
val cameraxVersion = "1.2.2"
......
......@@ -20,15 +20,14 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/logo"
android:supportsRtl="true"
android:theme="@style/Theme.BrowserWhite"
tools:targetApi="34">
<activity
android:name=".ui.activity.MainActivity"
android:name=".ui.activity.SplashActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
......@@ -37,6 +36,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.MainActivity"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
tools:ignore="DiscouragedApi,LockedOrientationActivity" />
<activity
android:name=".ui.activity.result.ResultActivity"
android:exported="false"
......
package com.base.browserwhite.bean
import com.base.browserwhite.utils.AppPreferences
object ConstObject {
const val GOOGLE = "Google"
......@@ -32,4 +34,13 @@ object ConstObject {
const val MIME_TYPE_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
const val MIME_TYPE_APK = "application/vnd.android.package-archive"
const val MIME_TYPE_ZIP = "application/zip"
var ifAgreePrivacy = false
get() {
return AppPreferences.getInstance().getBoolean("ifAgreePrivacy", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("ifAgreePrivacy", value, true)
}
}
\ No newline at end of file
......@@ -5,10 +5,11 @@ class NewsBean(
val publishTime: Long = 0,
val headline: String = "",//标题
val orgImgPath: String = "",//原媒体图片
val mediaName:String="",
val mediaIcon:String="",//媒体icon
val categoryId:Int=0,
val type:Int=0,
val linkPath:String="",//网站链接
)
\ No newline at end of file
val mediaName: String = "",
val mediaIcon: String = "",//媒体icon
val categoryId: Int = 0,
val type: Int = 0,
val linkPath: String = "",//网站链接
) {
var isBind: Boolean = false
}
\ No newline at end of file
package com.base.browserwhite.ui.activity
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.text.SpannableString
import android.text.Spanned
import android.text.style.UnderlineSpan
import android.view.View
import androidx.lifecycle.lifecycleScope
import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy
import com.base.browserwhite.databinding.ActivitySplashBinding
import com.base.browserwhite.utils.BarUtils
import com.base.browserwhite.utils.ConfigHelper
import com.base.browserwhite.utils.LogEx
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.random.Random
@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseActivity<ActivitySplashBinding>() {
private val TAG = "SplashActivity"
private var job: Job? = null
private val progress = MutableSharedFlow<Int>()
private val progressFlow: SharedFlow<Int> = progress
private var oneClickStart: Boolean = false
private var actionId = -1
override val binding: ActivitySplashBinding by lazy {
ActivitySplashBinding.inflate(layoutInflater)
}
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// if (MyApplication.isInterOpenShowing) {
// finish()
// return
// }
// startStayNotification()
// NotificationUtil.stopNotificationHandler()
// actionId = intent?.extras?.getInt("actionId") ?: -1
// closeNotification()
progressCollect()
if (ifAgreePrivacy) {
// AdmobMaxHelper.preloadAd(this)
job = startProgress()
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
} else {
binding.llStart.visibility = View.VISIBLE
binding.llProgress.visibility = View.GONE
}
val spannableString = SpannableString("Privacy Policy")
spannableString.setSpan(
UnderlineSpan(),
0,
spannableString.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
binding.idTvPrivacyPolicy.text = spannableString
binding.idTvPrivacyPolicy.setOnClickListener {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(ConfigHelper.privacyPolicy)
)
startActivity(intent)
}
}
private fun progressCollect() {
lifecycleScope.launch {
progressFlow.collectLatest {
if (it >= 100) {
job?.cancel()
jumpNext()
this.cancel()
}
}
}
}
var jumped: Boolean = false
private fun jumpNext() {
if (jumped) {
return
}
jumped = true
// LogEx.logDebug(TAG, "jumpNext actionId=$actionId")
when (actionId) {
// ID_JUNK_CLEAN_PUSH -> {
// startActivity(Intent(this, ScanJunkActivity::class.java))
// }
//
// ID_SIMILAR_IMAGE -> {
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
// }
//
// ID_SCREENSHOT_CLEAN -> {
// startActivity(Intent(this, PhotoManagerAnimationActivity::class.java))
// }
//
// ID_RECOVERY_PHOTOS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_PHOTOS)
// })
// }
//
// ID_RECOVERY_VIDEOS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_VIDEOS)
// })
// }
//
// ID_RECOVERY_DOCUMENTS -> {
// startActivity(Intent(this, FileScanResultActivity::class.java).apply {
// putExtra("ScanType", ConstObject.SCAN_DOCUMENTS)
// })
// }
//
// ID_WHATSAPP -> {
// startActivity(Intent(this, WhatsAppCleanerAnimationActivity::class.java))
// }
//
// ID_APP_PROCESS -> {
// startActivity(Intent(this, AppProcessAnimationActivity::class.java))
// }
//
// ID_APP_MANAGER -> {
// startActivity(Intent(this, AppManagerAnimationActivity::class.java))
// }
//
// ID_BATTERY_INFO -> {
// startActivity(Intent(this, BatteryInfoAnimationActivity::class.java))
// }
else -> {
val isHotLaunch = intent?.extras?.getBoolean("isHotLaunch", false) ?: false
// if (!isHotLaunch) {
startActivity(Intent(this@SplashActivity, MainActivity::class.java))
// if (!isGuide) {
// startActivity(Intent(this@SplashActivity, GuideActivity::class.java))
// isGuide = true
// } else {
// startActivity(Intent(this@SplashActivity, MainActivity::class.java))
// }
// }
}
}
finish()
intent?.extras?.clear()
}
// private fun closeNotification() {
// sendBroadcast(Intent(this, CloseNotificationReceiver::class.java).apply {
// this.action = CloseNotificationReceiver.Action
// this.putExtra(NotificationId, actionId)
// })
// }
override fun initListener() {
binding.idTvStart.setOnClickListener {
if (oneClickStart) {
return@setOnClickListener
}
oneClickStart = true
ifAgreePrivacy = true
// (application as MyApplication).initApp(true)
// AdmobMaxHelper.preloadAd(this)
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
job = startProgress()
}
}
private var processTime = 0L
private var outTimeAdStart = false
private fun startProgress() = lifecycleScope.launch {
// LogEx.logDebug(TAG, "startProgress")
while (isActive) {
val value = binding.pb.progress + 2
binding.pb.setProgress(value, true)
progress.emit(value)
val delayTime = 300L
delay(delayTime)
processTime += delayTime
if (processTime >= Random.nextLong(5000, 8000)) {
if (!outTimeAdStart) {
outTimeAdStart = true
outTimeAd()
}
}
}
}
private fun outTimeAd() {
// LogEx.logDebug(TAG, "outTimeAd")
//
// var loaded: Boolean = true
// AdmobMaxHelper.admobMaxShowOpenAd(this, showBeforeAction = { flag ->
// LogEx.logDebug(TAG, "showBeforeAction flag=$flag")
// loaded = flag
// job?.cancel()
// }, onHidden = {
// val sp = AppPreferences.getInstance().getString("splashShowInter", "0").toInt()
// if (sp == 1 && !loaded) {
// AdmobMaxHelper.admobMaxShowInterstitialAd(this, isLoading = false) {
// binding.pb.progress = 100
// jumpNext()
// }
// } else {
binding.pb.progress = 100
jumpNext()
// }
//
// })
}
override fun onResume() {
super.onResume()
LogEx.logDebug(TAG, "onResume")
if (ifAgreePrivacy && job?.isActive == false) {
job = startProgress()
}
}
override fun onPause() {
super.onPause()
job?.cancel()
LogEx.logDebug(TAG, "onPause")
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import androidx.lifecycle.LifecycleCoroutineScope
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.browserwhite.R
import com.base.browserwhite.bean.MediaBean
import com.base.browserwhite.bean.NewsBean
import com.base.browserwhite.databinding.ItemNewsBinding
import com.base.browserwhite.utils.KotlinExt.toFormatTime
......@@ -40,9 +41,16 @@ class NewsAdapter(
return beanList.size
}
override fun onBindViewHolder(holder: NewsViewHolder, @SuppressLint("RecyclerView") position: Int) {
override fun onBindViewHolder(holder: NewsViewHolder, position: Int) {
val log = "position=${holder.position} " +
"position=${holder.bindingAdapterPosition} " +
"position=${holder.absoluteAdapterPosition} " +
"position=${holder.layoutPosition}"
LogEx.logDebug(
TAG, log
)
val binding = ItemNewsBinding.bind(holder.itemView)
val bean = beanList[holder.bindingAdapterPosition]
val bean = beanList[holder.position]
val context = holder.itemView.context
Glide.with(context).load(bean.orgImgPath).listener(object : RequestListener<Drawable> {
override fun onLoadFailed(
......@@ -51,9 +59,8 @@ class NewsAdapter(
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
LogEx.logDebug(TAG, "onLoadFailed $position ${holder.bindingAdapterPosition}")
beanList.remove(bean)
notifyItemRemoved(position)
LogEx.logDebug(TAG, "onLoadFailed $log")
// beanList.remove(bean)
return true
}
......@@ -74,8 +81,10 @@ class NewsAdapter(
}
binding.tvMediaName.text = bean.mediaName
binding.tvPublishTime.text = bean.publishTime.toFormatTime()
bean.isBind = true
}
@SuppressLint("NotifyDataSetChanged")
fun loadMore(
categoryId: Int = 0,
errorCallBack: (() -> Unit)? = null,
......@@ -90,9 +99,13 @@ class NewsAdapter(
})
{
beanList.addAll(it)
if (beanList.size > 150) {
val item100 = beanList.subList(0, 100)
beanList.removeAll(item100.toSet())
}
lifecycleScope.launch(Dispatchers.Main) {
this@NewsAdapter.notifyItemInserted(position)
delay(1000)
delay(2000)
callBack?.invoke()
}
}
......
package com.base.browserwhite.ui.adapter
import android.graphics.drawable.Drawable
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.base.browserwhite.databinding.ItemNewsBinding
import com.base.browserwhite.utils.KotlinExt.toFormatTime
import com.base.browserwhite.utils.LogEx
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.chad.library.adapter4.loadState.LoadState
import com.chad.library.adapter4.loadState.LoadStateAdapter
//class NewsAdapter2: LoadStateAdapter<NewsAdapter2.NewsViewHolder>() {
// inner class NewsViewHolder(view: View) : RecyclerView.ViewHolder(view)
//
// override fun onBindViewHolder(holder: NewsViewHolder, loadState: LoadState) {
// val binding = ItemNewsBinding.bind(holder.itemView)
// val bean = beanList[holder.position]
// val context = holder.itemView.context
// Glide.with(context).load(bean.orgImgPath).listener(object : RequestListener<Drawable> {
// override fun onLoadFailed(
// e: GlideException?,
// model: Any?,
// target: Target<Drawable>,
// isFirstResource: Boolean
// ): Boolean {
// LogEx.logDebug(TAG, "onLoadFailed $log")
//// beanList.remove(bean)
// return true
// }
//
// override fun onResourceReady(
// resource: Drawable,
// model: Any,
// target: Target<Drawable>?,
// dataSource: DataSource,
// isFirstResource: Boolean
// ): Boolean {
// return false
// }
//
// }).centerCrop().into(binding.ivMedia)
// binding.tvTittle.text = bean.headline
// runCatching {
// Glide.with(context).load(bean.mediaIcon).into(binding.ivIcon)
// }
// binding.tvMediaName.text = bean.mediaName
// binding.tvPublishTime.text = bean.publishTime.toFormatTime()
// bean.isBind = true
// }
//
// override fun onCreateViewHolder(parent: ViewGroup, loadState: LoadState): NewsViewHolder {
// TODO("Not yet implemented")
// }
//}
\ No newline at end of file
package com.base.browserwhite.ui.fragment
import android.content.Intent
import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE
import com.base.browserwhite.R
import com.base.browserwhite.bean.ConstObject.BAIDU
import com.base.browserwhite.bean.ConstObject.BING
......@@ -28,6 +30,7 @@ import com.base.browserwhite.ui.views.DialogViews.showSearchEngineDialog
import com.base.browserwhite.ui.views.itemtouch.MyItemTouchHelperCallBack
import com.base.browserwhite.utils.AppPreferences
import com.base.browserwhite.utils.LogEx
import java.util.concurrent.atomic.AtomicBoolean
class HomeFragment : BaseFragment<FragmentHomeBinding>() {
......@@ -40,7 +43,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
private lateinit var websiteAdapter: WebsiteAdapter
private lateinit var itemTouchHelper: ItemTouchHelper
private lateinit var newsAdapter: NewsAdapter
private var isLoadingMore = false
private var isLoadingMore: AtomicBoolean = AtomicBoolean(false)
override fun setView() {
......@@ -62,33 +65,34 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
newsAdapter = NewsAdapter(lifecycleScope)
binding.rvNews.adapter = newsAdapter
binding.rvNews.addOnScrollListener(object : OnScrollListener() {
var i = 0
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val lastVisibleItemPosition =
(recyclerView.layoutManager as LinearLayoutManager).findLastCompletelyVisibleItemPosition()
LogEx.logDebug(
TAG,
"isLoadingMore=$isLoadingMore lastVisibleItemPosition=$lastVisibleItemPosition ${newsAdapter.itemCount} "
)
if (!isLoadingMore && lastVisibleItemPosition == newsAdapter.itemCount - 1) {
isLoadingMore = true
// 触发加载更多数据
newsAdapter.loadMore(
errorCallBack = {},
callBack = {
LogEx.logDebug(TAG, "loadMore BACK")
isLoadingMore = false
})
}
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
i++
if (newState == SCROLL_STATE_IDLE && !binding.rvNews.canScrollVertically(1)) {
loadMoreData()
}
}
})
isLoadingMore = true
loadMoreData()
}
private fun loadMoreData() {
if (isLoadingMore.get()) return
isLoadingMore.set(true)
LogEx.logDebug(TAG, "load data")
newsAdapter.loadMore(
errorCallBack = {},
errorCallBack = {
isLoadingMore.set(false)
},
callBack = {
LogEx.logDebug(TAG, "loadMore BACK")
isLoadingMore = false
isLoadingMore.set(false)
})
}
......
......@@ -2,7 +2,6 @@ package com.base.browserwhite.utils
import com.base.browserwhite.BuildConfig
import com.base.browserwhite.bean.NewsBean
import com.base.browserwhite.bean.WebSiteGroupBean
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<!-- <stroke-->
<!-- android:width="1px"-->
<!-- android:color="#FF3835" />-->
<solid android:color="#E5E5E5" />
<corners android:radius="10dp" />
</shape>
</item>
<!-- android:bottom="3dp"-->
<!-- android:end="3dp"-->
<!-- android:start="3dp"-->
<!-- android:top="3dp"-->
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="10dp" />
<solid android:color="#577DFD" />
</shape>
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/white"/>
<!-- <item android:drawable="@drawable/splash_bg" />-->
<item
android:top="130dp"
android:gravity="top|center_horizontal">
<bitmap
android:src="@mipmap/qdylogo" />
</item>
</layer-list>
\ No newline at end of file
......@@ -86,6 +86,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<TextView
......@@ -120,6 +121,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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"
android:background="@drawable/splash_bp"
android:gravity="center_horizontal"
android:orientation="vertical">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="2" />
<LinearLayout
android:id="@+id/ll_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="49dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:id="@+id/pb"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="5dp"
android:max="100"
android:progressDrawable="@drawable/shape_splash_s"
tools:progress="50" />
<TextView
android:id="@+id/tv_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:text="Loading..."
android:textColor="#000000"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tv_ad_des"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="42dp"
android:text="This process may involve ad."
android:textColor="#000000"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:text="By continuing you are agreeing to the"
android:textColor="#676767"
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" &amp; "
android:visibility="gone"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/id_tv_privacy_policy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Privacy Policy"
android:textColor="#676767"
android:textSize="14sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<TextView
android:id="@+id/id_tv_start"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginHorizontal="40dp"
android:layout_marginBottom="49dp"
android:background="#577CFB"
android:gravity="center"
android:text="START TO USE"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="visible"
tools:ignore="HardcodedText" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file
......@@ -215,7 +215,8 @@
android:layout_margin="16dp"
android:background="@drawable/bg_storke_dee9f4"
android:elevation="0dp"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
......@@ -266,6 +267,7 @@
android:layout_width="match_parent"
android:layout_height="195dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_storke_dee9f4"
android:orientation="vertical">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment