EDIT: Um es zu verdeutlichen, ist es langsam zu laden, nicht zu animieren.Warum ist meine Lottie Animation so langsam?
ich es auf einem AsyncTask bin mit wie folgt:
hier gutpublic class GetCurrentLocation extends AsyncTask<String, Void, String>{
private Context mContext;
private View view;
public GetCurrentLocation (View view, Context mContext) {
this.view = view;
this.mContext = mContext;
}
protected void onPreExecute() {
super.onPreExecute();
//Custom Dialog
customDialog = new Dialog(mContext);
customDialog.setContentView(R.layout.dialog_custom);
customDialog.setTitle("Looking for address");
//Custom Dialog Animation
LottieAnimationView animationView = (LottieAnimationView) customDialog.findViewById(R.id.animation_view);
animationView.setAnimation("PinJump.json"); //Lottie's premade animation
animationView.loop(true);
animationView.playAnimation();
//Custom Dialog Text
TextView text = (TextView) customDialog.findViewById(R.id.textView);
text.setText(R.string.dialog_looking_for_address);
customDialog.show();
}
protected String doInBackground(String... params) {
//Code removed to shorten codeblock, it calls gps location here
return null;
}
protected void onPostExecute(String result) {
super.onPostExecute(result);
customDialog.dismiss();
mPostSolicitationFragment.setLocalText(); //This is the method it transfer the GPS address to the view
}
}
Alles funktioniert.
Mein Problem mit diesem Code ist, dass, sobald der Dialog erscheint, die Lottie Animation eine Sekunde braucht, bevor sie auf dem Bildschirm erscheint. Wenn es im 4G-Netzwerk ist, kann ich die Animation sehen. Wenn es auf WIFI ist, ist das einzige, was ich sehen kann, der Text.
Meine Frage ist, wie kann ich die Animation auftauchen, sobald der Dialog erscheint?