android


Android - Crash when clicking on RecyclerView when SwipeRefreshLayout loading


I have a RecyclerView inside a SwipeRefreshLayout , when I reload my page , when SwipeRefreshLayout is loading, I click on the item on the RecyclerView and it crashes.
04-21 13:14:49.605 25586-25586/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.boxopen.funstack, PID: 25586
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.boxopen.funstack.adapter.RecycleBookAdapter$BookViewHolder.onClickLike(RecycleBookAdapter.java:339)
at com.boxopen.funstack.adapter.RecycleBookAdapter$BookViewHolder.access$100(RecycleBookAdapter.java:64)
at com.boxopen.funstack.adapter.RecycleBookAdapter$BookViewHolder$2.onDoubleClick(RecycleBookAdapter.java:122)
at com.boxopen.funstack.listener.DoubleClickListener.onClick(DoubleClickListener.java:36)
at android.view.View.performClick(View.java:4478)
at android.view.View$PerformClick.run(View.java:18698)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5268)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
04-21 13:14:49.675 182-1124/? E/IMGSRV: :0: PVRDRMOpen: TP3, ret = 57
From what i understand by your question and log is basically you are clearing the arraylist in onRefresh() but not notifying the adapter that the list has been cleared.
Please call notifyDataSetChanged() after clearing arraylist
you should put condition for check the size of (for eg. array, ArrayList ... used by you ) data
Seems like you have cleared your list upon refresh, but the items are still in your recyclerview. You should notify your adapter that the list is empty now.
In your current situation, starting to scroll will probably cause the application to crash as well?!

Related Links

Restore values on screen rotation
Database conflicts between threads
Displaying an image from the resource issue
Android Market Filter Help Needed
.videoWidth and .videoHeight not working in Android 3.x browser
IllegalArgumentException when using Android native component in LWUIT
How GPS device in car send notification to Android app when the car over the speed limit?
How can I tell when an Album is added to the MediaStore
How to get error message of a failed shell command on android
How do I monitor the progress of URLConnection.getInputStream() in Android where javax.swing.ProgressMonitorInputStream() is unavailable?
Android SQLite Repeated Elements
Is it possible to count the number of times I open google?
Adding an onclicklistener to listview (android)
TabListener constructor in FragmentTabs.java
Rooting ICS emulator; pushing su fails with “Out of memory”
Getting An Error While Using Web Service?

Categories

HOME
gridview
google-spreadsheet
formal-languages
datastore
mstest
javacc
newrelic
database-normalization
dojo
azure-container-service
accessibility
sendgrid-api-v3
mel
heap
alamofire
why3
nancy
google-maps-autocomplete
ios10.2
joptionpane
mongoid6
tosca
pic32
bulletphysics
corpus
vex
send
record
github3.py
nested-lists
raft
hivemq
xdocreport
google-data-api
numberpicker
magento-1.9.3
attributeerror
linqpad
oracle-service-bus
congestion-control
clang++
dynamic-linq
httrack
openresty
gitlist
dbcontext
datamaps
mongotemplate
zenhub
opengl-4
boo
mach-o
rackspace-cloud
pocketsphinx-android
chromium-os
builtins
pacemaker
envi
segment-io
file-uri
xdoclet
jclouds
refinerycms
nservicebus5
createprocess
lz77
fuzzywuzzy
mobiledoc-kit
toran-proxy
fiware-monitoring
django-urls
page.js
visual-sourcesafe-2005
rpart
slash
sql-server-data-tools
skspritenode
botan
mraid
openbabel
dbaccess
viewer
sip-server
teaspoon
codeplex
gwt-openlayers
scringo
pstack
appjs
workflow-services
listactivity
unattended-processing
cdonts
cruisecontrol.rb
dot-emacs
hbm2java
openfaces
sifr
lalr
soappy
ifilter
lemmatization
cardspace

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App