use of com.airbnb.lottie.LottieAnimationView in project Rocket by mozilla-tw.
the class ScreenCaptureDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_capture_screen, container, false);
mLottieAnimationView = (LottieAnimationView) view.findViewById(R.id.animation_view);
return view;
}
use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by WhisperSystems.
the class ConfirmKbsPinFragment method startEndAnimationOnNextProgressRepetition.
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);
}
}
use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by WhisperSystems.
the class ConfirmKbsPinFragment method updateSaveAnimation.
private void updateSaveAnimation(@NonNull ConfirmKbsPinViewModel.SaveAnimation animation) {
updateAnimationAndInputVisibility(animation);
LottieAnimationView lottieProgress = getLottieProgress();
switch(animation) {
case NONE:
lottieProgress.cancelAnimation();
break;
case LOADING:
lottieProgress.setAnimation(R.raw.lottie_kbs_loading);
lottieProgress.setRepeatMode(LottieDrawable.RESTART);
lottieProgress.setRepeatCount(LottieDrawable.INFINITE);
lottieProgress.playAnimation();
break;
case SUCCESS:
startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_success, new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
requireActivity().setResult(Activity.RESULT_OK);
closeNavGraphBranch();
RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
StorageSyncHelper.scheduleSyncForDataChange();
}
});
break;
case FAILURE:
startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_fail, new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
displayFailedDialog();
}
});
break;
}
}
use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by WhisperSystems.
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);
}
use of com.airbnb.lottie.LottieAnimationView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsHomepageActivity method recreateSpacer.
private void recreateSpacer() {
homepageSpacer = findViewById(R.id.settings_homepage_spacer);
homepageMainLayout = findViewById(R.id.main_content_scrollable_container);
LottieAnimationView view = homepageSpacer.findViewById(R.id.home_animation);
TextView tv = homepageSpacer.findViewById(R.id.spacer_text);
iv = homepageSpacer.findViewById(R.id.spacer_image);
mCustomImage = homepageSpacer.findViewById(R.id.custom_image);
mStockDrawable = context.getDrawable(R.drawable.rr_spacer);
Drawable rrDrawable = context.getDrawable(R.drawable.rr_spacer_main_icon);
Drawable rrDrawable2 = context.getDrawable(R.drawable.rr_main_conf_shortcut_icon_primay);
Drawable rrDrawable3 = context.getDrawable(R.drawable.rr_main_conf_shortcut_icon);
final int spacermargin = getResources().getDimensionPixelSize(R.dimen.homepage_spacer_height);
try {
RRFontHelper.setFontType(tv, getFontStyle());
tv.setTextSize(getFontSize());
if (configAnim() == 0) {
if (isProfileAvatar() == 1) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.VISIBLE);
iv.setImageDrawable(getCircularUserIcon(context));
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$UserSettingsActivity"));
startActivity(intent);
}
});
} else if (isProfileAvatar() == 0) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.VISIBLE);
iv.setClickable(false);
if (mStockDrawable != null) {
iv.setImageDrawable(mStockDrawable);
}
} else if (isProfileAvatar() == 2) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.VISIBLE);
if (rrDrawable != null) {
iv.setImageDrawable(rrDrawable);
}
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
startActivity(intent);
}
});
} else if (isProfileAvatar() == 3) {
iv.setVisibility(View.GONE);
BitmapDrawable bp = getCustomImageFromString(SPACER_IMAGE, context);
if (bp == null)
Log.d(TAG, "Bitmap is null!!");
if (bp != null) {
if (isCrop() == 0) {
homepageSpacer.setBackground(bp);
mCustomImage.setVisibility(View.GONE);
} else {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(bp);
mCustomImage.setVisibility(View.VISIBLE);
}
}
} else if (isProfileAvatar() == 4) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.VISIBLE);
if (rrDrawable2 != null) {
iv.setImageDrawable(rrDrawable2);
}
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
startActivity(intent);
}
});
} else if (isProfileAvatar() == 5) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.VISIBLE);
if (rrDrawable3 != null) {
iv.setImageDrawable(rrDrawable3);
}
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
startActivity(intent);
}
});
}
tv.setVisibility(View.GONE);
view.setVisibility(View.GONE);
} else if (configAnim() == 1) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.GONE);
tv.setVisibility(View.GONE);
view.setVisibility(View.VISIBLE);
} else if (configAnim() == 2) {
mCustomImage.setImageDrawable(null);
homepageSpacer.setBackground(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.GONE);
tv.setVisibility(View.VISIBLE);
view.setVisibility(View.GONE);
} else if (configAnim() == 3) {
homepageSpacer.setBackground(null);
mCustomImage.setImageDrawable(null);
mCustomImage.setVisibility(View.GONE);
iv.setVisibility(View.GONE);
tv.setVisibility(View.GONE);
view.setVisibility(View.GONE);
}
if (avatarView != null) {
avatarView.setVisibility(isSearchDisabled() ? View.GONE : View.VISIBLE);
}
} catch (Exception e) {
}
if (!isHomepageSpacerEnabled() && homepageSpacer != null && homepageMainLayout != null) {
homepageSpacer.setVisibility(View.GONE);
setMargins(homepageMainLayout, 0, 0, 0, 0);
} else if (isHomepageSpacerEnabled() && homepageSpacer != null && homepageMainLayout != null) {
homepageSpacer.setVisibility(View.VISIBLE);
setMargins(homepageMainLayout, 0, spacermargin, 0, 0);
}
}
Aggregations