Skip to content

Commit 8d3a3f7

Browse files
committed
取消滑动拉升效果
1 parent 97437a9 commit 8d3a3f7

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

app/src/main/java/com/tencent/iot/explorer/link/kitlink/fragment/SecondDeviceCategoryFragment.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.os.Bundle
99
import android.text.TextUtils
1010
import android.view.Gravity
1111
import android.view.LayoutInflater
12+
import android.view.MotionEvent
1213
import android.view.View
1314
import android.view.ViewGroup
1415
import android.widget.ImageView
@@ -112,7 +113,7 @@ class SecondDeviceCategoryFragment() : BaseFragment(), MyCallback {
112113
HttpRequest.instance.getSecondLevelCategoryList(categoryKey, this)
113114
}
114115

115-
var bleToGoView = object : BleToGoView {
116+
private val bleToGoView = object : BleToGoView {
116117
override fun onGoH5Ble(productId: String) {
117118
var bundle = Bundle()
118119
bundle.putString(CommonField.EXTRA_INFO, productId)
@@ -238,11 +239,17 @@ class SecondDeviceCategoryFragment() : BaseFragment(), MyCallback {
238239
llTitleLp.rightMargin = Utils.dp2px(requireContext(), 10)
239240
mLlTitleMap[it.SubCategoryKey] = llTitle
240241
second_category_container.addView(llTitle, llTitleLp)
241-
val deviceGridView = RecyclerView(requireContext())
242+
val deviceGridView = object : RecyclerView(requireContext()) {
243+
override fun onTouchEvent(e: MotionEvent?) = false
244+
}
245+
deviceGridView.overScrollMode = View.OVER_SCROLL_NEVER
242246
deviceGridView.tag = "${it.SubCategoryKey}_gridview_tag"
243247
val gridAdapter = GridAdapter(onItemClickListener)
244248
deviceGridView.adapter = gridAdapter
245-
deviceGridView.layoutManager = GridLayoutManager(requireContext(), 3)
249+
deviceGridView.layoutManager = object : GridLayoutManager(requireContext(), 3) {
250+
override fun canScrollHorizontally() = false
251+
override fun canScrollVertically() = false
252+
}
246253
deviceGridView.isVisible = false
247254
mGridAdapterMap[it.SubCategoryKey] = deviceGridView
248255
second_category_container.addView(deviceGridView)
@@ -331,7 +338,11 @@ class SecondDeviceCategoryFragment() : BaseFragment(), MyCallback {
331338

332339
private val onItemClickListener = object : OnItemClickListener<CategoryDeviceInfo> {
333340
override fun onItemClick(position: Int, data: CategoryDeviceInfo) {
334-
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
341+
if (ContextCompat.checkSelfPermission(
342+
requireContext(),
343+
Manifest.permission.ACCESS_FINE_LOCATION
344+
) != PackageManager.PERMISSION_GRANTED
345+
) {
335346
clickDeviceInfo = data
336347
// 查看请求location权限的时间是否大于48小时
337348
var locationJsonString = Utils.getStringValueFromXml(
@@ -365,7 +376,7 @@ class SecondDeviceCategoryFragment() : BaseFragment(), MyCallback {
365376
)
366377

367378
} else {
368-
if (data.IsRelatedProduct){// 根据推荐设备的配网方式,跳转到SmartConfig或者SoftAp配网界面
379+
if (data.IsRelatedProduct) {// 根据推荐设备的配网方式,跳转到SmartConfig或者SoftAp配网界面
369380
if (goBleH5Presenter != null) {
370381
conditionPrefix = false
371382
goBleH5Presenter!!.checkProductConfig(data.ProductId)
@@ -374,7 +385,7 @@ class SecondDeviceCategoryFragment() : BaseFragment(), MyCallback {
374385
listOf(data.ProductId), this@SecondDeviceCategoryFragment
375386
)
376387
}
377-
}else{
388+
} else {
378389
startActivityWithExtra(SmartConfigStepActivity::class.java, "")
379390
}
380391
}

app/src/main/res/layout/new_fragment_devices.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
android:id="@+id/ll_recommend_title"
2424
android:layout_width="match_parent"
2525
android:layout_height="wrap_content"
26-
android:layout_marginTop="13dp"
2726
android:layout_marginHorizontal="10dp"
27+
android:layout_marginTop="13dp"
2828
android:gravity="center_vertical"
2929
android:orientation="horizontal">
3030

@@ -55,6 +55,7 @@
5555
android:id="@+id/rv_recommend_devices"
5656
android:layout_width="match_parent"
5757
android:layout_height="wrap_content"
58+
android:overScrollMode="never"
5859
android:tag="recommend_gridview_tag"
5960
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
6061
app:spanCount="3" />

0 commit comments

Comments
 (0)