parent
a9d2f5aedd
commit
7912b9e627
37 changed files with 674 additions and 136 deletions
@ -0,0 +1,12 @@ |
||||
package com.project.survey.logic.repository |
||||
|
||||
import androidx.lifecycle.MutableLiveData |
||||
import com.project.survey.model.LoginBean |
||||
import com.project.survey.model.ProjectBean |
||||
|
||||
class GlobalRepository { |
||||
|
||||
val loginBean = MutableLiveData<LoginBean>() |
||||
|
||||
val currentProject = MutableLiveData<ProjectBean>() |
||||
} |
@ -0,0 +1,11 @@ |
||||
package com.project.survey.logic.viewmodel |
||||
|
||||
import com.project.survey.network.RetrofitClient |
||||
|
||||
class MainViewModel : BaseViewModel() { |
||||
|
||||
val api = RetrofitClient.createApiService() |
||||
|
||||
|
||||
|
||||
} |
@ -1,6 +1,14 @@ |
||||
package com.project.survey.model |
||||
|
||||
import android.os.Parcelable |
||||
import kotlinx.android.parcel.Parcelize |
||||
|
||||
/** |
||||
* {"token":"a52e6940-34c9-4f93-8a60-5b13bf25693f","mobilePhone":"15903684576","personId":"fqwerfqergqwer"} |
||||
*/ |
||||
@Parcelize |
||||
data class LoginBean( |
||||
val token: String, |
||||
val mobilePhone: String |
||||
) |
||||
val mobilePhone: String, |
||||
val personId: String |
||||
) : Parcelable |
||||
|
@ -0,0 +1,110 @@ |
||||
package com.project.survey.ui.controlnet |
||||
|
||||
import androidx.activity.viewModels |
||||
import com.project.survey.R |
||||
import com.project.survey.constants.SPConstants |
||||
import com.project.survey.databinding.ActivityControlNetListBinding |
||||
import com.project.survey.extend.smartDismiss |
||||
import com.project.survey.logic.viewmodel.ControlNetViewModel |
||||
import com.project.survey.model.ControlNetVersionBean |
||||
import com.project.survey.ui.base.BaseBindingActivity |
||||
import com.project.survey.ui.controlnet.adapter.ControlNetFirstAdapter |
||||
import com.project.survey.ui.controlnet.adapter.ControlNetSpecialAdapter |
||||
import com.project.survey.util.ActivityNavUtil |
||||
import com.project.survey.util.SPUtils |
||||
import com.project.survey.widget.decoration.TransparentDividerDecoration |
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout |
||||
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener |
||||
|
||||
/** |
||||
* 控制点详情 |
||||
*/ |
||||
class ControlPointActivity : BaseBindingActivity<ActivityControlNetListBinding>(), |
||||
OnRefreshLoadMoreListener { |
||||
|
||||
companion object { |
||||
fun start() { |
||||
ActivityNavUtil.startActivity<ControlPointActivity> { } |
||||
} |
||||
} |
||||
|
||||
override fun getBinding(): ActivityControlNetListBinding = |
||||
ActivityControlNetListBinding.inflate(layoutInflater) |
||||
|
||||
private val viewModel: ControlNetViewModel by viewModels() |
||||
|
||||
private val adapter by lazy { ControlNetFirstAdapter() } |
||||
private var currentPage = 1 |
||||
private var start = 0 |
||||
|
||||
override fun initView() { |
||||
immersionToolbar(mBinding.ilToolBar.toolbar, "控制点详情") |
||||
|
||||
initVersion() |
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(this) |
||||
mBinding.recyclerView.addItemDecoration(TransparentDividerDecoration(this)) |
||||
mBinding.recyclerView.adapter = adapter |
||||
adapter.isStateViewEnable = true |
||||
adapter.setStateViewLayout(this, R.layout.layout_no_data) |
||||
} |
||||
|
||||
override fun initData() { |
||||
viewModel.errorResponse.observe(this) { |
||||
mBinding.smartRefreshLayout.smartDismiss() |
||||
} |
||||
viewModel.controlNetCGListResponse.observe(this) { |
||||
mBinding.smartRefreshLayout.smartDismiss() |
||||
if (currentPage == 1) { |
||||
adapter.submitList(it.rows) |
||||
if (it.rows.isEmpty()) { |
||||
mBinding.smartRefreshLayout.finishLoadMoreWithNoMoreData() |
||||
adapter.setStateViewLayout(this, R.layout.layout_no_data) |
||||
} else { |
||||
currentPage++ |
||||
start += it.totalCount |
||||
} |
||||
} else { |
||||
if (it.rows.isEmpty()) { |
||||
mBinding.smartRefreshLayout.finishLoadMoreWithNoMoreData() |
||||
} else { |
||||
adapter.addAll(it.rows) |
||||
currentPage++ |
||||
start += it.totalCount |
||||
} |
||||
} |
||||
} |
||||
fetchData() |
||||
} |
||||
|
||||
private fun fetchData(){ |
||||
viewModel.fetchSpecialControlNetCGList("", currentPage, start) |
||||
} |
||||
|
||||
override fun onRefresh(refreshLayout: RefreshLayout) { |
||||
currentPage = 0 |
||||
start = 0 |
||||
fetchData() |
||||
} |
||||
|
||||
override fun onLoadMore(refreshLayout: RefreshLayout) { |
||||
fetchData() |
||||
} |
||||
|
||||
override fun initListener() { |
||||
|
||||
} |
||||
|
||||
private fun initVersion() { |
||||
val versionList = mutableListOf<ControlNetVersionBean>() |
||||
versionList.add(ControlNetVersionBean("版本一")) |
||||
versionList.add(ControlNetVersionBean("版本二")) |
||||
versionList.add(ControlNetVersionBean("版本三")) |
||||
|
||||
mBinding.ilSearch.spinner.setItems(versionList) |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,13 @@ |
||||
package com.project.survey.util |
||||
|
||||
import com.project.survey.constants.SPConstants |
||||
|
||||
object LogoutUtil { |
||||
|
||||
fun clearSP(){ |
||||
SPUtils.removeKey(SPConstants.ACCOUNT) |
||||
SPUtils.removeKey(SPConstants.TOKEN) |
||||
SPUtils.removeKey(SPConstants.MOBILE_PHONE) |
||||
SPUtils.removeKey(SPConstants.PERSON_ID) |
||||
} |
||||
} |
@ -0,0 +1,40 @@ |
||||
package com.project.survey.widget |
||||
|
||||
import android.content.Context |
||||
import android.util.AttributeSet |
||||
import android.view.LayoutInflater |
||||
import android.view.inputmethod.EditorInfo |
||||
import androidx.appcompat.widget.LinearLayoutCompat |
||||
import com.project.survey.R |
||||
import com.project.survey.databinding.WidgetSearchBinding |
||||
import com.project.survey.databinding.WidgetSectionItemBinding |
||||
import com.project.survey.extend.isVisibleOrGone |
||||
import com.project.survey.extend.toast |
||||
|
||||
class SearchWidget @JvmOverloads constructor( |
||||
context: Context, |
||||
val attrs: AttributeSet? = null, |
||||
defStyleAttr: Int = 0 |
||||
) : LinearLayoutCompat(context, attrs, defStyleAttr) { |
||||
|
||||
private val binding: WidgetSearchBinding |
||||
|
||||
init { |
||||
binding = WidgetSearchBinding.inflate(LayoutInflater.from(context), this, true) |
||||
val typeArray = context.obtainStyledAttributes(attrs, R.styleable.SearchWidget) |
||||
|
||||
binding.etSearch.setHint(typeArray.getString(R.styleable.SearchWidget_sw_hint)) |
||||
|
||||
typeArray.recycle() |
||||
} |
||||
|
||||
|
||||
fun setOnEditorSearchListener(onSearch: (String) -> Unit) { |
||||
binding.etSearch.setOnEditorActionListener { textView, i, keyEvent -> |
||||
if (i == EditorInfo.IME_ACTION_SEARCH) { |
||||
onSearch(textView.text.toString()) |
||||
} |
||||
return@setOnEditorActionListener true |
||||
} |
||||
} |
||||
} |
@ -1,6 +1,6 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:shape="rectangle"> |
||||
<corners android:radius="99dp" /> |
||||
<corners android:radius="15dp" /> |
||||
<solid android:color="#f2f4f5" /> |
||||
</shape> |
@ -1,45 +1,63 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tl="http://schemas.android.com/apk/res-auto" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tl="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:orientation="vertical"> |
||||
|
||||
<include |
||||
android:id="@+id/ilToolBar" |
||||
layout="@layout/sh_toolbar" /> |
||||
<com.google.android.material.appbar.MaterialToolbar |
||||
android:id="@+id/toolbar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="?actionBarSize" |
||||
android:background="@color/transparent" |
||||
app:navigationIcon="@drawable/icon_toolbar_back" |
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" |
||||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" |
||||
app:titleCentered="true" |
||||
app:titleTextAppearance="@style/ToolbarTextAppearance" /> |
||||
|
||||
<include layout="@layout/item_search" /> |
||||
<com.project.survey.widget.SearchWidget |
||||
android:id="@+id/searchWidget" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
app:sw_hint="项目名称、项目编号" /> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/recyclerView" |
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout |
||||
android:id="@+id/smartRefreshLayout" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:itemCount="3" |
||||
tools:listitem="@layout/item_project_list" |
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> |
||||
app:srlEnableLoadMore="false"> |
||||
|
||||
<androidx.recyclerview.widget.RecyclerView |
||||
android:id="@+id/recyclerView" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" |
||||
tools:itemCount="3" |
||||
tools:listitem="@layout/item_project_list" /> |
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout> |
||||
|
||||
<!-- <androidx.fragment.app.FragmentContainerView--> |
||||
<!-- android:id="@+id/container"--> |
||||
<!-- android:layout_width="match_parent"--> |
||||
<!-- android:layout_height="0dp"--> |
||||
<!-- android:layout_weight="1" />--> |
||||
<!-- <androidx.fragment.app.FragmentContainerView--> |
||||
<!-- android:id="@+id/container"--> |
||||
<!-- android:layout_width="match_parent"--> |
||||
<!-- android:layout_height="0dp"--> |
||||
<!-- android:layout_weight="1" />--> |
||||
|
||||
<!-- <com.flyco.tablayout.CommonTabLayout--> |
||||
<!-- android:id="@+id/tabLayout"--> |
||||
<!-- android:layout_width="match_parent"--> |
||||
<!-- android:layout_height="54dp"--> |
||||
<!-- android:background="@color/bg_color_main_tab"--> |
||||
<!-- tl:tl_iconHeight="23dp"--> |
||||
<!-- tl:tl_iconWidth="23dp"--> |
||||
<!-- tl:tl_indicator_height="0dp"--> |
||||
<!-- tl:tl_textSelectColor="@color/text_color_tab_selected"--> |
||||
<!-- tl:tl_textUnselectColor="@color/text_color_tab_unselected"--> |
||||
<!-- tl:tl_textsize="12sp"--> |
||||
<!-- tl:tl_underline_color="@color/bg_color_main_underline_color"--> |
||||
<!-- tl:tl_underline_gravity="TOP"--> |
||||
<!-- tl:tl_underline_height="0.5dp" />--> |
||||
<!-- <com.flyco.tablayout.CommonTabLayout--> |
||||
<!-- android:id="@+id/tabLayout"--> |
||||
<!-- android:layout_width="match_parent"--> |
||||
<!-- android:layout_height="54dp"--> |
||||
<!-- android:background="@color/bg_color_main_tab"--> |
||||
<!-- tl:tl_iconHeight="23dp"--> |
||||
<!-- tl:tl_iconWidth="23dp"--> |
||||
<!-- tl:tl_indicator_height="0dp"--> |
||||
<!-- tl:tl_textSelectColor="@color/text_color_tab_selected"--> |
||||
<!-- tl:tl_textUnselectColor="@color/text_color_tab_unselected"--> |
||||
<!-- tl:tl_textsize="12sp"--> |
||||
<!-- tl:tl_underline_color="@color/bg_color_main_underline_color"--> |
||||
<!-- tl:tl_underline_gravity="TOP"--> |
||||
<!-- tl:tl_underline_height="0.5dp" />--> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,44 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical"> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="30dp" |
||||
android:layout_marginHorizontal="16dp" |
||||
android:layout_marginVertical="7dp" |
||||
android:background="@drawable/bg_search" |
||||
android:gravity="center_vertical" |
||||
android:orientation="horizontal" |
||||
android:paddingHorizontal="18dp"> |
||||
|
||||
<ImageView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:src="@drawable/ic_search" /> |
||||
|
||||
<EditText |
||||
android:id="@+id/etSearch" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:background="@null" |
||||
android:hint="请输入" |
||||
android:imeOptions="actionSearch" |
||||
android:inputType="text" |
||||
android:paddingHorizontal="6dp" |
||||
android:singleLine="true" |
||||
android:textColor="@color/text_color_1" |
||||
android:textColorHint="@color/text_color_2" |
||||
android:textSize="11sp" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
<View |
||||
android:layout_width="match_parent" |
||||
android:layout_height="2dp" |
||||
android:background="@drawable/bg_search_shadow_2" /> |
||||
|
||||
</LinearLayout> |
||||
|
Loading…
Reference in new issue