com.airbnb.lottie.LottieAnimationView Java Examples

The following examples show how to use com.airbnb.lottie.LottieAnimationView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfirmKbsPinFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void startEndAnimationOnNextProgressRepetition(@RawRes int lottieAnimationId,
                                                       @NonNull AnimationCompleteListener listener)
{
  LottieAnimationView lottieProgress = getLottieProgress();
  LottieAnimationView lottieEnd      = getLottieEnd();

  lottieEnd.setAnimation(lottieAnimationId);
  lottieEnd.removeAllAnimatorListeners();
  lottieEnd.setRepeatCount(0);
  lottieEnd.addAnimatorListener(listener);

  if (lottieProgress.isAnimating()) {
    lottieProgress.addAnimatorListener(new AnimationRepeatListener(animator ->
        hideProgressAndStartEndAnimation(lottieProgress, lottieEnd)
    ));
  } else {
    hideProgressAndStartEndAnimation(lottieProgress, lottieEnd);
  }
}
 
Example #2
Source File: Splash.java    From DeviceInfo with Apache License 2.0 6 votes vote down vote up
@Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     Fabric.with(this, new Crashlytics());

/*     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
         this.getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
     }*/

     setContentView(R.layout.activity_splash);

     LottieAnimationView lottieAnimationView = findViewById(R.id.animationView);
     lottieAnimationView.playAnimation();
     int SPLASH_TIME_OUT = 1300;
     new Handler().postDelayed(new Runnable() {
         @Override
         public void run() {
             Intent intent = new Intent(Splash.this, MainActivity.class);
             startActivity(intent);
             finish();
         }
     }, SPLASH_TIME_OUT);
 }
 
Example #3
Source File: PairView.java    From justaline-android with Apache License 2.0 6 votes vote down vote up
private LottieAnimationView addNewLottieAnimationView(Animation animation) {
        animationImageView = new LottieAnimationView(getContext());
        animationImageView.setId(R.id.animation_view);
//        animationImageView.enableMergePathsForKitKatAndAbove(true);
        messageContainer.addView(animationImageView);

        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(messageContainer);
        constraintSet.constrainWidth(R.id.animation_view, animation.width);
        constraintSet.constrainHeight(R.id.animation_view, animation.height);
        constraintSet.connect(R.id.animation_view, ConstraintSet.BOTTOM, R.id.message,
                ConstraintSet.TOP,
                getResources().getDimensionPixelSize(R.dimen.pair_animation_margin_bottom));
        constraintSet.connect(R.id.animation_view, ConstraintSet.LEFT, ConstraintSet.PARENT_ID,
                ConstraintSet.LEFT);
        constraintSet.connect(R.id.animation_view, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID,
                ConstraintSet.RIGHT);

        constraintSet.applyTo(messageContainer);

        return animationImageView;
    }
 
Example #4
Source File: ConfirmKbsPinFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void hideProgressAndStartEndAnimation(@NonNull LottieAnimationView lottieProgress,
                                              @NonNull LottieAnimationView lottieEnd)
{
  viewModel.onLoadingAnimationComplete();
  lottieProgress.setVisibility(View.GONE);
  lottieEnd.setVisibility(View.VISIBLE);
  lottieEnd.playAnimation();
}
 
Example #5
Source File: Reaction.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public Reaction(final ReactionType reactionType, int padding, Context context) {
  this.reactionType = reactionType;
  view = new LottieAnimationView(context);
  view.setAnimation(this.reactionType.name()
      .toLowerCase() + ".json");
  view.loop(true);
  view.setPadding(padding, padding, padding, padding);
}
 
Example #6
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 5 votes vote down vote up
private LottieAnimationViewPropertyManager getOrCreatePropertyManager(LottieAnimationView view) {
  LottieAnimationViewPropertyManager result = propManagersMap.get(view);
  if (result == null) {
    result = new LottieAnimationViewPropertyManager(view);
    propManagersMap.put(view, result);
  }
  return result;
}
 
Example #7
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 5 votes vote down vote up
@ReactProp(name = "renderMode")
public void setRenderMode(LottieAnimationView view, String renderMode) {
  RenderMode mode = null;
  if ("AUTOMATIC".equals(renderMode) ){
    mode = RenderMode.AUTOMATIC;
  }else if ("HARDWARE".equals(renderMode)){
    mode = RenderMode.HARDWARE;
  }else if ("SOFTWARE".equals(renderMode)){
    mode = RenderMode.SOFTWARE;
  }
  getOrCreatePropertyManager(view).setRenderMode(mode);
}
 
Example #8
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 5 votes vote down vote up
@ReactProp(name = "resizeMode")
public void setResizeMode(LottieAnimationView view, String resizeMode) {
  ImageView.ScaleType mode = null;
  if ("cover".equals(resizeMode)) {
    mode = ImageView.ScaleType.CENTER_CROP;
  } else if ("contain".equals(resizeMode)) {
    mode = ImageView.ScaleType.CENTER_INSIDE;
  } else if ("center".equals(resizeMode)) {
    mode = ImageView.ScaleType.CENTER;
  }
  getOrCreatePropertyManager(view).setScaleType(mode);
}
 
Example #9
Source File: LayoutFaceService.java    From io18watchface with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    int gravity = !insets.isRound() ? (Gravity.START | Gravity.TOP) :  Gravity.CENTER;
    setWatchFaceStyle(new WatchFaceStyle.Builder(LayoutFaceService.this)
            .setStatusBarGravity(gravity)
            .setAccentColor(0xff526cfe)
            .build());

    // Load the display spec - we'll need this later for measuring layoutRoot
    Point displaySize = new Point();
    ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getSize(displaySize);

    if (layoutRoot instanceof LinearLayout) {
        int height = (int) (displaySize.y * 0.28);
        int width = (int) (height * 0.62);
        for (LottieAnimationView digitView : digitViews) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) digitView.getLayoutParams();
            params.width = width;
            params.height = height;
        }
        //noinspection SuspiciousNameCombination
        layoutRoot.findViewById(R.id.logo).setLayoutParams(new LinearLayout.LayoutParams(height, height));
    }
    
    // Recompute the MeasureSpec fields - these determine the actual size of the layout
    int specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
    int specH = View.MeasureSpec.makeMeasureSpec(displaySize.y, View.MeasureSpec.EXACTLY);

    // Update the layout
    layoutRoot.measure(specW, specH);
    layoutRoot.layout(0, 0, layoutRoot.getMeasuredWidth(), layoutRoot.getMeasuredHeight());
}
 
Example #10
Source File: LottieViewCreator.java    From LottieBottomNav with MIT License 5 votes vote down vote up
private static void setLottieView(LottieAnimationView view, MenuItem menuItem, boolean isSelected) {

        switch (menuItem.lottieSource) {

            case Raw:
            case Assets:
                view.setAnimation(isSelected ? menuItem.selectedLottieName : menuItem.unselectedLottieName);
                view.pauseAnimation();
                view.setProgress(menuItem.lottieProgress);
                view.setRepeatCount(menuItem.loop ? Integer.MAX_VALUE : 0);
        }
    }
 
Example #11
Source File: BlankFragment.java    From Injector with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
	super.onViewCreated(view, savedInstanceState);
	final LottieAnimationView lottieAnimationView = view.findViewById(R.id.lottie_view);
	LottieCompositionFactory.fromAsset(getActivity(), "tick.json").addListener(result -> {
		System.out.println("Loaded!!!!!!!!!!!!!!");
		lottieAnimationView.setComposition(result);
		lottieAnimationView.playAnimation();
	}).addFailureListener(result -> result.printStackTrace());
	System.out.println("openning!!!!!!!!!!!!!!");
}
 
Example #12
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "imageAssetsFolder")
public void setImageAssetsFolder(LottieAnimationView view, String imageAssetsFolder) {
  getOrCreatePropertyManager(view).setImageAssetsFolder(imageAssetsFolder);
}
 
Example #13
Source File: Reaction.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public LottieAnimationView getView() {
  return view;
}
 
Example #14
Source File: BaseKbsPinFragment.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
protected LottieAnimationView getLottieProgress() {
  return lottieProgress;
}
 
Example #15
Source File: LoaderDecorator.java    From live-app-android with MIT License 4 votes vote down vote up
public void stop() {
    ((LottieAnimationView) findViewById(R.id.loader)).cancelAnimation();
    dismiss();
}
 
Example #16
Source File: LoaderDecorator.java    From live-app-android with MIT License 4 votes vote down vote up
public void start() {
    show();
    ((LottieAnimationView) findViewById(R.id.loader)).playAnimation();
}
 
Example #17
Source File: CommandRecognizingAnimationView.java    From black-mirror with MIT License 4 votes vote down vote up
void init(Context context) {
    inflate(context, R.layout.view_comand_recognizing_animation, this);
    animationView = (LottieAnimationView) findViewById(R.id.view_animation);
}
 
Example #18
Source File: BaseKbsPinFragment.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
protected LottieAnimationView getLottieEnd() {
  return lottieEnd;
}
 
Example #19
Source File: LottieAnimationViewPropertyManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the view with changed fields.
 * Majority of the properties here are independent so they are has to be reset to null
 * as soon as view is updated with the value.
 *
 * The only exception from this rule is the group of the properties for the animation.
 * For now this is animationName and cacheStrategy. These two properties are should be set
 * simultaneously if the dirty flag is set.
 */
public void commitChanges() {
  LottieAnimationView view = viewWeakReference.get();
  if (view == null) {
    return;
  }

  if (animationJson != null) {
    view.setAnimationFromJson(animationJson, Integer.toString(animationJson.hashCode()));
    animationJson = null;
  }

  if (animationNameDirty) {
    view.setAnimation(animationName);
    animationNameDirty = false;
  }

  if (progress != null) {
    view.setProgress(progress);
    progress = null;
  }

  if (loop != null) {
    view.setRepeatCount(loop ? LottieDrawable.INFINITE : 0);
    loop = null;
  }

  if (speed != null) {
    view.setSpeed(speed);
    speed = null;
  }

  if (scaleType != null) {
    view.setScaleType(scaleType);
    scaleType = null;
  }

  if (renderMode != null) {
    view.setRenderMode(renderMode);
    renderMode = null;
  }

  if (imageAssetsFolder != null) {
    view.setImageAssetsFolder(imageAssetsFolder);
    imageAssetsFolder = null;
  }

  if (enableMergePaths != null) {
    view.enableMergePathsForKitKatAndAbove(enableMergePaths);
    enableMergePaths = null;
  }

  if (colorFilters != null && colorFilters.size() > 0) {
    for (int i = 0 ; i < colorFilters.size() ; i++) {
      ReadableMap current = colorFilters.getMap(i);
      String color = current.getString("color");
      String path = current.getString("keypath");
      SimpleColorFilter colorFilter = new SimpleColorFilter(Color.parseColor(color));
      KeyPath keyPath = new KeyPath(path, "**");
      LottieValueCallback<ColorFilter> callback = new LottieValueCallback<>(colorFilter);
      view.addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback);
    }
  }
}
 
Example #20
Source File: LottieAnimationViewPropertyManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
public LottieAnimationViewPropertyManager(LottieAnimationView view) {
  this.viewWeakReference = new WeakReference<>(view);
}
 
Example #21
Source File: MessageRequestMegaphoneActivity.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState, boolean isReady) {
  dynamicTheme.onCreate(this);

  setContentView(R.layout.message_requests_megaphone_activity);


  LottieAnimationView lottie            = findViewById(R.id.message_requests_lottie);
  TextView            profileNameButton = findViewById(R.id.message_requests_confirm_profile_name);

  lottie.setAnimation(R.raw.lottie_message_requests_splash);
  lottie.playAnimation();

  profileNameButton.setOnClickListener(v -> {
    final Intent profile = new Intent(this, EditProfileActivity.class);

    profile.putExtra(EditProfileActivity.SHOW_TOOLBAR, false);
    profile.putExtra(EditProfileActivity.NEXT_BUTTON_TEXT, R.string.save);

    startActivityForResult(profile, EDIT_PROFILE_REQUEST_CODE);
  });
}
 
Example #22
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@Override
protected void onAfterUpdateTransaction(LottieAnimationView view) {
  super.onAfterUpdateTransaction(view);
  getOrCreatePropertyManager(view).commitChanges();
}
 
Example #23
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "colorFilters")
public void setColorFilters(LottieAnimationView view, ReadableArray colorFilters) {
  getOrCreatePropertyManager(view).setColorFilters(colorFilters);
}
 
Example #24
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "enableMergePathsAndroidForKitKatAndAbove")
public void setEnableMergePaths(LottieAnimationView view, boolean enableMergePaths) {
  getOrCreatePropertyManager(view).setEnableMergePaths(enableMergePaths);
}
 
Example #25
Source File: SplashActivity.java    From Awesome-WanAndroid with Apache License 2.0 4 votes vote down vote up
private void cancelAnimation(LottieAnimationView mLottieAnimationView) {
    if (mLottieAnimationView != null) {
        mLottieAnimationView.cancelAnimation();
    }
}
 
Example #26
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "loop")
public void setLoop(LottieAnimationView view, boolean loop) {
  getOrCreatePropertyManager(view).setLoop(loop);
}
 
Example #27
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "speed")
public void setSpeed(LottieAnimationView view, double speed) {
  getOrCreatePropertyManager(view).setSpeed((float)speed);
}
 
Example #28
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "progress")
public void setProgress(LottieAnimationView view, float progress) {
  getOrCreatePropertyManager(view).setProgress(progress);
}
 
Example #29
Source File: LottieAnimationViewManager.java    From lottie-react-native with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "sourceJson")
public void setSourceJson(LottieAnimationView view, String json) {
  getOrCreatePropertyManager(view).setAnimationJson(json);
}
 
Example #30
Source File: Spritz.java    From spritz with Apache License 2.0 4 votes vote down vote up
private Builder(LottieAnimationView lottieAnimationView) {
    this.lottieAnimationView = lottieAnimationView;
    spritzStepsWithOffset = new ArrayList<>();
}