2017-05-06 9 views
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上にある場合、私が見ることができるのはテキストだけです。

私の質問は、ダイアログがポップアップするとすぐにアニメーションが表示されるようにするにはどうすればいいですか?

答えて

1

は実際に最後に、それを解決したガブリエルペアルのおかげ

非常にシンプル。構図ダイアログが現れたときに、以下のように、我々は、LottieCompositionで手前にそれをレンダリングレンダリング避けるために:

 LottieComposition.Factory.fromAssetFileName(mContext, "PinJump.json", new OnCompositionLoadedListener() { 
      @Override 
      public void onCompositionLoaded(LottieComposition composition) { 
       mAnimationView.loop(true); 
       mAnimationView.playAnimation(); 
       TextView text = (TextView) customDialog.findViewById(R.id.textView); 
       text.setText(R.string.dialog_looking_for_address); 
       customDialog.show(); 
      } 
     }); 

その方法を、アニメーションはダイアログでをポップアップします。

関連する問題