Search in sources :

Example 1 with LottieDrawable

use of com.airbnb.lottie.LottieDrawable in project Rocket by mozilla-tw.

the class FirstrunPagerAdapter method getView.

private View getView(int position, ViewPager pager) {
    final View view = LayoutInflater.from(context).inflate(R.layout.firstrun_page, pager, false);
    final FirstrunPage page = pages[position];
    final TextView titleView = (TextView) view.findViewById(R.id.title);
    titleView.setText(page.title);
    final TextView textView = (TextView) view.findViewById(R.id.text);
    textView.setText(page.text);
    final ImageView imageView = (ImageView) view.findViewById(R.id.image);
    final LottieDrawable drawable = new LottieDrawable();
    LottieComposition.Factory.fromAssetFileName(context, page.imageResource, new OnCompositionLoadedListener() {

        @Override
        public void onCompositionLoaded(@Nullable LottieComposition composition) {
            drawable.setComposition(composition);
        }
    });
    imageView.setImageDrawable(drawable);
    final Button buttonView = (Button) view.findViewById(R.id.button);
    buttonView.setOnClickListener(listener);
    if (position == pages.length - 1) {
        buttonView.setText(R.string.firstrun_close_button);
        buttonView.setId(R.id.finish);
    } else {
        buttonView.setText(R.string.firstrun_next_button);
        buttonView.setId(R.id.next);
    }
    if (position == TURBO_MODE_PAGE_INDEX) {
        initForTurboModePage(context, view);
    }
    return view;
}
Also used : LottieDrawable(com.airbnb.lottie.LottieDrawable) OnCompositionLoadedListener(com.airbnb.lottie.OnCompositionLoadedListener) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LottieComposition(com.airbnb.lottie.LottieComposition)

Aggregations

View (android.view.View)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LottieComposition (com.airbnb.lottie.LottieComposition)1 LottieDrawable (com.airbnb.lottie.LottieDrawable)1 OnCompositionLoadedListener (com.airbnb.lottie.OnCompositionLoadedListener)1