Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiscreteScrollView doesn't show for the first time #167

Open
samkazmi opened this issue May 3, 2019 · 2 comments
Open

DiscreteScrollView doesn't show for the first time #167

samkazmi opened this issue May 3, 2019 · 2 comments
Labels
can't reproduce Include please a sample project where I can reproduce the issue.

Comments

@samkazmi
Copy link

samkazmi commented May 3, 2019

Having a weird issue
Screenshot_20190503-123539
The RecyclerView Doesn't show for the first time when activity is open
But when i open the side menu (which is done in motionLayout) RecyclerView show up..

<com.yarolegovich.discretescrollview.DiscreteScrollView
            android:id="@+id/rvSmallList"
            android:layout_width="match_parent"
            android:layout_height="176dp"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="16dp"
            app:dsv_orientation="horizontal"
            tools:listitem="@layout/venue_item_small" />

ItemView is this
`

<data>

    <import type="incubasys.needcharge.base.RoundedCornersTransformation" />

    <import type="android.view.View" />
    <variable
        name="vm"
        type="incubasys.needcharge.home.vm.VenueItemViewModel" />
</data>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="165dp"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/venue_small_bg"
    android:elevation="2dp"
    android:orientation="horizontal"
    android:padding="12dp">


    <ImageView
        android:id="@+id/ivImage"
        cornerType="@{RoundedCornersTransformation.CornerType.DIFFERENT}"
        isRoundCorners="@{true}"
        placeholderRes="@{@drawable/venue_small_image_placeholder}"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:layout_centerVertical="true"
        android:layout_marginStart="4dp"
        android:src="@{@drawable/temp}"
        tools:src="@drawable/venue_small_image_placeholder" />

    <ImageView
        android:id="@+id/ivOpenClose"
        android:layout_width="15dp"
        android:layout_height="15dp"
        android:layout_alignTop="@id/ivImage"
        android:layout_marginTop="-4dp"
        android:src="@drawable/circle_open_bg" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/ivImage"
        android:paddingTop="8dp"
        android:layout_centerVertical="true"
        android:background="?selectableItemBackground"
        android:paddingBottom="8dp">

        <TextView
            android:id="@+id/tvName"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginBottom="8dp"
            android:layout_alignParentStart="true"
            android:layout_alignParentEnd="true"
            android:fontFamily="@font/sf_ui_medium"
            android:maxLines="1"
            android:singleLine="true"
            android:text="@{vm.venueItem.name}"
            android:textColor="@color/text_label_clr_on_home_bg"
            android:textSize="16sp"
            tools:text="Name of the Venue" />

        <TextView
            android:id="@+id/tvOpenClosed"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/tvName"
            android:layout_alignStart="@id/tvName"
            android:background="@{vm.venueItem.isOpen ? @drawable/open_bg : @drawable/close_bg}"
            android:fontFamily="@font/sf_ui_bold"
            android:gravity="center"
            android:paddingStart="12dp"
            android:paddingTop="4dp"
            android:paddingEnd="12dp"
            android:paddingBottom="4dp"
            android:singleLine="true"
            android:text="@{vm.venueItem.isOpen ? @string/open : @string/close}"
            android:textAllCaps="true"
            android:textColor="@{vm.venueItem.isOpen ? @color/open_green : @color/close_red}"
            android:textSize="12sp"
            tools:background="@drawable/open_bg"
            tools:text="Open"
            tools:textColor="@color/open_green" />

        <TextView
            android:id="@+id/tvTimings"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@id/tvOpenClosed"
            android:layout_alignBottom="@id/tvOpenClosed"
            android:layout_toEndOf="@id/tvOpenClosed"
            android:fontFamily="@font/sf_ui_regular"
            android:gravity="center"
            android:padding="4dp"
            android:singleLine="true"
            android:text="@{vm.venueItem.todayTiming}"
            android:textColor="@color/text_label_clr_on_home_bg"
            android:textSize="12sp"
            tools:text="Until 11PM TODAY" />

        <TextView
            android:id="@+id/tvVenueType"
            venueTypeToString="@{vm.venueItem.type}"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/tvOpenClosed"
            android:layout_alignStart="@id/tvName"
            android:fontFamily="@font/sf_ui_regular"
            android:gravity="center"
            android:paddingStart="0dp"
            android:paddingTop="4dp"
            android:paddingEnd="9dp"
            android:paddingBottom="4dp"
            android:singleLine="true"
            android:textColor="@color/text_label_clr_on_home_bg"
            android:textSize="13sp"
            tools:text="Restaurant" />

        <ImageView
            android:id="@+id/ivDistance"
            android:layout_width="11dp"
            android:layout_height="11dp"
            android:layout_below="@+id/tvVenueType"
            android:layout_alignStart="@id/tvName"
            android:layout_alignTop="@id/tvDistance"
            android:layout_alignBottom="@id/tvDistance"
            android:src="@drawable/ic_current_location"
            android:tint="@color/text_label_clr_on_home_bg" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/tvDistance"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tvVenueType"
            android:layout_toEndOf="@id/ivDistance"
            android:fontFamily="@font/sf_ui_regular"
            android:gravity="center"
            android:padding="4dp"
            android:text="@{@string/km_with_value(vm.venueItem.distance)}"
            android:textColor="@color/text_label_clr_on_home_bg"
            android:textSize="13sp"
            tools:text="0.22 Km" />

        <ImageView
            android:id="@+id/ivDuration"
            android:layout_width="15dp"
            android:layout_height="11dp"
            android:layout_below="@+id/tvVenueType"
            android:layout_alignTop="@id/tvDuration"
            android:layout_alignBottom="@id/tvDuration"
            android:layout_marginStart="5dp"
            android:layout_marginEnd="0dp"
            android:layout_toEndOf="@id/tvDistance"
            android:src="@drawable/ic_directions_run_black_24dp"
            android:tint="@color/text_label_clr_on_home_bg" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/tvDuration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tvVenueType"
            android:layout_toEndOf="@id/ivDuration"
            android:fontFamily="@font/sf_ui_regular"
            android:gravity="center"
            android:padding="4dp"
            android:text="@{@plurals/duration(((int)vm.venueItem.duration), vm.venueItem.duration)}"
            android:textColor="@color/text_label_clr_on_home_bg"
            android:textSize="13sp"
            tools:text="5 mints" />

    </RelativeLayout>
</RelativeLayout>

`

Inside fragment

@SuppressLint("ClickableViewAccessibility")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.rvSmallList.setOrientation(DSVOrientation.HORIZONTAL)
        binding.rvSmallList.setOffscreenItems(2)
        binding.rvSmallList.setOverScrollEnabled(false)
        binding.rvSmallList.setSlideOnFling(true)
        binding.rvSmallList.setSlideOnFlingThreshold(2100)
        binding.rvSmallList.setItemTransformer(ScaleTransformer.Builder()
                .setMaxScale(1f)
                .setMinScale(0.9f)
                .setPivotX(Pivot.X.CENTER) // CENTER is a default one
                .setPivotY(Pivot.Y.CENTER) // CENTER is a default one
                .build())
        binding.rvSmallList.adapter = VenueAdapter(vm.venueListSmall)
    }

adapter is pretty standard

class VenueAdapter(private val items: MutableList<VenueItem> = ArrayList()) RecyclerView.Adapter<VenueAdapter.ItemViewHolder>() {

   fun updateList(items: MutableList<VenueItem>) {
       this.items.clear()
       this.items.addAll(items)
       notifyDataSetChanged()
   }

   override fun getItemCount() = items.size

   override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
       return ItemViewHolder(VenueItemSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false)
       )
   }

   override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
       holder.bind(getItem(position))
   }

   private fun getItem(position: Int) = items[position]

   inner class ItemViewHolder internal constructor(private val binding: VenueItemSmallBinding) :
           RecyclerView.ViewHolder(binding.root) {

       val vm = VenueItemViewModel()

       init {
           binding.vm = vm
           binding.executePendingBindings()
       }

       internal fun bind(item: VenueItem) {
        //   vm.venueItem.set(item)
         //  binding.executePendingBindings()
       }
   }
}
@death14stroke
Copy link

I am having the same issue. The onItemChangedListener works perfectly fine when you swipe on the screen but the view doesn't show. I also tried setting visibility in code but still, it doesn't show.

@jjmins
Copy link

jjmins commented Jul 21, 2020

I have this problem in Fragment.

@yarolegovich yarolegovich added the can't reproduce Include please a sample project where I can reproduce the issue. label Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Include please a sample project where I can reproduce the issue.
Projects
None yet
Development

No branches or pull requests

4 participants