carrot / recycler-core

Multiple view type handling in RecyclerViews with 90% less tears
25 stars 1 forks source link

A few issues implementing the library #49

Closed Gonzom closed 8 years ago

Gonzom commented 8 years ago

Hey,

While trying to implement this library I've encountered some problems.

  1. I cannot build the application and receive this error message: Error:(15) No resource identifier found for attribute 'distanceFromBottomToLoadMore' in package 'com.roide.temp'
  2. The ProgressRecyclerViewLayout does not have a setOnLoadPointListener method.
  3. I couldn't use SwipeRefreshProgressRecyclerView as the library doesn't have this class.
  4. I couldn't find any adapter helper methods for adding and removing item and list of items. How should this be handled here (without the need to clear the adapter and add all items to it each time)?
  5. Not a bug but a request, would it be possible to add the empty and error views to the xml instead of needing to inflate them in code?

Thanks! I've attached my testing project. RecyclerCoreTest.zip

roideuniverse commented 8 years ago

Hi @Gonzom this is an error on my side, apologies. I have updated the README. Try the new version recycler-core:1.0.8

Gonzom commented 8 years ago

Hey @roideuniverse,

Updating to 1.0.8 solved issues 1-3, thanks!

I have 2 questions left: 1) I'm still wondering if there are any helper methods for the adapter, as I'd really not like to use a general "notifydatasetchanged" but a more specific one, which would enable animations for rows.

2) How would I be able to add a progress loader as the last row while new data is being fetched?

I'm also getting a new rendering error in a layout using ProgressRecyclerViewLayout:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.android.layoutlib.bridge.util.ReflectionUtils.invoke(ReflectionUtils.java:54)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:127)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:121)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setAdapter(RecyclerViewUtil.java:63)
    at android.view.BridgeInflater.setupViewInContext(BridgeInflater.java:385)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:262)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
    at com.carrotcreative.recyclercore.widget.ProgressRecyclerViewLayout.<init>(ProgressRecyclerViewLayout.java:78)
    at com.carrotcreative.recyclercore.widget.ProgressRecyclerViewLayout.<init>(ProgressRecyclerViewLayout.java:67)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$72(RenderTask.java:659)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Invalid usage of setAdapter. Use ProgressRecyclerViewLayout.setAdapter(RecyclerCoreAdapter adapter) to Set the adapter
    at com.carrotcreative.recyclercore.widget.RecyclerCoreRecyclerView.setAdapter(RecyclerCoreRecyclerView.java:32)
    ... 49 more

I've attached my updated testing project. RecyclerCoreTest.zip

roideuniverse commented 8 years ago
  1. I don't think adapters are supposed to have remove item method. They do have methods like https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyItemRemoved(int) If you need additional animation functionality you will have to extend the adapter write your own. RecyclerCore does not support animations by default. Adapter is not final so it should be easily possible.
  2. This is generic Recycler View questions not related to recycler core. There are multiple possible ways to do that but the simplest solution is before starting the fetch add a model at the bottom of the model list of the recycler view, and after the data is fetched and before it gets displayed remove that model from the model list.
  3. The exception happens when we incorrectly try to set an adapter on RecyclerCoreRecyclerView instead of ProgressRecyclerViewLayout