android


FirebaseRecyclerAdapter multiple error such as “item position”


I am trying to create two FirebaseRecyclerAdapter in one activity.
So I have one MainActivity with two fragments. Each fragment has its own FirebaseRecyclerAdapter(List). In the picture you can see the structure plan!
Below are two Buttons. Where you can switch between the two Fragments.
So my error is: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:2).state:2
My Code from one of my Fragments:
#Override
public void onStop() {
super.onStop();
if (firebaseRecyclerAdapter != null) {
firebaseRecyclerAdapter.cleanup();
}
}
#Override
public void onPause() {
super.onPause();
if (firebaseRecyclerAdapter != null) {
firebaseRecyclerAdapter.cleanup();
}
}
#Override
public void onResume() {
super.onResume();
startRecycler();
}
#Override
public void onStart() {
super.onStart();
if (firebaseRecyclerAdapter != null) {
firebaseRecyclerAdapter.cleanup();
}
}
private void startRecycler() {
if (firebaseRecyclerAdapter != null)
firebaseRecyclerAdapter.onAttachedToRecyclerView(mList);
if (mAuth.getCurrentUser() != null) {
firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<Model, FragmentOneViewHolder>(
Model.class,
R.layout.row,
FragmentOneViewHolder.class,
mDatabase
) {
#Override
protected void populateViewHolder(FragmentOneViewHolder viewHolder, final Model model, int position) {
final String key = getRef(position).getKey();
viewHolder.setText(model.getText());
viewHolder.setImage(model.getImage());
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
}
};
mList.setAdapter(firebaseRecyclerAdapter);
}
}
public static class FragmentOneViewHolder extends RecyclerView.ViewHolder {
View mView;
String resultImg;
private FirebaseAuth mAuth;
private StorageReference mStorageImage;
private FirebaseStorage mStorage;
public EventViewHolder(View itemView) {
super(itemView);
mView = itemView;
mAuth = FirebaseAuth.getInstance();
public void setText(String text) {
TextView tvText = (TextView) mView.findViewById(R.id.tvText);
tvText.setText(text);
}
public void setImage(String image) {
final ImageView ivImage = (ImageView) mView.findViewById(R.id.ivImage);
resultImg = image;
mStorage = FirebaseStorage.getInstance();
mStorageImage = mStorage.getReferenceFromUrl(resultImg);
try {
final File localFile = File.createTempFile("images", "jpg");
mStorageImage.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
#Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Bitmap bitmap = BitmapFactory.decodeFile(localFile.getAbsolutePath());
ivImage.setImageBitmap(bitmap);
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception exception) {
}
});
} catch (IOException e) {
}
}
}
I believe or I know that I can solve the error with the getImageView command!
But I do not know, if I am right and how to program it!
Thank you!

Related Links

Error by including drawable xml-file
Display thumbnail of video
Android parallel updating the edit text
Given the following code , under Eclipse ,I get a type mismatch error :cannot convert from java.lang.reflect.Type to android.renderscript.Type
Activity and service both gets different value of Application instance
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly
Android Amazon S3 HTTP/1.1 403 Forbidden Issue while uploading file
Weird native datepicker display on Android
Android Volley: Multipart Request. using Apache HTTP libraries
Dialog buttons with long text not wrapping / squeezed out - material theme on android 5.0 lollipop
Nesting a fragment in a nested fragment
Spinner not showing dropdown view
Control the Toolbar icon with NavigationDrawer
Android Software caused connection abort and Async task
Android : Get the token using GoogleAuthUtils. Invalid Client ID
An internal error occurred during: “C/C++ Indexer”.java.lang.NullPointerException

Categories

HOME
httparty
microsoftgraph
google-cloud-platform
ng-idle
saml-2.0
error-handling
bitbucket-api
regular-language
nfs
recordrtc
qpython
google-chrome-app
mel
gson
renjin
selectize.js
symbol
package-managers
dpdk
question2answer
systemtime
joptionpane
imageresizer
mongoid6
resourcebundle
comparator
dynamically-generated
moses
browser-sync
powershell-ise
record
dumpbin
memory-address
spring-security4
code-snippets
gnat-gps
mnist
raft
wurfl
node-mssql
bc
numberpicker
dcmtk
softmax
movilizer
microsoft-metro
glm-math
outputcache
photos
pom.xml
httrack
jquery-ui-draggable
mschart
vugen
convex-optimization
google-cse
scalding
video-conferencing
git-flow
renaming
node-request
parfor
macaulay2
expectations
cifilter
lua-telegram-bot
aurora
kendo-upload
concurrentmodification
computer-architecture
coda
shopizer
code-documentation
nodelist
beatsmusic
packet-sniffers
boost-program-options
addressing-mode
teaspoon
ignite-ui
ray
mutual-authentication
maven-scm
gae-quotas
mysql-error-1044
hidapi
mvc-editor-templates
octal
traceability
stress
promotion-code
automationelement
collectionviewsource
uideviceorientation
updatesourcetrigger
zend-rest
visualj#
wysiwym
fdf
linfu-dynamicproxy
technical-debt

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