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

Layout as selector item in Android
Android studio version 2.3 not working
CSS Portrait Media Query not detected on 720p and up phones
Issue with Fragment lifecycle in Android app
Data from firebase database is not displayed properly
Android 25 and Espresso 2.2.2 fails instrumentation test annotations failure
What is the best way to send a message to specific user in Firebase?
Activity can still call unbind service method. Is it normal?
Android Fragment Flow
Andriod httpurlconnection with WooCommerce OAuth1 API
Cannot add platform using Cordova CLI 7.0.0
Monitoring Main(UI) Thread
Android Layout Inspector: Extract Hint Property for Analysis
Could not open database code 14 - only in wrapped app
How to make a squircle ImageView with Android [on hold]
Issues in android native application

Categories

HOME
assembly
twitter-bootstrap-3
c99
css3
rdbms
jax-rs
object
depth
numbers
pascal
yandex
xbee
entity-framework-core
square
ado.net
bookmarks
settings
data-visualization
mvc5
gluon-mobile
pkcs#11
joomla3.0
arangodb
jquery-ui-sortable
enthought
powershell-v5.0
feathersjs
google-content-api
git-extensions
react-toolbox
pchart
roundup
tiki-wiki
jquery-multiselect
jasmine-node
linked-data
8051
datastax-enterprise-graph
sql-server-2000
erb
android-sugarorm
hunspell
hibernate-search
indy10
release
recurrent-neural-network
css-position
opensmpp
tasm
branching-and-merging
memory-mapping
dapper-simplecrud
textsum
jquery-ui-draggable
globalize
rserve
trojan
compiler-design
android-testing
reshape
objectscript
renaming
angular2-testing
actor-platform
async.js
resourcemanager
signalr.client
expectations
kango-framework
uiactionsheet
html-to-pdf
thread-sleep
pushbots
asyncdisplaykit
dynatree
sciruby
pypiserver
rate-limiting
poppler
doctype
sony-lifelog-api
jdk1.7
dulwich
avahi
dnssec
teamcity-9.1
nsurlsessiondatatask
angular-gettext
uncaught-typeerror
ignite-ui
ora-00904
buffering
fpdi
mvc-editor-templates
cmmi
wp7test
http-status-code-410
apache-abdera
android-sdk-2.3
redis-py
frameworkelementfactory
vfs
listitem
josql
azman
predicatebuilder
kqueue
pylucene
event-receiver
http-daemon
msr
ruby-1.8
undefined-index
updatesourcetrigger
easyb
scrollbars
django-piston
wordprocessingml
xpsdocument
int64
business-model

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