Giter Club home page Giter Club logo

Comments (12)

ZacSweers avatar ZacSweers commented on September 26, 2024 2

I don't think this is a bug on our end. I can't say for sure from looking at your stacktrace what's wrong with it (I'm able to use recyclerview in a sheet just fine on an internal project).

I would hazard a guess though that it has something to do with SwipeRefreshLayout, which would almost certainly not work as desired with bottom sheet. Not too familiar with its implementation under the hood, but I could imagine a case where it tries to get a view under a certain x/y position and (perhaps mistakenly) assumes that result is never null. Try removing that wrapper and see if that helps.

from bottomsheet.

alexdao avatar alexdao commented on September 26, 2024

You were right! Removing the ScrollView fixed the NullPointerException.
My data to populate the RecyclerView still isn't showing though. I'm fetching it via an Otto event. Do you have any idea why adding BottomSheetLayout would cause this?

from bottomsheet.

ZacSweers avatar ZacSweers commented on September 26, 2024

I have no idea :/. Could you share a snippet of your fragment_layout file or overview of your view hieararchy? FWIW I had trouble when trying to nest it in a nestedscrollview (Google can't seem to make up their mind on if they support this or not).

from bottomsheet.

alexdao avatar alexdao commented on September 26, 2024

Sure! Here's my fragment_layout file:

<com.flipboard.bottomsheet.BottomSheetLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bottomsheet"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout 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/linear_layout_base"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.lumivote.lumivote.ui.votes_tab.VotesFragment">


        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relative_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?android:attr/selectableItemBackground"
        android:orientation="horizontal"
        android:paddingBottom="@dimen/rv_padding">

        <TextView
            android:id="@+id/leftTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:paddingLeft="@dimen/rv_padding"
            android:paddingRight="@dimen/padding_between_main_and_right"
            android:paddingTop="@dimen/rv_padding"
            android:textSize="@dimen/main_text_size" />

        <TextView
            android:id="@+id/leftDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_below="@id/leftTitle"
            android:paddingLeft="@dimen/rv_padding"
            android:paddingRight="@dimen/padding_between_main_and_right"
            android:textSize="@dimen/description_text_size"
            android:textStyle="italic" />

        <TextView
            android:id="@+id/mainTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:paddingEnd="@dimen/rv_padding"
            android:paddingRight="@dimen/rv_padding"
            android:paddingTop="@dimen/rv_padding"
            android:textSize="@dimen/main_text_size" />

        <TextView
            android:id="@+id/mainDescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:paddingEnd="@dimen/rv_padding"
            android:paddingRight="@dimen/rv_padding"
            android:textSize="@dimen/description_text_size" />

    </RelativeLayout>

</LinearLayout>

</com.flipboard.bottomsheet.BottomSheetLayout>

Also, I don't know if this is weird but I noticed you graduated from UT last year... I'm from Plano, so I have a lot of friends that go to UT haha

from bottomsheet.

ZacSweers avatar ZacSweers commented on September 26, 2024

Not weird at all, world needs more Texans :)

So looking at that, nothing stands out to me as an obvious reason why it might not be loading, especially if you're able to get the sheet showing without any problems. My suggested debugging steps would be as follows:

  • Breakpoint your adapter and see if the appropriate onBindViewHolder and onCreateViewHolder methods are actually being hit.
  • Remove the sheet wrapper and see if it still doesn't work

Also, I just realized that you're not trying to put the recyclerview in the sheet, which totally changes things. You can enable interacting with views outside the sheet via BottomSheetLayout#setInterceptContentTouch(boolean), then your swipe refresh layout should hopefully work since the sheet won't intercept those touches.. Sorry for the confusion!

from bottomsheet.

alexdao avatar alexdao commented on September 26, 2024

Hm, alright, thanks for your help and quick responses anyways. I guess I'll spend the rest of the night figuring this out ๐Ÿ‘

Feel free to close the issue since it seems to be a problem on my end

from bottomsheet.

ZacSweers avatar ZacSweers commented on September 26, 2024

Happy to help. Let me know if disabling the interceptContentTouch flag fixes the initial issue as well

from bottomsheet.

alexdao avatar alexdao commented on September 26, 2024

Finally figured it out!!! Issue was having the RecyclerView item layout in the fragment layout itself. I moved it out into a separate file to inflate within onCreateViewHolder().

Doing it this way also means the SwipeRefreshLayout now works without disabling the interceptContent Touch flag

from bottomsheet.

ZacSweers avatar ZacSweers commented on September 26, 2024

Good to hear, glad you were able to figure it out!

from bottomsheet.

alexdao avatar alexdao commented on September 26, 2024

I'll see if I can make some contributions to BottomSheet after I finish my project. This seems like a fun lib to work on

from bottomsheet.

ZacSweers avatar ZacSweers commented on September 26, 2024

Contributions are always welcome! Take a look at the issue tracker to see some of the implementations we're looking to add in the near future

from bottomsheet.

yanbin92 avatar yanbin92 commented on September 26, 2024

you use RecyclerView must use a LayoutManager,
such as
LinearLayoutManager layoutManager = new LinearLayoutManager(context); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(layoutManager);
i meet the same problem and solve the problem .

from bottomsheet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.