Skip to content

Commit

Permalink
Optimisation: Replacing listView in CarSelectionActivity with Recycle…
Browse files Browse the repository at this point in the history
…r View having well designed Cardviews (#1012)

* Replace ListView to RecyclerView

* Add CardView In CarSelectionList

* Add CardView Corner radius in dimens.xml
  • Loading branch information
Jdbarad authored Jan 6, 2025
1 parent 45be0d4 commit c74a576
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 228 deletions.
12 changes: 6 additions & 6 deletions org.envirocar.app/res/layout/activity_car_selection_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
with the enviroCar app. If not, see http://www.gnu.org/licenses/.
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/activity_car_selection_layout_content"
<androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/activity_car_selection_layout_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">

<LinearLayout
android:orientation="vertical"
Expand Down Expand Up @@ -99,11 +99,11 @@
<!--android:visibility="invisible"/>-->
</LinearLayout>

<ListView
android:id="@+id/activity_car_selection_layout_carlist"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/activity_car_selection_layout_car_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
tools:listitem="@layout/activity_car_selection_layout_carlist_entry"
android:divider="#00000000"
android:padding="@dimen/spacing_medium"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,39 @@
You should have received a copy of the GNU General Public License along
with the enviroCar app. If not, see http://www.gnu.org/licenses/.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="64dp"
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/cardview_corner_radius"
android:elevation="16dp"
android:layout_marginTop="@dimen/spacing_small"
android:layout_marginLeft="@dimen/spacing_small"
android:layout_marginRight="@dimen/spacing_small">

<ImageView
android:id="@+id/activity_car_selection_layout_carlist_entry_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/spacing_medium"
android:alpha="0.54"
android:src="@drawable/ic_drive_eta_black_24dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:orientation="vertical">

<RadioButton
android:id="@+id/activity_car_selection_layout_carlist_entry_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginLeft="8dp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_centerInParent="true"
android:layout_toLeftOf="@id/activity_car_selection_layout_carlist_entry_radio"
android:layout_toRightOf="@id/activity_car_selection_layout_carlist_entry_icon"
android:orientation="horizontal"
android:paddingLeft="8dp">
<ImageView
android:id="@+id/activity_car_selection_layout_carlist_entry_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/spacing_medium"
android:alpha="0.54"
android:src="@drawable/ic_drive_eta_black_24dp" />

<RadioButton
android:id="@+id/activity_car_selection_layout_carlist_entry_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginLeft="8dp" />

<LinearLayout
android:layout_width="wrap_content"
Expand All @@ -56,61 +54,65 @@
android:layout_centerInParent="true"
android:layout_toLeftOf="@id/activity_car_selection_layout_carlist_entry_radio"
android:layout_toRightOf="@id/activity_car_selection_layout_carlist_entry_icon"
android:layout_weight="1"
android:orientation="vertical">

android:orientation="horizontal"
android:paddingLeft="8dp">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/activity_car_selection_layout_carlist_entry_firstline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:fontFamily="@font/roboto_medium"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="@string/dashboard_carselection_no_car_selected"
android:textColor="#000000"
app:autoSizeMaxTextSize="20sp"
app:autoSizeMinTextSize="15sp"
app:autoSizeTextType="uniform" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/activity_car_selection_layout_carlist_entry_secondline"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto"
android:singleLine="true"
android:text="@string/dashboard_carselection_no_car_selected_advise"
android:textColor="#000000"
app:autoSizeMaxTextSize="15sp"
app:autoSizeMinTextSize="7sp"
app:autoSizeTextType="uniform" />
android:layout_alignWithParentIfMissing="true"
android:layout_centerInParent="true"
android:layout_toLeftOf="@id/activity_car_selection_layout_carlist_entry_radio"
android:layout_toRightOf="@id/activity_car_selection_layout_carlist_entry_icon"
android:layout_weight="1"
android:orientation="vertical">

</LinearLayout>

<ImageButton
android:id="@+id/activity_car_selection_layout_carlist_delete_icon"
style="?attr/borderlessButtonStyle"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical|right"
android:alpha="0.54"
android:background="?selectableItemBackgroundBorderless"
android:gravity="right"
android:src="@drawable/ic_delete_black_24dp"
android:visibility="visible" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/activity_car_selection_layout_carlist_entry_firstline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:fontFamily="@font/roboto_medium"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="@string/dashboard_carselection_no_car_selected"
android:textColor="#000000"
app:autoSizeMaxTextSize="20sp"
app:autoSizeMinTextSize="15sp"
app:autoSizeTextType="uniform" />

</LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/activity_car_selection_layout_carlist_entry_secondline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto"
android:singleLine="true"
android:text="@string/dashboard_carselection_no_car_selected_advise"
android:textColor="#000000"
app:autoSizeMaxTextSize="15sp"
app:autoSizeMinTextSize="7sp"
app:autoSizeTextType="uniform" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@id/activity_car_selection_layout_carlist_entry_icon"
android:background="@color/envirocar_color_divider_grey" />
</LinearLayout>

<ImageButton
android:id="@+id/activity_car_selection_layout_carlist_delete_icon"
style="?attr/borderlessButtonStyle"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical|right"
android:alpha="0.54"
android:background="?selectableItemBackgroundBorderless"
android:gravity="right"
android:src="@drawable/ic_delete_black_24dp"
android:visibility="visible" />

</LinearLayout>

</RelativeLayout>

</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
1 change: 1 addition & 0 deletions org.envirocar.app/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
<dimen name="fab_margin_download_button_top">16dp</dimen>

<dimen name="dashboard_selector">57dp</dimen>
<dimen name="cardview_corner_radius">4dp</dimen>

</resources>
Loading

0 comments on commit c74a576

Please sign in to comment.