Commit b2e88f7d authored by wanglei's avatar wanglei

...

parent e1a2fc06
...@@ -5,15 +5,20 @@ import android.view.View ...@@ -5,15 +5,20 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.base.browserwhite.R import com.base.browserwhite.R
import com.base.browserwhite.bean.ConstObject.JUNK_CLEANER
import com.base.browserwhite.databinding.ItemHead1Binding
import com.base.browserwhite.utils.XmlEx.inflate import com.base.browserwhite.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseSingleItemAdapter import com.chad.library.adapter4.BaseSingleItemAdapter
class HeaderAdapter: BaseSingleItemAdapter<Any, HeaderAdapter.VH>() { class HeaderAdapter(val click:(key:String)->Unit): BaseSingleItemAdapter<Any, HeaderAdapter.VH>() {
class VH(view: View): RecyclerView.ViewHolder(view) class VH(view: View): RecyclerView.ViewHolder(view)
override fun onBindViewHolder(holder: VH, item: Any?) { override fun onBindViewHolder(holder: VH, item: Any?) {
val binding = ItemHead1Binding.bind(holder.itemView)
binding.llClean.setOnClickListener {
click.invoke(JUNK_CLEANER)
}
} }
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH { override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
......
...@@ -9,6 +9,7 @@ import com.base.browserwhite.bean.ConstObject.BAIDU ...@@ -9,6 +9,7 @@ import com.base.browserwhite.bean.ConstObject.BAIDU
import com.base.browserwhite.bean.ConstObject.BING import com.base.browserwhite.bean.ConstObject.BING
import com.base.browserwhite.bean.ConstObject.DUCKDUCKGO import com.base.browserwhite.bean.ConstObject.DUCKDUCKGO
import com.base.browserwhite.bean.ConstObject.GOOGLE import com.base.browserwhite.bean.ConstObject.GOOGLE
import com.base.browserwhite.bean.ConstObject.JUNK_CLEANER
import com.base.browserwhite.bean.ConstObject.YAHOO import com.base.browserwhite.bean.ConstObject.YAHOO
import com.base.browserwhite.bean.ConstObject.YANDEX import com.base.browserwhite.bean.ConstObject.YANDEX
import com.base.browserwhite.bean.WebSiteBean import com.base.browserwhite.bean.WebSiteBean
...@@ -16,6 +17,7 @@ import com.base.browserwhite.bean.defaultValue ...@@ -16,6 +17,7 @@ import com.base.browserwhite.bean.defaultValue
import com.base.browserwhite.bean.webSiteGroupBeanList import com.base.browserwhite.bean.webSiteGroupBeanList
import com.base.browserwhite.databinding.FragmentHomeBinding import com.base.browserwhite.databinding.FragmentHomeBinding
import com.base.browserwhite.service.StayNotificationService.Companion.restartStartStayNotification import com.base.browserwhite.service.StayNotificationService.Companion.restartStartStayNotification
import com.base.browserwhite.ui.activity.cleanjunk.ScanJunkActivity
import com.base.browserwhite.ui.activity.scanqrc.ScanQRCActivity import com.base.browserwhite.ui.activity.scanqrc.ScanQRCActivity
import com.base.browserwhite.ui.activity.webbrowser.WebBrowserActivity import com.base.browserwhite.ui.activity.webbrowser.WebBrowserActivity
import com.base.browserwhite.ui.adapter.HeadWebsiteAdapter import com.base.browserwhite.ui.adapter.HeadWebsiteAdapter
...@@ -76,7 +78,14 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() { ...@@ -76,7 +78,14 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
}).build() }).build()
// 设置预加载,请调用以下方法 // 设置预加载,请调用以下方法
// helper.trailingLoadStateAdapter?.preloadSize = 1 // helper.trailingLoadStateAdapter?.preloadSize = 1
helper.addBeforeAdapter(0, HeaderAdapter()) helper.addBeforeAdapter(0, HeaderAdapter { key ->
when (key) {
JUNK_CLEANER -> {
requireContext().startActivity(Intent(requireContext(), ScanJunkActivity::class.java))
}
}
})
binding.rv.adapter = helper.adapter binding.rv.adapter = helper.adapter
requestMore() requestMore()
...@@ -212,6 +221,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() { ...@@ -212,6 +221,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
false false
} }
} }
fun isMatchesUrl(urlString: String): Boolean { fun isMatchesUrl(urlString: String): Boolean {
val pattern = "^(https?://)?(www\\.)?[a-z0-9]+\\.[a-z0-9.-]+\\.[a-z]{2,6}(:[0-9]{1,5})?(/.*)?$" val pattern = "^(https?://)?(www\\.)?[a-z0-9]+\\.[a-z0-9.-]+\\.[a-z]{2,6}(:[0-9]{1,5})?(/.*)?$"
return urlString.matches(pattern.toRegex()) return urlString.matches(pattern.toRegex())
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
tools:ignore="UselessParent"> tools:ignore="UselessParent">
<LinearLayout <LinearLayout
android:id="@+id/ll_news" android:id="@+id/ll_clean"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
android:layout_height="45dp" android:layout_height="45dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="8.5dp" android:layout_marginTop="8.5dp"
android:src="@mipmap/news" android:src="@mipmap/clean"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:text="News" android:text="Clean"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_clean" android:id="@+id/ll_news"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:orientation="vertical" android:orientation="vertical"
android:visibility="invisible"
tools:ignore="UseCompoundDrawables"> tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
...@@ -53,7 +54,7 @@ ...@@ -53,7 +54,7 @@
android:layout_height="45dp" android:layout_height="45dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="8.5dp" android:layout_marginTop="8.5dp"
android:src="@mipmap/clean" android:src="@mipmap/news"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
...@@ -62,7 +63,7 @@ ...@@ -62,7 +63,7 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:text="Clean" android:text="News"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
......
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