-
-
Save JobGetabu/4058f7d355895d706f222964d00e762e to your computer and use it in GitHub Desktop.
Folding cell implementation like car wash cell
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <com.ramotion.foldingcell.FoldingCell xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:folding-cell="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| folding-cell:additionalFlipsCount="4" | |
| folding-cell:animationDuration="1300" | |
| folding-cell:backSideColor="@color/bgBackSideColor" | |
| folding-cell:cameraHeight="30" | |
| android:cursorVisible="false" | |
| > | |
| <!-- CONTENT (UNFOLDED) LAYOUT (MUST BE AT LEAST 2x times BIGGER than content layout bellow)--> | |
| <include layout="@layout/cell_expand" /> | |
| <!-- TITLE (FOLDED) LAYOUT (MUST BE AT LEAST 2x times SMALLER than content layout above) --> | |
| <include layout="@layout/item_collapse" /> | |
| </com.ramotion.foldingcell.FoldingCell> |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout 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" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:orientation="vertical" | |
| android:visibility="gone"> | |
| <!-- content body layout --> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@color/bgContent" | |
| android:orientation="vertical" | |
| android:paddingBottom="6dp" | |
| android:paddingLeft="20dp" | |
| android:paddingRight="20dp" | |
| android:paddingTop="9dp"> | |
| <!-- avatar and name part --> | |
| <RelativeLayout | |
| android:layout_width="wrap_content" | |
| android:layout_height="match_parent"> | |
| <TextView | |
| android:id="@+id/content_avatar_title" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:layout_marginBottom="5dp" | |
| android:text="Client" /> | |
| <ImageView | |
| android:id="@+id/content_avatar" | |
| android:layout_width="50dp" | |
| android:layout_height="50dp" | |
| android:layout_below="@id/content_avatar_title" | |
| android:scaleType="centerCrop" | |
| android:src="@drawable/avatar" /> | |
| <TextView | |
| android:id="@+id/cell_name" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignTop="@id/content_avatar" | |
| android:layout_marginBottom="2dp" | |
| android:layout_marginLeft="10dp" | |
| android:layout_marginStart="10dp" | |
| android:layout_toEndOf="@id/content_avatar" | |
| android:layout_toRightOf="@id/content_avatar" | |
| android:text="Client Name" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" /> | |
| <me.zhanghai.android.materialratingbar.MaterialRatingBar | |
| android:id="@+id/cell_rating_stars" | |
| style="@style/Widget.MaterialRatingBar.RatingBar.Indicator.Small" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/cell_name" | |
| android:layout_alignStart="@id/cell_name" | |
| android:layout_below="@id/cell_name" | |
| /> | |
| <TextView | |
| android:id="@+id/cell_rating_nums" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignBottom="@+id/cell_rating_stars" | |
| android:layout_marginBottom="-2dp" | |
| android:layout_marginLeft="3dp" | |
| android:layout_marginStart="3dp" | |
| android:layout_toEndOf="@id/cell_rating_stars" | |
| android:layout_toRightOf="@id/cell_rating_stars" | |
| android:text="@string/rating_mock" | |
| android:textColor="@color/contentBadgeTitle" | |
| android:textSize="12sp" /> | |
| <ImageView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentEnd="true" | |
| android:layout_alignParentRight="true" | |
| android:layout_centerVertical="true" | |
| app:srcCompat="@drawable/ic_arrow_right" /> | |
| </RelativeLayout> | |
| <!-- divider line --> | |
| <ImageView | |
| android:layout_width="match_parent" | |
| android:layout_height="1dp" | |
| android:layout_marginBottom="6dp" | |
| android:layout_marginTop="9dp" | |
| android:src="@color/contentDividerLine" /> | |
| <!-- wash history part --> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:baselineAligned="false" | |
| android:orientation="horizontal"> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_from_badge" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Last wash" /> | |
| <TextView | |
| android:id="@+id/cell_date" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_from_badge" | |
| android:layout_alignStart="@id/content_from_badge" | |
| android:layout_below="@id/content_from_badge" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" | |
| tools:text="SAT 26" /> | |
| <TextView | |
| android:id="@+id/cell_year" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/cell_date" | |
| android:layout_alignStart="@id/cell_date" | |
| android:layout_below="@id/cell_date" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="14sp" | |
| tools:text="2018" /> | |
| </RelativeLayout> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_to_badge" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Visits" /> | |
| <TextView | |
| android:id="@+id/cell_visits" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_to_badge" | |
| android:layout_alignStart="@id/content_to_badge" | |
| android:layout_below="@id/content_to_badge" | |
| tools:text="5" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" /> | |
| <TextView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/cell_visits" | |
| android:layout_alignStart="@id/cell_visits" | |
| android:layout_below="@id/cell_visits" | |
| android:text="To date" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="14sp" /> | |
| <ImageView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentEnd="true" | |
| android:layout_centerVertical="true" | |
| app:srcCompat="@drawable/ic_arrow_right" /> | |
| </RelativeLayout> | |
| </LinearLayout> | |
| <!-- divider line --> | |
| <ImageView | |
| android:layout_width="match_parent" | |
| android:layout_height="1dp" | |
| android:layout_marginBottom="6dp" | |
| android:layout_marginTop="7dp" | |
| android:src="@color/contentDividerLine" /> | |
| <!-- vehicle wash part --> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:baselineAligned="false" | |
| android:orientation="horizontal"> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_from_badge1" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Type of Vehicle" /> | |
| <TextView | |
| android:id="@+id/cell_type_vehicle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_from_badge1" | |
| android:layout_alignStart="@id/content_from_badge1" | |
| android:layout_below="@id/content_from_badge1" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" | |
| tools:text="Motobike" /> | |
| </RelativeLayout> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_to_badge1" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Cost" /> | |
| <TextView | |
| android:id="@+id/cell_cost" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_to_badge1" | |
| android:layout_alignStart="@id/content_to_badge1" | |
| android:layout_below="@id/content_to_badge1" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" | |
| tools:text="KES 250" /> | |
| <ImageView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentEnd="true" | |
| android:layout_centerVertical="true" | |
| app:srcCompat="@drawable/ic_arrow_right" /> | |
| </RelativeLayout> | |
| </LinearLayout> | |
| <!-- divider line --> | |
| <ImageView | |
| android:layout_width="match_parent" | |
| android:layout_height="1dp" | |
| android:layout_marginBottom="6dp" | |
| android:layout_marginTop="7dp" | |
| android:src="@color/contentDividerLine" /> | |
| <!-- vehicle reg part --> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:baselineAligned="false" | |
| android:orientation="horizontal"> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_from_badge11" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Vehicle Registration" /> | |
| <TextView | |
| android:id="@+id/cell_vehicle_reg" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_from_badge11" | |
| android:layout_alignStart="@id/content_from_badge11" | |
| android:layout_below="@id/content_from_badge11" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" | |
| tools:text="KAR 102A" /> | |
| </RelativeLayout> | |
| <RelativeLayout | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_weight="1"> | |
| <TextView | |
| android:id="@+id/content_to_badge11" | |
| style="@style/ContentMainBadgeTitle" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentLeft="true" | |
| android:layout_alignParentStart="true" | |
| android:text="Free Washes" /> | |
| <TextView | |
| android:id="@+id/cell_coupon" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@id/content_to_badge11" | |
| android:layout_alignStart="@id/content_to_badge11" | |
| android:layout_below="@id/content_to_badge11" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="18sp" | |
| android:textStyle="bold" | |
| tools:text="2" /> | |
| <ImageView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentEnd="true" | |
| android:layout_centerVertical="true" | |
| app:srcCompat="@drawable/ic_arrow_right" /> | |
| </RelativeLayout> | |
| </LinearLayout> | |
| <!-- divider line --> | |
| <ImageView | |
| android:layout_width="match_parent" | |
| android:layout_height="1dp" | |
| android:layout_marginBottom="6dp" | |
| android:layout_marginTop="7dp" | |
| android:src="@color/contentDividerLine" /> | |
| <!-- request button --> | |
| <TextView | |
| android:id="@+id/cell_add_btn" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_marginTop="16dp" | |
| android:background="@color/btnRequest" | |
| android:padding="10dp" | |
| android:text="Add Entry" | |
| android:textAlignment="center" | |
| android:textColor="@color/mainTextColor" | |
| android:textSize="20sp" /> | |
| <TextView | |
| android:id="@+id/cell_info" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_marginTop="4dp" | |
| android:textAlignment="center" | |
| android:textColor="@color/contentBadgeTitle" | |
| android:textSize="12sp" | |
| tools:text="1 wash entry left to get free wash" /> | |
| </LinearLayout> | |
| </LinearLayout> |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <RelativeLayout 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="wrap_content" | |
| android:background="?attr/selectableItemBackground" | |
| android:orientation="vertical" | |
| android:padding="8dp"> | |
| <ImageView | |
| android:id="@+id/item_col_image" | |
| android:layout_width="60dp" | |
| android:layout_height="60dp" | |
| android:scaleType="centerCrop" | |
| android:background="#757575" | |
| android:tint="#232323" | |
| app:srcCompat="@drawable/ic_car" /> | |
| <TextView | |
| android:id="@+id/item_col_name" | |
| style="@style/AppTheme.Subheader" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignTop="@+id/item_col_image" | |
| android:layout_marginBottom="4dp" | |
| android:layout_marginLeft="8dp" | |
| android:layout_marginTop="-2dp" | |
| android:layout_toLeftOf="@+id/item_col_price" | |
| android:layout_toRightOf="@+id/item_col_image" | |
| android:ellipsize="end" | |
| android:maxLines="1" | |
| tools:text="Client Name" /> | |
| <me.zhanghai.android.materialratingbar.MaterialRatingBar | |
| android:id="@+id/item_col_rating" | |
| style="@style/Widget.MaterialRatingBar.RatingBar.Indicator.Small" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:numStars="5" | |
| android:layout_alignLeft="@+id/item_col_name" | |
| android:layout_below="@+id/item_col_name" | |
| android:layout_marginBottom="4dp" /> | |
| <TextView | |
| android:id="@+id/item_col_num_ratings" | |
| style="@style/AppTheme.Caption" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignBottom="@+id/item_col_rating" | |
| android:layout_alignTop="@+id/item_col_rating" | |
| android:layout_marginLeft="4dp" | |
| android:layout_toRightOf="@+id/item_col_rating" | |
| android:gravity="center_vertical" | |
| android:textColor="@color/greyDisabled" | |
| tools:text="(10)" /> | |
| <TextView | |
| android:id="@+id/item_col_phone" | |
| style="@style/AppTheme.Body1" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignLeft="@+id/item_col_name" | |
| android:layout_below="@+id/item_col_rating" | |
| android:text="Phone" | |
| android:textColor="@color/greySecondary" /> | |
| <TextView | |
| android:id="@+id/item_col_divider" | |
| style="@style/AppTheme.TextDivider" | |
| android:layout_alignTop="@+id/item_col_phone" | |
| android:layout_toRightOf="@+id/item_col_phone" | |
| android:text="@string/divider_bullet" /> | |
| <TextView | |
| android:id="@+id/item_col_phonenum" | |
| style="@style/AppTheme.Body1" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignTop="@+id/item_col_phone" | |
| android:layout_toRightOf="@+id/item_col_divider" | |
| android:textColor="@color/greySecondary" | |
| tools:text="0708440184" /> | |
| <TextView | |
| android:id="@+id/item_col_price" | |
| style="@style/AppTheme.Caption" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentRight="true" | |
| android:textColor="@color/greySecondary" | |
| tools:text="$$$" /> | |
| </RelativeLayout> |
This file contains hidden or 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
| private void setUpList() { | |
| FirestoreRecyclerOptions<CustomerInfo> options = new FirestoreRecyclerOptions.Builder<CustomerInfo>() | |
| .setQuery(mQuery, CustomerInfo.class) | |
| .build(); | |
| adapter = new FirestoreRecyclerAdapter<CustomerInfo, ClientViewHolder>(options) { | |
| @NonNull | |
| @Override | |
| public ClientViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |
| LayoutInflater vi = LayoutInflater.from(MainActivity.this); | |
| final FoldingCell cell = (FoldingCell) vi.inflate(R.layout.cell, parent, false); | |
| // attach click listener to folding cell | |
| cell.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { | |
| cell.toggle(false); | |
| } | |
| }); | |
| return new ClientViewHolder(cell); | |
| } | |
| @Override | |
| public void onBindViewHolder(@NonNull ClientViewHolder holder, int position, @NonNull CustomerInfo model) { | |
| holder.init(MainActivity.this, mFirestore); | |
| holder.setUpUiSmall(model); | |
| holder.setUpUiExpanded(model.getCustomerId()); | |
| Log.d(TAG, "onBindViewHolder: " + model.toString()); | |
| } | |
| @Override | |
| public void onDataChanged() { | |
| super.onDataChanged(); | |
| // Show/hide content if the query returns empty. | |
| if (getItemCount() == 0) { | |
| mainClientlist.setVisibility(View.GONE); | |
| viewEmpty.setVisibility(View.VISIBLE); | |
| } else { | |
| mainClientlist.setVisibility(View.VISIBLE); | |
| viewEmpty.setVisibility(View.GONE); | |
| } | |
| } | |
| @Override | |
| public void onError(FirebaseFirestoreException e) { | |
| // Show a snackbar on errors | |
| Snackbar.make(findViewById(android.R.id.content), | |
| "Error: check logs for info.", Snackbar.LENGTH_LONG).show(); | |
| Log.d(TAG, "onError: ", e); | |
| } | |
| @Override | |
| public void startListening() { | |
| super.startListening(); | |
| Log.d(TAG, "startListening: started "); | |
| } | |
| }; | |
| adapter.startListening(); | |
| adapter.notifyDataSetChanged(); | |
| mainClientlist.setAdapter(adapter); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment