2
EDIT:明らかにするには、読み込みが遅く、アニメーション化されません。私のロッテアニメーションはなぜこのように遅いのですか?
次のように私はAsyncTaskでそれを使用しています:
public 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
}
}
すべてがここに適しています。
このコードの問題は、ダイアログが表示されたら、Lottieアニメーションが画面に表示されるまでに1秒かかることです。それが4Gネットワーク上にあれば、私はアニメーションを見ることができます。それがWIFI上にある場合、私が見ることができるのはテキストだけです。
私の質問は、ダイアログがポップアップするとすぐにアニメーションが表示されるようにするにはどうすればいいですか?