Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- final ImageView imageView = (ImageView) findViewById(R.id.img_glide);
- final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
- Glide.with(this)
- .load("https://raw.githubusercontent.com/bumptech/glide/master/static/glide_logo.png")
- .listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- progressBar.setVisibility(View.GONE);
- return false;
- }
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- progressBar.setVisibility(View.GONE);
- return false;
- }
- })
- .into(imageView);
- }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity">
- <ProgressBar
- android:id="@+id/progress"
- android:layout_width="match_parent"
- android:layout_height="100dp"
- android:visibility="visible" />
- <ImageView
- android:id="@+id/img_glide"
- android:layout_width="match_parent"
- android:layout_height="100dp" />
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement