So I'm looking for a solution. I currently have a Firebase database that stores all my users’ information. I then take this and place it into an ImageView
and TextView
by running a listener for a single value event which gives me a list of users that I'm able to iterate over.
The key point to this is that I do not want to swipe in order to change the user they are looking at; I want them to click on a button.
This is the current onClick
listener:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
boolean verified;
//REMOVE USER FROM LIST
String matchUid = userList.get(0).getUid();
userList.remove(0);
}
// GET NEW USER
String url = userList.get(0).getPhoto1URI();
String name = userList.get(0).getFirstname();
final String userage = String.valueOf(userList.get(0).getAge());
// SET NEW USER
if(url != null && name != null) {
mainName.setText(name);
mainAge.setText(userage);
Glide.with(getApplicationContext())
.load(url)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.centerCrop()
.crossFade()
.error(R.drawable.addimage)
.into(profileImage);
}
}
});
Currently, this process takes too long to switch between users once the button is pressed so there must be a more efficient way of doing this. Is there any way of preloading the next image so that it gives quicker loading times?