SimpleRatingBar icon indicating copy to clipboard operation
SimpleRatingBar copied to clipboard

onSizeChanged may oom

Open coolegos opened this issue 8 years ago • 5 comments

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?

coolegos avatar Dec 22 '16 06:12 coolegos

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 ?

FlyingPumba avatar Dec 22 '16 06:12 FlyingPumba

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

coolegos avatar Dec 22 '16 07:12 coolegos

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 avatar Dec 22 '16 07:12 FlyingPumba

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

FlyingPumba avatar Dec 22 '16 07:12 FlyingPumba

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

coolegos avatar Dec 22 '16 07:12 coolegos