Search in sources :

Example 11 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by WhisperSystems.

the class MessageRequestMegaphoneActivity method onCreate.

@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);
    });
}
Also used : TextView(android.widget.TextView) Intent(android.content.Intent) LottieAnimationView(com.airbnb.lottie.LottieAnimationView)

Example 12 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project atlas by alibaba.

the class LottieFontViewGroup method init.

private void init() {
    final float density = getContext().getResources().getDisplayMetrics().density;
    textSize = (int) (density * 120);
    for (int x = 0; x < 5; x++) {
        cursorView = new LottieAnimationView(getContext());
        cursorView.setLayoutParams(new LayoutParams(textSize, textSize));
        addView(cursorView);
        views.add(cursorView);
    }
    this.postDelayed(new Runnable() {

        @Override
        public void run() {
            LottieComposition.Factory.fromAssetFileName(getContext(), "A.json", new OnCompositionLoadedListener() {

                @Override
                public void onCompositionLoaded(LottieComposition composition) {
                    views.get(0).setBackgroundDrawable(new ColorDrawable(0x112233));
                    views.get(0).setComposition(composition);
                    views.get(0).playAnimation();
                }
            });
        }
    }, 300);
    this.postDelayed(new Runnable() {

        @Override
        public void run() {
            LottieComposition.Factory.fromAssetFileName(getContext(), "T.json", new OnCompositionLoadedListener() {

                @Override
                public void onCompositionLoaded(LottieComposition composition) {
                    views.get(1).setComposition(composition);
                    views.get(1).playAnimation();
                }
            });
        }
    }, 300);
    this.postDelayed(new Runnable() {

        @Override
        public void run() {
            LottieComposition.Factory.fromAssetFileName(getContext(), "L.json", new OnCompositionLoadedListener() {

                @Override
                public void onCompositionLoaded(LottieComposition composition) {
                    views.get(2).setComposition(composition);
                    views.get(2).playAnimation();
                }
            });
        }
    }, 300);
    this.postDelayed(new Runnable() {

        @Override
        public void run() {
            LottieComposition.Factory.fromAssetFileName(getContext(), "A.json", new OnCompositionLoadedListener() {

                @Override
                public void onCompositionLoaded(LottieComposition composition) {
                    views.get(3).setComposition(composition);
                    views.get(3).playAnimation();
                }
            });
        }
    }, 300);
    this.postDelayed(new Runnable() {

        @Override
        public void run() {
            LottieComposition.Factory.fromAssetFileName(getContext(), "S.json", new OnCompositionLoadedListener() {

                @Override
                public void onCompositionLoaded(LottieComposition composition) {
                    views.get(4).setComposition(composition);
                    views.get(4).playAnimation();
                }
            });
        }
    }, 300);
}
Also used : OnCompositionLoadedListener(com.airbnb.lottie.OnCompositionLoadedListener) ColorDrawable(android.graphics.drawable.ColorDrawable) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) LottieComposition(com.airbnb.lottie.LottieComposition)

Example 13 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project iosched by google.

the class MyIOFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mLoadingSwitcher = (ViewSwitcher) view.findViewById(R.id.loading_switcher);
    mLoadingView = (LottieAnimationView) view.findViewById(R.id.loading_anim);
    mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list);
    mRecyclerView.addItemDecoration(new DividerDecoration(getContext()));
    mAdapter = new MyIOAdapter(getContext(), this);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new StickyHeadersLinearLayoutManager<MyIOAdapter>(getContext()));
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            mScrolled = true;
            recyclerView.removeOnScrollListener(this);
        }
    });
    View header = view.findViewById(R.id.header_anim);
    if (header instanceof ImageView) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.avd_header_my_io);
        ((ImageView) header).setImageDrawable(avd);
        avd.start();
    }
}
Also used : DividerDecoration(com.google.samples.apps.iosched.schedule.DividerDecoration) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) ImageView(android.widget.ImageView) View(android.view.View) MyIoView(com.google.samples.apps.iosched.myio.MyIOContract.MyIoView) RecyclerView(android.support.v7.widget.RecyclerView) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 14 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by signalapp.

the class PaymentsHomeFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.payments_home_fragment_toolbar);
    RecyclerView recycler = view.findViewById(R.id.payments_home_fragment_recycler);
    View header = view.findViewById(R.id.payments_home_fragment_header);
    MoneyView balance = view.findViewById(R.id.payments_home_fragment_header_balance);
    TextView exchange = view.findViewById(R.id.payments_home_fragment_header_exchange);
    View addMoney = view.findViewById(R.id.button_start_frame);
    View sendMoney = view.findViewById(R.id.button_end_frame);
    View refresh = view.findViewById(R.id.payments_home_fragment_header_refresh);
    LottieAnimationView refreshAnimation = view.findViewById(R.id.payments_home_fragment_header_refresh_animation);
    toolbar.setNavigationOnClickListener(v -> {
        viewModel.markAllPaymentsSeen();
        requireActivity().finish();
    });
    toolbar.setOnMenuItemClickListener(this::onMenuItemSelected);
    addMoney.setOnClickListener(v -> {
        if (SignalStore.paymentsValues().getPaymentsAvailability().isSendAllowed()) {
            SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsHomeFragmentDirections.actionPaymentsHomeToPaymentsAddMoney());
        } else {
            showPaymentsDisabledDialog();
        }
    });
    sendMoney.setOnClickListener(v -> {
        if (SignalStore.paymentsValues().getPaymentsAvailability().isSendAllowed()) {
            SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsHomeFragmentDirections.actionPaymentsHomeToPaymentRecipientSelectionFragment());
        } else {
            showPaymentsDisabledDialog();
        }
    });
    PaymentsHomeAdapter adapter = new PaymentsHomeAdapter(new HomeCallbacks());
    recycler.setAdapter(adapter);
    viewModel = ViewModelProviders.of(this, new PaymentsHomeViewModel.Factory()).get(PaymentsHomeViewModel.class);
    viewModel.getList().observe(getViewLifecycleOwner(), list -> {
        boolean hadPaymentItems = Stream.of(adapter.getCurrentList()).anyMatch(model -> model instanceof PaymentItem);
        if (!hadPaymentItems) {
            adapter.submitList(list, () -> recycler.scrollToPosition(0));
        } else {
            adapter.submitList(list);
        }
    });
    viewModel.getPaymentsEnabled().observe(getViewLifecycleOwner(), enabled -> {
        if (enabled) {
            toolbar.inflateMenu(R.menu.payments_home_fragment_menu);
        } else {
            toolbar.getMenu().clear();
        }
        header.setVisibility(enabled ? View.VISIBLE : View.GONE);
    });
    viewModel.getBalance().observe(getViewLifecycleOwner(), balance::setMoney);
    viewModel.getExchange().observe(getViewLifecycleOwner(), amount -> {
        if (amount != null) {
            exchange.setText(FiatMoneyUtil.format(getResources(), amount));
        } else {
            exchange.setText(R.string.PaymentsHomeFragment__unknown_amount);
        }
    });
    refresh.setOnClickListener(v -> viewModel.refreshExchangeRates(true));
    exchange.setOnClickListener(v -> viewModel.refreshExchangeRates(true));
    viewModel.getExchangeLoadState().observe(getViewLifecycleOwner(), loadState -> {
        switch(loadState) {
            case INITIAL:
            case LOADED:
                refresh.setVisibility(View.VISIBLE);
                refreshAnimation.cancelAnimation();
                refreshAnimation.setVisibility(View.GONE);
                break;
            case LOADING:
                refresh.setVisibility(View.INVISIBLE);
                refreshAnimation.playAnimation();
                refreshAnimation.setVisibility(View.VISIBLE);
                break;
            case ERROR:
                refresh.setVisibility(View.VISIBLE);
                refreshAnimation.cancelAnimation();
                refreshAnimation.setVisibility(View.GONE);
                exchange.setText(R.string.PaymentsHomeFragment__currency_conversion_not_available);
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__cant_display_currency_conversion, Toast.LENGTH_SHORT).show();
                break;
        }
    });
    viewModel.getPaymentStateEvents().observe(getViewLifecycleOwner(), paymentStateEvent -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
        builder.setTitle(R.string.PaymentsHomeFragment__deactivate_payments_question);
        builder.setMessage(R.string.PaymentsHomeFragment__you_will_not_be_able_to_send);
        builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
        switch(paymentStateEvent) {
            case NO_BALANCE:
                Toast.makeText(requireContext(), R.string.PaymentsHomeFragment__balance_is_not_currently_available, Toast.LENGTH_SHORT).show();
                return;
            case DEACTIVATED:
                Snackbar.make(requireView(), R.string.PaymentsHomeFragment__payments_deactivated, Snackbar.LENGTH_SHORT).setTextColor(Color.WHITE).show();
                return;
            case DEACTIVATE_WITHOUT_BALANCE:
                builder.setPositiveButton(SpanUtil.color(ContextCompat.getColor(requireContext(), R.color.signal_alert_primary), getString(R.string.PaymentsHomeFragment__deactivate)), (dialog, which) -> {
                    viewModel.confirmDeactivatePayments();
                    dialog.dismiss();
                });
                break;
            case DEACTIVATE_WITH_BALANCE:
                builder.setPositiveButton(getString(R.string.PaymentsHomeFragment__continue), (dialog, which) -> {
                    dialog.dismiss();
                    SafeNavigation.safeNavigate(NavHostFragment.findNavController(this), R.id.deactivateWallet);
                });
                break;
            case ACTIVATED:
                return;
            default:
                throw new IllegalStateException("Unsupported event type: " + paymentStateEvent.name());
        }
        builder.show();
    });
    viewModel.getErrorEnablingPayments().observe(getViewLifecycleOwner(), errorEnabling -> {
        switch(errorEnabling) {
            case REGION:
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__payments_is_not_available_in_your_region, Toast.LENGTH_LONG).show();
                break;
            case NETWORK:
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__could_not_enable_payments, Toast.LENGTH_SHORT).show();
                break;
            default:
                throw new AssertionError();
        }
    });
    requireActivity().getOnBackPressedDispatcher().addCallback(onBackPressed);
}
Also used : AlertDialog(android.app.AlertDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextView(android.widget.TextView) PaymentItem(org.thoughtcrime.securesms.payments.preferences.model.PaymentItem) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by signalapp.

the class MessageRequestMegaphoneActivity method onCreate.

@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);
    });
}
Also used : TextView(android.widget.TextView) Intent(android.content.Intent) LottieAnimationView(com.airbnb.lottie.LottieAnimationView)

Aggregations

LottieAnimationView (com.airbnb.lottie.LottieAnimationView)15 View (android.view.View)7 TextView (android.widget.TextView)5 Animator (android.animation.Animator)4 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)4 Intent (android.content.Intent)3 Activity (android.app.Activity)2 AlertDialog (android.app.AlertDialog)2 ImageView (android.widget.ImageView)2 NonNull (androidx.annotation.NonNull)2 RawRes (androidx.annotation.RawRes)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 Toolbar (androidx.appcompat.widget.Toolbar)2 HintConstants (androidx.autofill.HintConstants)2 ContextCompat (androidx.core.content.ContextCompat)2 ViewCompat (androidx.core.view.ViewCompat)2 ViewModelProviders (androidx.lifecycle.ViewModelProviders)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 LottieComposition (com.airbnb.lottie.LottieComposition)2 LottieDrawable (com.airbnb.lottie.LottieDrawable)2