mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Feature/search on page. First iteration (#998)
This commit is contained in:
parent
4233273717
commit
004e49906c
41 changed files with 957 additions and 132 deletions
|
@ -19,12 +19,16 @@
|
|||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name=".DisabledAnimationActivity">
|
||||
<activity
|
||||
android:name=".search.SearchOnPageActivity"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".DisabledAnimationActivity" />
|
||||
<activity android:name=".ScrollAndMove" />
|
||||
<activity android:name=".StyleActivity" />
|
||||
<activity android:name=".MainActivity" />
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.anytypeio.anytype.sample.search
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.sample.R
|
||||
import kotlinx.android.synthetic.main.activity_search_on_page.*
|
||||
|
||||
class SearchOnPageActivity : AppCompatActivity(R.layout.activity_search_on_page) {
|
||||
|
||||
private val items = mutableListOf<SearchOnPageAdapter.Item>().apply {
|
||||
repeat(10) {
|
||||
add(
|
||||
SearchOnPageAdapter.Item(
|
||||
id = it,
|
||||
txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val mockAdapter = SearchOnPageAdapter(
|
||||
items = items
|
||||
)
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
recycler.apply {
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
adapter = mockAdapter
|
||||
}
|
||||
search.doOnTextChanged { text, start, before, count ->
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.anytypeio.anytype.sample.search
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.anytypeio.anytype.sample.R
|
||||
import com.anytypeio.anytype.sample.adapter.AbstractAdapter
|
||||
import com.anytypeio.anytype.sample.adapter.AbstractHolder
|
||||
import kotlinx.android.synthetic.main.item_editable.view.*
|
||||
|
||||
class SearchOnPageAdapter(
|
||||
private var items: List<Item>
|
||||
) : AbstractAdapter<SearchOnPageAdapter.Item>(items) {
|
||||
|
||||
override fun update(update: List<Item>) {
|
||||
this.items = update
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AbstractHolder<Item> {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val view = inflater.inflate(R.layout.item_editable, parent, false)
|
||||
return ItemViewHolder(view)
|
||||
}
|
||||
|
||||
data class Item(
|
||||
val id: Int,
|
||||
val txt: String
|
||||
)
|
||||
|
||||
class ItemViewHolder(view: View) : AbstractHolder<Item>(view) {
|
||||
override fun bind(item: Item) {
|
||||
itemView.input.setText(item.txt)
|
||||
}
|
||||
}
|
||||
}
|
35
sample/src/main/res/layout/activity_search_on_page.xml
Normal file
35
sample/src/main/res/layout/activity_search_on_page.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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=".search.SearchOnPageActivity">
|
||||
|
||||
<EditText
|
||||
android:fontFamily="monospace"
|
||||
android:id="@+id/search"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="monospace"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/search" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Add a link
Reference in a new issue