Author: Adam Pioterek <adam.pioterek@protonmail.ch>
departures loading and empty state
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt b/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt index 1a526976df5df7f157d702d84ca19966c4d23328..90ec0eeb951bc1022bbea28479cf78c72a499416 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/activities/StopActivity.kt @@ -142,6 +142,7 @@ favourite!!.subscribeForDepartures(this, context) } override fun onDeparturesReady(departures: List<Departure>, plateId: Plate.ID?, code: Int) { + progressBar.visibility = View.GONE showError(stop_layout, code, this) if (plateId == null) { this.departures.clear() @@ -153,6 +154,15 @@ } if (timetableType == TIMETABLE_TYPE_FULL) return refreshAdapter() + if (adapter.departures?.isEmpty() != false) { + emptyStateIcon.visibility = View.VISIBLE + emptyStateText.visibility = View.VISIBLE + departuresList.visibility = View.GONE + } else { + emptyStateIcon.visibility = View.GONE + emptyStateText.visibility = View.GONE + departuresList.visibility = View.VISIBLE + } } private fun refreshAdapter() { diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/adapters/DeparturesAdapter.kt b/app/src/main/java/ml/adamsprogs/bimba/models/adapters/DeparturesAdapter.kt index b24b3736b730449f795d3adfa9b994cf8428c67b..0ee09a73d37a03a364fde72c3a6dd229c96d694d 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/models/adapters/DeparturesAdapter.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/models/adapters/DeparturesAdapter.kt @@ -18,23 +18,10 @@ class DeparturesAdapter(val context: Context, var departures: List<Departure>?, var relativeTime: Boolean) : androidx.recyclerview.widget.RecyclerView.Adapter<DeparturesAdapter.ViewHolder>() { - companion object { - const val VIEW_TYPE_LOADING: Int = 0 - const val VIEW_TYPE_CONTENT: Int = 1 - } - override fun getItemCount(): Int { if (departures == null || departures!!.isEmpty()) return 1 return departures!!.size - } - - override fun getItemViewType(position: Int): Int { - return when { - departures == null -> VIEW_TYPE_LOADING //empty - departures!!.isEmpty() -> VIEW_TYPE_LOADING - else -> VIEW_TYPE_CONTENT - } } override fun onBindViewHolder(holder: ViewHolder, position: Int) { diff --git a/app/src/main/res/drawable/ic_traffic.xml b/app/src/main/res/drawable/ic_traffic.xml new file mode 100644 index 0000000000000000000000000000000000000000..081757364d3c63690943ab9b31d5c4109f420e2b --- /dev/null +++ b/app/src/main/res/drawable/ic_traffic.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="@color/textDark" + android:pathData="M20,10h-3L17,8.86c1.72,-0.45 3,-2 3,-3.86h-3L17,4c0,-0.55 -0.45,-1 -1,-1L8,3c-0.55,0 -1,0.45 -1,1v1L4,5c0,1.86 1.28,3.41 3,3.86L7,10L4,10c0,1.86 1.28,3.41 3,3.86L7,15L4,15c0,1.86 1.28,3.41 3,3.86L7,20c0,0.55 0.45,1 1,1h8c0.55,0 1,-0.45 1,-1v-1.14c1.72,-0.45 3,-2 3,-3.86h-3v-1.14c1.72,-0.45 3,-2 3,-3.86zM12,19c-1.11,0 -2,-0.9 -2,-2s0.89,-2 2,-2c1.1,0 2,0.9 2,2s-0.89,2 -2,2zM12,14c-1.11,0 -2,-0.9 -2,-2s0.89,-2 2,-2c1.1,0 2,0.9 2,2s-0.89,2 -2,2zM12,9c-1.11,0 -2,-0.9 -2,-2 0,-1.11 0.89,-2 2,-2 1.1,0 2,0.89 2,2 0,1.1 -0.89,2 -2,2z"/> +</vector> diff --git a/app/src/main/res/layout/activity_dash.xml b/app/src/main/res/layout/activity_dash.xml index d0823ba430d5269b6015012226f003dea7223b0c..ee61d3aafc6658f882403f31ff3fa60cb9e2631a 100644 --- a/app/src/main/res/layout/activity_dash.xml +++ b/app/src/main/res/layout/activity_dash.xml @@ -55,7 +55,6 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:mt_hint="@string/search_placeholder" - app:mt_maxSuggestionsCount="10" app:mt_navIconEnabled="true" app:mt_placeholder="@string/search_placeholder" app:mt_roundedSearchBarEnabled="true" diff --git a/app/src/main/res/layout/activity_stop.xml b/app/src/main/res/layout/activity_stop.xml index 21c4be62306b15bf15e00e47911dc77042030cb4..baf078918f5baf2a93b57ddfa86ed2b14d42b34e 100644 --- a/app/src/main/res/layout/activity_stop.xml +++ b/app/src/main/res/layout/activity_stop.xml @@ -9,6 +9,49 @@ android:fitsSystemWindows="true" tools:context="ml.adamsprogs.bimba.activities.StopActivity"> + <ImageView + android:id="@+id/emptyStateIcon" + 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" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/appbar" + app:srcCompat="@drawable/ic_traffic" + android:visibility="gone" + android:contentDescription="@string/departures_empty_state_icon" /> + + <TextView + android:id="@+id/emptyStateText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:text="@string/no_departures" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + android:visibility="gone" + app:layout_constraintTop_toBottomOf="@+id/emptyStateIcon" /> + + <ProgressBar + android:id="@+id/progressBar" + style="?android:attr/progressBarStyle" + 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" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/appbar" /> + <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" @@ -47,6 +90,7 @@android:id="@+id/departuresList" android:layout_width="0dp" android:layout_height="0dp" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e4653b4fd15ae5c8ee399dd5e536d433ae6c48f0..88c0ef9490f6e2d0b91f440edd01389e43037b8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -68,4 +68,5 @@ Automatically check for and download timetable updates <string name="server_error">Server error</string> <string name="suggestion_row_image" translatable="false">suggestion row image</string> <string name="nothing_found">Nothing found</string> + <string name="departures_empty_state_icon" translatable="false">departures empty state icon</string> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f565d9510e50b34a281ea802147490070f4e7acf..b957c902a4f271f8a32a4ccb889929ea847c6e6b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -24,6 +24,10 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> + <item name="mt_handlesTintEnabled">true</item> + <item name="mt_leftTextSelectorTint">@color/colorAccent</item> + <item name="mt_rightTextSelectorTint">@color/colorAccent</item> + <item name="mt_middleTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> @drawable/ic_texthandle_start </item> diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index bd618948b05adc10285137774305e9f390997f1f..471cf22213b51f84eff2aca9f8e51a90fca5adbf 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -8,6 +8,10 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> + <item name="mt_handlesTintEnabled">true</item> + <item name="mt_leftTextSelectorTint">@color/colorAccent</item> + <item name="mt_rightTextSelectorTint">@color/colorAccent</item> + <item name="mt_middleTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> @drawable/ic_texthandle_start </item> diff --git a/app/src/main/res/values-notnight/styles.xml b/app/src/main/res/values-notnight/styles.xml index aabb27040d3506702ab96ae5b140c8dbb670f122..91c96a627f637c75c0a16c6de17ca84e7963284f 100644 --- a/app/src/main/res/values-notnight/styles.xml +++ b/app/src/main/res/values-notnight/styles.xml @@ -8,6 +8,10 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> + <item name="mt_handlesTintEnabled">true</item> + <item name="mt_leftTextSelectorTint">@color/colorAccent</item> + <item name="mt_rightTextSelectorTint">@color/colorAccent</item> + <item name="mt_middleTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> @drawable/ic_texthandle_start </item> diff --git a/todo b/todo index c3e273d3fa766894a60097822e9ee72a7f70048c..62196df2b060dc659ca9f94b58289aaca79c3dfe 100644 --- a/todo +++ b/todo @@ -4,11 +4,11 @@ - sort search results - search results loading [?] - search results history [?] v shed loading -- departures loading -- departures empty +v departures loading +v departures empty - search result retry - shed retry - departures retry -- ripples android:background="?android:attr/selectableItemBackground" x search results flickering - favourite cache +- in a moment