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

Uncaught translation error: com.android.dx.cf.code.SimException: local 0002: invalid
Set dynamic string data of different languages to textview in android
Can not reduce size of Switch in android
Error:Could not initialize class org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.StaticVersionComparator
How to create a two column list with random item heights [duplicate]
Android N Notification Direct Reply
How to update a textview of a listItem based on the current time and the event start time
Image resizing issue when keyboard open in android mobile
Accessing component within layout inflater
How to zoom in android Layout Editor?
Android exit transition excludeTarget not working inside android.support.v4.widget.DrawerLayout
How to implement Firebase Cloud messaging with Foreground application?
Retrieve Firebase Data saved with push()
Override lock screen with activity for alarm application
How to edit already present file in SD CARD using SAF(storage access framework)?
why does my shouldOverrideLoading method never get called?

Categories

HOME
twitter-bootstrap-3
awk
polymer
alexa-skills-kit
twig
mstest
sitecore
grafana
appcelerator
access
javacc
spring-data-mongodb
soa
square
windows-ce
activecollab
automatic-ref-counting
3nf
screen-readers
null-pointer
firefox-addon
easyphp
foreign-keys
nodemcu
apache2.4
ember-cli
php-mysqlidb
data.stackexchange.com
interbase
pylons
nstimer
progress-bar
comparable
mql
sqsh
autodesk-designautomation
dotspatial
volatile
turfjs
memory-address
code-snippets
nested-lists
lubridate
salesforce-communities
watchman
gdata
google-data-api
hackintosh
trigonometry
vmware-fusion
datacachefactory
microsoft-metro
apollostack
angular-http
importerror
textsum
context-switch
azure-cli
git-flow
check-mk
type-theory
ampps
mapxtreme
async.js
adafruit
vorpal.js
refinerycms
libvlc
ess
wso2greg
branch-and-bound
ansi
broadband
phpldapadmin
theos
trdion2011
jjaql
ray
tinyxml
synapse
drupal-nodes
syndicationfeed
multitasking
light
embedded-fonts
flex++
process-explorer
apache-abdera
resource-management
curb
pstack
wcf-configuration
multiplexing
jquery-address
gobject-introspection
ikimagebrowserview
mysql-error-1205
webdev.webserver
cuteeditor
appledoc
luajava
undefined-index
maven-1
ajax-polling
message-passing
image-capture
great-circle

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