@ -0,0 +1,35 @@ |
||||
package net.pokeranalytics.android.ui.view |
||||
|
||||
import androidx.annotation.Nullable |
||||
import androidx.recyclerview.widget.DiffUtil |
||||
import net.pokeranalytics.android.ui.adapter.components.RowRepresentableDataSource |
||||
|
||||
class RowRepresentableDiffCallback( |
||||
var newRows: List<RowRepresentable>, var oldRows: List<RowRepresentable>, |
||||
var rowRepresentableDataSource: RowRepresentableDataSource |
||||
) : |
||||
DiffUtil.Callback() { |
||||
|
||||
override fun getOldListSize(): Int { |
||||
return oldRows.size |
||||
} |
||||
|
||||
override fun getNewListSize(): Int { |
||||
return newRows.size |
||||
} |
||||
|
||||
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { |
||||
return oldRows[oldItemPosition] === newRows[newItemPosition] |
||||
} |
||||
|
||||
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { |
||||
// Force to update all the rows that were already there |
||||
return false |
||||
} |
||||
|
||||
@Nullable |
||||
override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? { |
||||
//you can return particular field for changed item. |
||||
return super.getChangePayload(oldItemPosition, newItemPosition) |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@ |
||||
package net.pokeranalytics.android.ui.view |
||||
|
||||
import android.content.Context |
||||
import android.graphics.PointF |
||||
import android.util.DisplayMetrics |
||||
import androidx.recyclerview.widget.LinearLayoutManager |
||||
import androidx.recyclerview.widget.LinearSmoothScroller |
||||
import androidx.recyclerview.widget.RecyclerView |
||||
|
||||
/** |
||||
* SmoothScrollLinearLayoutManager |
||||
*/ |
||||
class SmoothScrollLinearLayoutManager(context: Context) : |
||||
LinearLayoutManager(context, RecyclerView.VERTICAL, false) { |
||||
|
||||
companion object { |
||||
private const val MILLISECONDS_PER_INCH = 100f |
||||
} |
||||
|
||||
override fun smoothScrollToPosition( |
||||
recyclerView: RecyclerView, state: RecyclerView.State?, |
||||
position: Int |
||||
) { |
||||
val smoothScroller = TopSnappedSmoothScroller(recyclerView.context) |
||||
smoothScroller.targetPosition = position |
||||
startSmoothScroll(smoothScroller) |
||||
} |
||||
|
||||
private inner class TopSnappedSmoothScroller(context: Context) : LinearSmoothScroller(context) { |
||||
|
||||
override fun computeScrollVectorForPosition(targetPosition: Int): PointF? { |
||||
return this@SmoothScrollLinearLayoutManager |
||||
.computeScrollVectorForPosition(targetPosition) |
||||
} |
||||
|
||||
override fun getVerticalSnapPreference(): Int { |
||||
return SNAP_TO_START |
||||
} |
||||
|
||||
override fun calculateSpeedPerPixel(displayMetrics: DisplayMetrics): Float { |
||||
return MILLISECONDS_PER_INCH / displayMetrics.densityDpi |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,72 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.appcompat.widget.LinearLayoutCompat 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:id="@+id/rowHeaderTitleValue.container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical"> |
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="@color/green_header"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/rowHeaderTitleValue.title" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowTitle" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Title" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/rowHeaderTitleValue.value" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowValue" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:ellipsize="end" |
||||
android:gravity="end" |
||||
android:maxLines="1" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" |
||||
app:layout_constraintStart_toEndOf="@+id/rowHeaderTitleValue.title" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Value" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="16dp" /> |
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
|
||||
|
||||
<FrameLayout |
||||
android:id="@+id/rowHeaderTitleValue.separator" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp" |
||||
android:visibility="gone" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
tools:visibility="visible" /> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
@ -0,0 +1,9 @@ |
||||
<?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:id="@+id/container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp"> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -1,44 +0,0 @@ |
||||
<?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:id="@+id/container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground" |
||||
android:padding="16dp"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/title" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="8dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:textSize="18sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintHorizontal_bias="0.0" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Title" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/value" |
||||
android:layout_width="0dp" |
||||
android:layout_height="16dp" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="8dp" |
||||
android:layout_marginEnd="8dp" |
||||
android:layout_marginBottom="8dp" |
||||
android:ellipsize="end" |
||||
android:gravity="end" |
||||
android:maxLines="1" |
||||
android:textSize="14sp" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toEndOf="@+id/title" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Value" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
@ -1,40 +1,78 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
<androidx.appcompat.widget.LinearLayoutCompat 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:id="@+id/container" |
||||
android:id="@+id/rowTitleValue.container" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground" |
||||
android:paddingStart="16dp" |
||||
android:paddingEnd="16dp"> |
||||
android:orientation="vertical"> |
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:background="?selectableItemBackground"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/title" |
||||
android:id="@+id/rowTitleValue.title" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowTitle" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowTitle" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintHorizontal_bias="0.0" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintStart_toStartOf="@+id/guidelineStart" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Title" /> |
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView |
||||
android:id="@+id/value" |
||||
android:id="@+id/rowTitleValue.value" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowValue" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:ellipsize="end" |
||||
android:gravity="end" |
||||
android:maxLines="1" |
||||
style="@style/PokerAnalyticsTheme.TextView.RowValue" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toEndOf="@+id/title" |
||||
app:layout_constraintEnd_toEndOf="@+id/guidelineEnd" |
||||
app:layout_constraintStart_toEndOf="@+id/rowTitleValue.title" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="Value" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineStart" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_begin="16dp" /> |
||||
|
||||
<androidx.constraintlayout.widget.Guideline |
||||
android:id="@+id/guidelineEnd" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
app:layout_constraintGuide_end="16dp" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
|
||||
<FrameLayout |
||||
android:id="@+id/rowTitleValue.separator" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="16dp" |
||||
android:visibility="gone" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
tools:visibility="visible"> |
||||
|
||||
<View |
||||
android:layout_width="match_parent" |
||||
android:layout_height="1dp" |
||||
android:layout_gravity="center" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:background="@color/kaki" /> |
||||
|
||||
</FrameLayout> |
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat> |
||||
@ -1,5 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<background android:drawable="@drawable/ic_launcher_background"/> |
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> |
||||
</adaptive-icon> |
||||
@ -1,5 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<background android:drawable="@drawable/ic_launcher_background"/> |
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> |
||||
</adaptive-icon> |
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 42 KiB |