This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.coordinatorlayout.widget.CoordinatorLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context="com.demon.android.demo.activity.SearchActivity"> | |
| <include layout="@layout/toolbar" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SeachActivity : AppCompatActivity() { | |
| lateinit var searchView: SearchView | |
| private val vm: SearchViewModel by viewModel() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.search_activity_layout) | |
| recyclerView.adapter = vm.adapter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SearchViewModel(): ViewModel(), KoinComponent { | |
| val datasource: DataSource by inject() | |
| val adapter: SearchRecyclerViewAdapter by inject { | |
| parametersOf(datasource.elements) | |
| } | |
| var searchOrder = SortOrder.ASCENDING | |
| set(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class DesiredObject(var text: String) | |
| class DataSource() { | |
| var elements: MutableArrayList<DesiredObject> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SearchRecyclerViewAdapter(var elements: ArrayList<DesiredObject>): | |
| RecyclerView.Adapter<SearchRecyclerViewAdapter.ViewHolder>() { | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
| val layout = LayoutInflater.from(parent.context) | |
| .inflate(R.layout.list_item, parent, false) | |
| return ViewHolder(layout) | |
| } | |
| override fun getItemCount(): Int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val searchViewActivityModule = module { | |
| viewModel { SearchViewModel() } | |
| factory { DataSource() } | |
| factory { (elements: ArrayList<DesiredObject>) -> SearchRecyclerViewAdapter(elements) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DemoApp : Application() { | |
| override fun onCreate() { | |
| super.onCreate() | |
| startKoin { | |
| androidContext(this@DemoApp) | |
| modules(searchViewActivityModule) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [versions] | |
| library-group = "com.my.library" | |
| library-version = "0.0.1" | |
| android = "8.0.2" | |
| kotlin = "1.8.20" | |
| kover = "0.6.1" | |
| ksp = "1.8.20-1.0.11" | |
| [libraries] | |
| kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "kotlin" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencyResolutionManagement { | |
| repositories { | |
| google() | |
| mavenCentral() | |
| } | |
| versionCatalogs { | |
| create("commonlibs") { | |
| from(files("./catalogs/common.versions.toml")) | |
| } | |
| } |