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

onSizeChanged may oom #21

Open
coolegos opened this issue Dec 22, 2016 · 5 comments
Open

onSizeChanged may oom #21

coolegos opened this issue Dec 22, 2016 · 5 comments

Comments

@coolegos
Copy link

thank your great library.i use it in my app.i have a demo.

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="becomeBig"
        android:text="Become Big"/>

    <View
        android:id="@+id/test_view"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_below="@id/button"
        android:background="#ffff0000"/>

    <com.iarcuschin.simpleratingbar.SimpleRatingBar
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/test_view"
        android:layout_margin="8dp"
        android:paddingLeft="10dp"
        app:srb_numberOfStars="1"
        />
</RelativeLayout>

my app xml must be RelativeLayout, so my demo use RelativeLayout.When I click button the test_view will become MATCH_PARENT. SimpleRatingBar's onSizeChange height return a big number. it will oom when Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); i can't use LinearLayout/FrameLayout. so i do something in onSizeChange.

if (w > getResources().getDisplayMetrics().widthPixels || 
    h > getResources().getDisplayMetrics().heightPixels) {
            return;
        }

Can you give me some advice?

@FlyingPumba
Copy link
Owner

Hi, not sure if I can change the library so that it doesn't use the internalBitmap (although perhaps there is a way that I don't know). What numbers are you seeing as height ?

@coolegos
Copy link
Author

h 16777168.
image
my phone is 720X1920, it may be different in other phone.

@FlyingPumba
Copy link
Owner

Well, that's big. I'll start thinking on how to solve it, but It might take me a while. If you find a workaround or fix please let me know.

@FlyingPumba
Copy link
Owner

Btw, have you tried using wrap_content for the height of the ratingbar ?

@coolegos
Copy link
Author

i try wrap_content now, it will not invoke onSizeChange, so it will not oom. maybe something wrong with my layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants