Created
June 16, 2022 11:35
-
-
Save hellofaizan/a78ac0f91c3698be5d1739ce01d29e63 to your computer and use it in GitHub Desktop.
Load Image From Firebase Real Time Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load NavBar Image From Firebase | |
DatabaseReference getImage = databaseReferenceImage.child("NavBarImage"); | |
getImage.addListenerForSingleValueEvent(new ValueEventListener() { | |
@Override | |
public void onDataChange(@NonNull DataSnapshot dataSnapshot) { | |
// getting a DataSnapshot for the location at the specified | |
// relative path and getting in the link variable | |
String link = dataSnapshot.getValue(String.class); | |
// loading that data into rImage | |
// variable which is ImageView | |
Glide.with(MainActivity.this).load(link).into(eventImage); | |
eventImage.setOnClickListener(v -> { | |
if (!NavBarLink.isEmpty()){ | |
Intent pAD1 = new Intent(Intent.ACTION_VIEW, Uri.parse(NavBarLink)); | |
startActivity(pAD1); | |
} | |
}); | |
} | |
@Override | |
public void onCancelled(@NonNull DatabaseError databaseError) { | |
// we are showing that error message in toast | |
Toast.makeText(MainActivity.this, "Error Loading Image: " + databaseError.getMessage(), Toast.LENGTH_SHORT).show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment