refactor(ui): 重构 ReviewActivity 使用新的列表基类
- 将 ReviewActivity 继承自 BaseListFormLayoutNormalActivity 替代原有基类 - 移除 SwipeRefreshLayout 包装器,直接使用 RecyclerView - 修改 RecyclerView 高度从 300dp 调整为 220dp - 添加水平滚动方向支持 - 移除未使用的导入包和变量 - 创建新的基础列表活动模板 BaseListFormLayoutNormalActivity - 简化布局文件结构,移除嵌套的 EmptyView 和 SwipeRefreshLayout
这个提交包含在:
父节点
c587df2e4b
当前提交
f35781ec48
@ -1,23 +1,23 @@
|
||||
package com.nova.brain.glass.ui
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nova.brain.glass.R
|
||||
import com.nova.brain.glass.databinding.ActivityFoBinding
|
||||
import com.nova.brain.glass.databinding.ActivityReviewBinding
|
||||
import com.nova.brain.glass.helper.OfflineCmdListener
|
||||
import com.nova.brain.glass.helper.OfflineCmdServiceHelper
|
||||
import com.nova.brain.glass.model.ItemItem
|
||||
import com.nova.brain.glass.model.TaskItem
|
||||
import com.nova.brain.glass.viewmodel.ItemListVM
|
||||
import com.xuqm.base.adapter.BasePagedAdapter
|
||||
import com.xuqm.base.adapter.CommonPagedAdapter
|
||||
import com.xuqm.base.adapter.ViewHolder
|
||||
import com.xuqm.base.ui.BaseActivity
|
||||
import com.xuqm.base.ui.BaseListFormLayoutActivity
|
||||
import com.xuqm.base.ui.BaseListFormLayoutNormalActivity
|
||||
|
||||
class ReviewActivity : BaseListFormLayoutActivity<ItemItem, ItemListVM,ActivityReviewBinding>() {
|
||||
class ReviewActivity : BaseListFormLayoutNormalActivity<ItemItem, ItemListVM, ActivityReviewBinding>() {
|
||||
override fun getLayoutId(): Int =R.layout.activity_review
|
||||
override fun fullscreen(): Boolean = true
|
||||
|
||||
override fun getRecyclerOrientation(): Int = RecyclerView.HORIZONTAL
|
||||
|
||||
private val listener = object : OfflineCmdListener {
|
||||
override fun onOfflineCmd(cmd: String) {
|
||||
when( cmd){
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:background="@drawable/bg_item"
|
||||
android:layout_height="300dp"
|
||||
android:layout_height="220dp"
|
||||
android:text="采用手工铺贴,按操作规程CD1442要求进行铺贴,将铺层信息填写在表SAMC 31-71《零件铺层信息、生产记录表》中,并扫描上传。 1)I型表面胶膜铺贴最大搭接6mm或对接最大间隙1.5mm。按投影线及工装余量刻线进行铺贴。 2)织物铺层的方向公差为±5°,铺贴中允许搭接13mm~25mm或对接间隙≤1.5mm,拼缝错开至少25mm,同向铺层之间可以每隔4层重复拼缝的错开位置。按投影线及工装余量刻线进行铺贴,加强层铺贴位置公差为投影位置±2.5mm。"
|
||||
android:textColor="#ff40FF5E"
|
||||
android:layout_marginTop="10dp"
|
||||
@ -33,29 +33,15 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvTaskHeader" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/baseRefreshLayout"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/baseRecyclerView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:overScrollMode="never"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/content">
|
||||
|
||||
<com.xuqm.base.view.EmptyView
|
||||
android:id="@+id/baseEmptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/baseRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:overScrollMode="never"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
</com.xuqm.base.view.EmptyView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
app:layout_constraintTop_toBottomOf="@id/content" />
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,105 @@
|
||||
package com.xuqm.base.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.paging.PagedList;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.xuqm.base.R;
|
||||
import com.xuqm.base.adapter.BaseItem;
|
||||
import com.xuqm.base.adapter.BasePagedAdapter;
|
||||
import com.xuqm.base.common.RefreshResult;
|
||||
import com.xuqm.base.viewmodel.BaseListViewModel;
|
||||
import com.xuqm.base.viewmodel.callback.AdapterObserverCallback;
|
||||
import com.xuqm.base.viewmodel.callback.DataObserverCallback;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
public abstract class BaseListFormLayoutNormalActivity<T extends BaseItem, VM extends BaseListViewModel<T>, V extends ViewDataBinding>
|
||||
extends BaseActivity<V> {
|
||||
|
||||
private final ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
|
||||
private final Class<VM> cal = (Class<VM>) parameterizedType.getActualTypeArguments()[1];
|
||||
private VM viewModel;
|
||||
private BasePagedAdapter<T> adapter;
|
||||
|
||||
public RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_base_list_normal;
|
||||
}
|
||||
|
||||
public VM getViewModel() {
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public BasePagedAdapter<T> getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(Bundle savedInstanceState) {
|
||||
viewModel = new ViewModelProvider(this).get(cal);
|
||||
adapter = adapter();
|
||||
adapter.setItemClickListener(this::itemClicked);
|
||||
adapter.setItemLongClickListener(this::itemLongClicked);
|
||||
recyclerView = findViewById(R.id.baseRecyclerView);
|
||||
recyclerView.setAdapter(adapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, getRecyclerOrientation(), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
viewModel.observeDataObserver(this, new DataObserverCallback<T>() {
|
||||
@Override
|
||||
public void data(PagedList<T> data) {
|
||||
adapter.submitList(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshResult(RefreshResult refreshResult) {
|
||||
refreshFinished(refreshResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadMoreResult(RefreshResult refreshResult) {
|
||||
loadMoreFinished(refreshResult);
|
||||
}
|
||||
});
|
||||
viewModel.observeAdapterObserver(this, new AdapterObserverCallback() {
|
||||
@Override
|
||||
public void notifyItem(int position, Object payload) {
|
||||
adapter.notifyItemChanged(position, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeItem(int position) {
|
||||
adapter.notifyItemRangeRemoved(position, adapter.getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void itemClicked(View view, T item, int position) {
|
||||
}
|
||||
|
||||
public boolean itemLongClicked(View view, T item, int position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getRecyclerOrientation() {
|
||||
return RecyclerView.VERTICAL;
|
||||
}
|
||||
|
||||
public void refreshFinished(RefreshResult result) {
|
||||
}
|
||||
|
||||
public void loadMoreFinished(RefreshResult result) {
|
||||
}
|
||||
|
||||
public abstract BasePagedAdapter<T> adapter();
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/baseRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never" />
|
||||
</layout>
|
||||
正在加载...
在新工单中引用
屏蔽一个用户