use of com.aviary.android.feather.library.filters.StickerFilter in project mobile-android by photo.
the class StickersPanel method addSticker.
/**
* Add a new sticker to the canvas.
*
* @param drawable
* - the drawable name
*/
private void addSticker(String drawable, RectF position) {
if (mPlugin == null || !(mPlugin instanceof InternalPlugin)) {
return;
}
final InternalPlugin plugin = (InternalPlugin) mPlugin;
onApplyCurrent();
final boolean rotateAndResize = true;
InputStream stream = null;
try {
stream = plugin.getStickerStream(drawable, StickerType.Small);
} catch (Exception e) {
e.printStackTrace();
onGenericError("Failed to load the selected sticker");
return;
}
if (stream != null) {
StickerDrawable d = new StickerDrawable(plugin.getResources(), stream, drawable, plugin.getLabel(FeatherIntent.PluginType.TYPE_STICKER).toString());
d.setAntiAlias(true);
IOUtils.closeSilently(stream);
// adding the required action
ApplicationInfo info = PackageManagerUtils.getApplicationInfo(getContext().getBaseContext(), mPlugin.getPackageName());
if (info != null) {
String sourceDir = plugin.getSourceDir(PluginType.TYPE_STICKER);
if (null == sourceDir) {
sourceDir = "";
mLogger.error("Cannot find the source dir");
}
mCurrentFilter = new StickerFilter(sourceDir, drawable);
mCurrentFilter.setSize(d.getBitmapWidth(), d.getBitmapHeight());
mCurrentFilter.setExternal(0);
Tracker.recordTag(drawable + ": Selected");
addSticker(d, rotateAndResize, position);
} else {
onGenericError("Sorry I'm not able to load the selected sticker");
}
}
}
Aggregations