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

Crash when apply ripple builder on view holder #22

Closed
cbedoy opened this issue Dec 23, 2014 · 5 comments
Closed

Crash when apply ripple builder on view holder #22

cbedoy opened this issue Dec 23, 2014 · 5 comments

Comments

@cbedoy
Copy link

cbedoy commented Dec 23, 2014

I'm trying your library on my view holder but when I run the project the application crash, these happend when I scroll the listView.

The code is:

public class CategoryViewCell extends AbstractAdapter
{

public CategoryViewCell(List<HashMap<String, Object>> dataModel){
    super(dataModel);
}

@Override
public View getView(int position, View convertView, ViewGroup viewGroup){

    ViewHolder viewHolder;
    if(convertView == null)
    {
        viewHolder = new ViewHolder();
        convertView = ApplicationLoader.mainLayoutInflater.inflate(R.layout.lsta_pral_item, null);
        viewHolder.imageView = (ImageView)convertView.findViewById(R.id.lstaPralItem);
        convertView.setTag(viewHolder);
    }
    else
    {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    HashMap<String, Object> information = dataModel.get(position);
    String imagen = information.get("imagen").toString();

    Bitmap bitmapFromFile = ImageLoaderService.getInstance().getBitmapFromFile(imagen);
    if (bitmapFromFile != null)
    {
        viewHolder.imageView.setImageBitmap(bitmapFromFile);
    }
    else
    {
        viewHolder.imageView.setImageResource(R.drawable.no_found_image);
    }

    MaterialRippleLayout.on(viewHolder.imageView).rippleColor(Color.RED).create();


    return convertView;
}

private static class ViewHolder
{
    ImageView imageView;
}

}

And the crash is:

java.lang.IllegalStateException: MaterialRippleLayout could not be created: parent of the view already is a MaterialRippleLayout
        at org.pademobile.widgets.MaterialRippleLayout$RippleBuilder.create(MaterialRippleLayout.java:701)
        at org.pademobile.bills.artifacts.CategoryViewCell.getView(CategoryViewCell.java:60)
        at android.widget.AbsListView.obtainView(AbsListView.java:2255)
        at android.widget.ListView.makeAndAddView(ListView.java:1790)
        at android.widget.ListView.fillDown(ListView.java:691)
        at android.widget.ListView.fillGap(ListView.java:655)
        at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5143)
        at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3243)
        at android.widget.AbsListView.onTouchMove(AbsListView.java:3587)
        at android.widget.AbsListView.onTouchEvent(AbsListView.java:3431)
        at android.view.View.dispatchTouchEvent(View.java:7736)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2212)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2218)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2466)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
        at android.view.View.dispatchPointerEvent(View.java:7916)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4023)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3902)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3471)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3578)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3479)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3635)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3502)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3471)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3479)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3452)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5657)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5588)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5559)
        at androi
@cbedoy
Copy link
Author

cbedoy commented Dec 23, 2014

Well I fixed that, but the ripple dont show on customs cells :(

@3c
Copy link

3c commented Dec 24, 2014

try this:

if(convertView == null) {
   viewHolder = new ViewHolder();
   convertView = ApplicationLoader.mainLayoutInflater.inflate(R.layout.lsta_pral_item, null);
   viewHolder.imageView = (ImageView)convertView.findViewById(R.id.lstaPralItem);
    //add code in here
    convertView=MaterialRippleLayout.on(convertView)
      .rippleColor(Color.parseColor("#FF0000"))
      .rippleAlpha(0.2f)
      .rippleHover(true)
      .rippleInAdapter(true)
      .create();
    convertView.setTag(viewHolder);
} else {
   viewHolder = (ViewHolder) convertView.getTag();
}

edit: code formatting

@balysv
Copy link
Owner

balysv commented Dec 24, 2014

Your initial crash happened because you apply a MaterialRippleLayout onto views that already have it. An AdapterView reuses previous views and you apply to the reused view.
To get it working inside some inner view, you must register a ClickListener to that view.

@cbedoy
Copy link
Author

cbedoy commented Dec 24, 2014

Yes, later I reuse the view, but the effect dont appear, I'll try that 3c

@balysv balysv closed this as completed Jan 31, 2015
@aartiverma1
Copy link

Hi,

I have used the above formatted code,but ripple effect is not showing on list Item.Any help please?

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

4 participants