-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add select all and select nothing to records filter
- Loading branch information
Showing
13 changed files
with
756 additions
and
242 deletions.
There are no files selected for viewing
This file contains 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
25 changes: 25 additions & 0 deletions
25
...ample/util/simpletimetracker/feature_base_adapter/emptySpace/EmptySpaceAdapterDelegate.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.util.simpletimetracker.feature_base_adapter.emptySpace | ||
|
||
import com.example.util.simpletimetracker.domain.extension.tryCast | ||
import com.example.util.simpletimetracker.feature_base_adapter.createRecyclerBindingAdapterDelegate | ||
import com.example.util.simpletimetracker.feature_views.extension.dpToPx | ||
import com.google.android.flexbox.FlexboxLayoutManager | ||
import com.example.util.simpletimetracker.feature_base_adapter.databinding.ItemEmptySpaceLayoutBinding as Binding | ||
import com.example.util.simpletimetracker.feature_base_adapter.emptySpace.EmptySpaceViewData as ViewData | ||
|
||
fun createEmptySpaceAdapterDelegate() = createRecyclerBindingAdapterDelegate<ViewData, Binding>( | ||
Binding::inflate, | ||
) { binding, item, _ -> | ||
|
||
with(binding.root) { | ||
item as ViewData | ||
|
||
layoutParams | ||
.tryCast<FlexboxLayoutManager.LayoutParams>() | ||
?.apply { | ||
width = item.widthDp.dpToPx() | ||
height = item.heightDp.dpToPx() | ||
isWrapBefore = item.wrapBefore | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../com/example/util/simpletimetracker/feature_base_adapter/emptySpace/EmptySpaceViewData.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.example.util.simpletimetracker.feature_base_adapter.emptySpace | ||
|
||
import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType | ||
|
||
data class EmptySpaceViewData( | ||
val id: Long, | ||
val widthDp: Int = 0, | ||
val heightDp: Int = 0, | ||
val wrapBefore: Boolean = false, | ||
) : ViewHolderType { | ||
|
||
override fun getUniqueId(): Long = id | ||
|
||
override fun isValidType(other: ViewHolderType): Boolean = | ||
other is EmptySpaceViewData | ||
} |
21 changes: 21 additions & 0 deletions
21
.../simpletimetracker/feature_base_adapter/selectionButton/SelectionButtonAdapterDelegate.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.util.simpletimetracker.feature_base_adapter.selectionButton | ||
|
||
import com.example.util.simpletimetracker.feature_base_adapter.createRecyclerBindingAdapterDelegate | ||
import com.example.util.simpletimetracker.feature_views.extension.setOnClickWith | ||
import com.example.util.simpletimetracker.feature_base_adapter.databinding.ItemSelectionButtonLayoutBinding as Binding | ||
import com.example.util.simpletimetracker.feature_base_adapter.selectionButton.SelectionButtonViewData as ViewData | ||
|
||
fun createSelectionButtonAdapterDelegate( | ||
onItemClick: ((ViewData) -> Unit), | ||
) = createRecyclerBindingAdapterDelegate<ViewData, Binding>( | ||
Binding::inflate, | ||
) { binding, item, _ -> | ||
|
||
with(binding) { | ||
item as ViewData | ||
|
||
root.setCardBackgroundColor(item.color) | ||
tvSelectionButtonItemName.text = item.name | ||
root.setOnClickWith(item, onItemClick) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...le/util/simpletimetracker/feature_base_adapter/selectionButton/SelectionButtonViewData.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.util.simpletimetracker.feature_base_adapter.selectionButton | ||
|
||
import androidx.annotation.ColorInt | ||
import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType | ||
|
||
class SelectionButtonViewData( | ||
val type: Type, | ||
val name: String, | ||
@ColorInt val color: Int, | ||
) : ViewHolderType { | ||
|
||
// Only one add item on screen | ||
override fun getUniqueId(): Long = 1L | ||
|
||
override fun isValidType(other: ViewHolderType): Boolean = | ||
other is SelectionButtonViewData && other.type == type | ||
|
||
interface Type | ||
} |
5 changes: 5 additions & 0 deletions
5
features/feature_base_adapter/src/main/res/layout/item_empty_space_layout.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<View xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/viewEmptySpaceItem" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> |
37 changes: 37 additions & 0 deletions
37
features/feature_base_adapter/src/main/res/layout/item_selection_button_layout.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.cardview.widget.CardView 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="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:cardBackgroundColor="@color/black" | ||
app:cardCornerRadius="@dimen/record_type_card_corner_radius" | ||
app:cardElevation="@dimen/record_type_card_elevation" | ||
app:cardPreventCornerOverlap="false" | ||
app:cardUseCompatPadding="true"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:background="?selectableItemBackground" | ||
android:paddingHorizontal="4dp"> | ||
|
||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/tvSelectionButtonItemName" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:paddingVertical="12dp" | ||
android:textColor="?appLightTextColor" | ||
android:textStyle="bold" | ||
app:layout_constrainedWidth="true" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="Item name" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.cardview.widget.CardView> |
Oops, something went wrong.