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

OutOfmemoryError from getContentView when Inflating #30

Closed
samy-baili opened this issue Jan 20, 2016 · 8 comments
Closed

OutOfmemoryError from getContentView when Inflating #30

samy-baili opened this issue Jan 20, 2016 · 8 comments

Comments

@samy-baili
Copy link

That happen when I open and close the activity several times, the memory is not freed

01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: FATAL EXCEPTION: main
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: Process: com.swapcard.apps.android, PID: 25284
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: android.view.InflateException: Binary XML file line #144: Error inflating class
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:633)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.getContentView(CardStack.java:256)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.loadLast(CardStack.java:276)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.access$300(CardStack.java:20)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack$1.onAnimationEnd(CardStack.java:58)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardAnimator$3.onAnimationEnd(CardAnimator.java:180)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:854)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:580)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:549)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5430)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Native Method)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:607)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.getContentView(CardStack.java:256) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.loadLast(CardStack.java:276) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.access$300(CardStack.java:20) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack$1.onAnimationEnd(CardStack.java:58) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardAnimator$3.onAnimationEnd(CardAnimator.java:180) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:854) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:580) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:549) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5430) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: Caused by: java.lang.OutOfMemoryError: Failed to allocate a 64000012 byte allocation with 33554336 free bytes and 53MB until OOM
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:988)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.content.res.Resources.loadDrawableForCookie(Resources.java:2580)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:2487)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.widget.ImageView.(ImageView.java:146)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.widget.ImageView.(ImageView.java:135)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.joooonho.SelectableRoundedImageView.(SelectableRoundedImageView.java:76)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.joooonho.SelectableRoundedImageView.(SelectableRoundedImageView.java:72)
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Native Method) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.getContentView(CardStack.java:256) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.loadLast(CardStack.java:276) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack.access$300(CardStack.java:20) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardStack$1.onAnimationEnd(CardStack.java:58) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.wenchao.cardstack.CardAnimator$3.onAnimationEnd(CardAnimator.java:180) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:854) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:580) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:549) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5430) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:913) 
01-20 18:03:54.556 25284-25284/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 

@wenchaojiang
Copy link
Owner

Could you try to profile your app and provide more info of what is leaking, thanks

@samy-baili
Copy link
Author

I got the Out memory when inflating from:

public View getContentView() {
        View contentView = null;
        if (mContentResource != 0) {
            LayoutInflater lf = LayoutInflater.from(getContext());
            contentView = lf.inflate(mContentResource, null);
        }
        return contentView;
    }

But I think the main issue is the memory is not released, every time I open the activity and notify my adapter the allocated memory increases by 50 mo.

That is what my card layout look like:

<?xml version="1.0" encoding="utf-8"?>
<com.swapcard.apps.android.views.SquareRelativeLayout
    android:id="@+id/activity_root"
    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="wrap_content"
    android:background="@drawable/swipeable_card_drawable">

    <com.joooonho.SelectableRoundedImageView
        android:id="@+id/blur_background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:background="@drawable/swipeable_background_blue_drawable"
        app:sriv_left_top_corner_radius="3dp"
        app:sriv_right_top_corner_radius="3dp"
        app:sriv_left_bottom_corner_radius="3dp"
        app:sriv_right_bottom_corner_radius="3dp" />

    <View
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/swipeable_overlay_drawable"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_alignTop="@+id/data_container">

        <View
            android:layout_width="fill_parent"
            android:layout_height="@dimen/picture_size_divider"
            android:background="@android:color/transparent"/>

        <View
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@drawable/swipeable_background_drawable"/>

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/data_container"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="@dimen/detail_padding"
        android:paddingRight="@dimen/detail_padding"
        android:paddingBottom="@dimen/detail_padding"
        android:layout_marginTop="@dimen/detail_padding"
        android:layout_alignParentBottom="true">

        <TextView
            android:id="@+id/placeholder"
            android:layout_width="@dimen/picture_size"
            android:layout_height="@dimen/picture_size"
            android:gravity="center"
            android:background="@drawable/contact_picture_swipeable_drawable"
            android:text="@string/picto_contact"
            android:textColor="@android:color/white"
            android:textSize="80sp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"/>

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/picture"
            android:layout_width="@dimen/picture_size"
            android:layout_height="@dimen/picture_size"
            app:border_color="@color/white"
            app:border_width="2dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"/>

        <LinearLayout
            android:id="@+id/infos_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:minHeight="@dimen/picture_size"
            android:layout_marginLeft="125dp"
            android:layout_marginStart="125dp">

            <TextView
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="@dimen/picture_size_divider"
                android:gravity="center_vertical"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:textSize="19sp"/>

            <TextView
                android:id="@+id/job"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@color/main_blue"
                android:textSize="14sp"/>

            <TextView
                android:id="@+id/job_bis"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@color/main_blue"
                android:textSize="14sp"/>

            <TextView
                android:id="@+id/company"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:textColor="@color/main_blue"
                android:textSize="14sp"/>

        </LinearLayout>

        <com.swapcard.apps.android.fragments.contact.detail.FlowLayout
            android:id="@+id/flow_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/infos_layout"
            android:layout_marginTop="@dimen/detail_padding"/>

    </RelativeLayout>

    <com.joooonho.SelectableRoundedImageView
        android:id="@+id/overlay_add"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/matching_user_added"
        android:scaleType="fitXY"
        android:background="@android:color/transparent"
        android:clickable="false"
        android:alpha="0"
        app:sriv_left_top_corner_radius="3dp"
        app:sriv_right_top_corner_radius="3dp"
        app:sriv_left_bottom_corner_radius="3dp"
        app:sriv_right_bottom_corner_radius="3dp" />

</com.swapcard.apps.android.views.SquareRelativeLayout>

@rajyvan
Copy link

rajyvan commented Jan 25, 2016

Hi !
There is an issue of recycling.
In CardStack, try something like that:

private void loadLast() {
ViewGroup parent = (ViewGroup) viewCollection.get(0);

    int lastIndex = (mNumVisible - 1) + mIndex;
    if (lastIndex > mAdapter.getCount() - 1) {
        parent.setVisibility(View.GONE);
        return;
    }

    View child = mAdapter.getView(lastIndex, parent.getChildAt(0), parent);   (HERE instead of getContentVie())
    parent.removeAllViews();
    parent.addView(child);
}

@samy-baili
Copy link
Author

Hi rajyvan,
Thanks for your help, but your workaround always display the four first items. But your right, I think that's a recycling issue

@rajyvan
Copy link

rajyvan commented Jan 26, 2016

Hi Samy-baily,
Check in your adapter if getView is correctly called and then, check if your returned view is correctly populated. May be there is a wrong condition somewhere...

@samy-baili
Copy link
Author

Did you see something wrong ?

@Override
    public View getView(int position, View convertView, ViewGroup parent){
        CardHolder holder = new CardHolder();
        if (convertView.getTag() == null) {
            holder.mBlurBackground = (RoundedImageView) convertView.findViewById(R.id.blur_background);
            holder.mOverlayAdded = (RoundedImageView) convertView.findViewById(R.id.overlay_add);
            mGlide.load(R.drawable.matching_user_added).into(holder.mOverlayAdded);
            holder.mOverlayRemove = (RoundedImageView) convertView.findViewById(R.id.overlay_remove);
            mGlide.load(R.drawable.matching_user_ignored).into(holder.mOverlayRemove);
            holder.mPlaceHolder = (TextView) convertView.findViewById(R.id.placeholder);
            holder.mPlaceHolder.setTypeface(mSwapFont);
            holder.mPicture = (CircleImageView) convertView.findViewById(R.id.picture);
            holder.mName = (TextView) convertView.findViewById(R.id.name);
            holder.mName.setTypeface(mRegularFont);
            holder.mJob = (TextView) convertView.findViewById(R.id.job);
            holder.mJob.setTypeface(mLightFont);
            holder.mJobBis = (TextView) convertView.findViewById(R.id.job_bis);
            holder.mJobBis.setTypeface(mLightFont);
            holder.mCompany = (TextView) convertView.findViewById(R.id.company);
            holder.mCompany.setTypeface(mRegularFont);
            holder.mAddTags = (TextView) convertView.findViewById(R.id.add_tags);
            holder.mAddTags.setTypeface(mRegularFont);
            holder.mFlowLayout = (FlowLayout) convertView.findViewById(R.id.flow_layout);
            holder.mColor = ActionUtils.getContactRandomColor(mContext);
            convertView.setTag(holder);
        }
        else
            holder = (CardHolder) convertView.getTag();


        Relation relationObject = (Relation) getItem(position);
        if (relationObject != null) {
            UserCard card = ContactUtils.getCardFromRelation(relationObject);
            if (card != null) {
                String photo = card.getPhotoThumbnail();
                if (!TextCheckUtils.isEmpty(photo)) {
                    final CardHolder finalHolder = holder;
                    mGlide.load(photo).asBitmap().into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                            finalHolder.mPicture.setImageBitmap(resource);
                            new AsyncBitmapUrl(resource, finalHolder.mBlurBackground).execute();
                        }
                    });
                }
                else {
                    GradientDrawable bgShapeBlur = (GradientDrawable) holder.mBlurBackground.getBackground();
                    bgShapeBlur.setColor(holder.mColor);
                }

                populateView(holder.mName, card.getDisplayName(mContext));
                populateView(holder.mJob, card.getJob());
                populateView(holder.mJobBis, card.getJobbis());
                populateView(holder.mCompany, card.getCompany());

                GradientDrawable bgShape = (GradientDrawable) holder.mPlaceHolder.getBackground();
                bgShape.setColor(holder.mColor);

                List<String> skills = card.getKeywords();
                if (skills.size() > 0)
                    addSkillDynamically(holder.mFlowLayout, skills);
                else {
                    if (mCardID == card.id)
                        holder.mAddTags.setVisibility(View.VISIBLE);
                    else
                        holder.mAddTags.setVisibility(View.GONE);
                    holder.mFlowLayout.setVisibility(View.GONE);
                }
            }
        }
        return convertView;
    }

@rajyvan
Copy link

rajyvan commented Jan 26, 2016

I don't see anything wrong...
Try to debug with breakpoints everytime getView is called.

@samy-baili
Copy link
Author

Ok, Thank you very much for your time 👍

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

3 participants