Reputation: 59
I am using animated GIF to show progress, I set GIF to image view and show it using Dialog.
Here is my Dialog with GIF.
public class SimplifyaProgressDialog extends Dialog {
public SimplifyaProgressDialog(@NonNull Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = this.getWindow();
if (null != window) {
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
this.setCanceledOnTouchOutside(false);
this.setCancelable(false);
this.setContentView(R.layout.progress_dialog);
ImageView progressImage = this.findViewById(R.id.progress_image);
Glide.with(getContext()).asGif().load(R.raw.main_loader).into(progressImage);
}
}
This is a network call, I used in Login
this.showProgress();
subscription = this.makeUIObservable(authService.authenticate(email, password))
.subscribe(
msg -> {
this.hideProgress();
onSuccess(msg);
},
error -> {
this.hideProgress();
if (error instanceof ApiError) {
this.showAlert(error.getMessage());
}
}
);
Here you can see how I show and hide Dialog, So when I used this animated GIF in network calls, It shows animation very slow, How can I handled this
Thanks
Upvotes: 2
Views: 2027
Reputation: 2566
Consider adding hardware acceleration to your slowly rendering view. This can make a real difference. You can control hardware acceleration at the following levels:
and the way to add it is (in activity):
<Activity android:hardwareAccelerated="true" >
</Activity>
It is also possible to add hardware acceleration in code.
Reference: hardware acceleration
Upvotes: 1