use of com.airbnb.lottie.OnCompositionLoadedListener in project lottie-android by airbnb.
the class LottieFontViewGroup method onKeyUp.
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SPACE) {
addSpace();
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL) {
removeLastView();
return true;
}
if (!isValidKey(event)) {
return super.onKeyUp(keyCode, event);
}
String letter = "" + Character.toUpperCase((char) event.getUnicodeChar());
// switch (letter) {
// case ",":
// letter = "Comma";
// break;
// case "'":
// letter = "Apostrophe";
// break;
// case ";":
// case ":":
// letter = "Colon";
// break;
// }
final String fileName = "Mobilo/" + letter + ".json";
if (compositionMap.containsKey(fileName)) {
addComposition(compositionMap.get(fileName));
} else {
LottieComposition.Factory.fromAssetFileName(getContext(), fileName, new OnCompositionLoadedListener() {
@Override
public void onCompositionLoaded(LottieComposition composition) {
compositionMap.put(fileName, composition);
addComposition(composition);
}
});
}
return true;
}
use of com.airbnb.lottie.OnCompositionLoadedListener 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;
}
use of com.airbnb.lottie.OnCompositionLoadedListener 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);
}
Aggregations