use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin in project mobile-android by photo.
the class BordersPanel method loadNativeFilter.
protected INativeFilter loadNativeFilter(final EffectPack pack, int position, final CharSequence label, boolean hires) {
BorderFilter filter = (BorderFilter) FilterLoaderFactory.get(Filters.BORDERS);
filter.setBorderName(label);
filter.setHiRes(hires);
IPlugin plugin = pack.mPluginRef;
if (null != plugin) {
if (plugin instanceof InternalPlugin) {
filter.setSourceApp(((InternalPlugin) plugin).getSourceDir(mPluginType));
// border size
int[] sizes = ((InternalPlugin) plugin).listBordersWidths();
position -= pack.getIndex();
if (null != sizes && sizes.length > (position - 1) && position > 0) {
int borderSize = sizes[position - 1];
filter.setSize((double) borderSize / 100.0);
}
}
}
return filter;
}
use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin in project mobile-android by photo.
the class StickersPanel method startDrag.
// ////////////////////////
// Drag and Drop methods //
// ////////////////////////
/**
* Starts the drag and drop operation
*
* @param parent
* - the parent list
* @param view
* - the current view clicked
* @param position
* - the position in the list
* @param id
* - the item id
* @param nativeClick
* - it's a native click
* @return
*/
private boolean startDrag(AdapterView<?> parent, View view, int position, long id, boolean animate) {
mLogger.info("startDrag");
if (android.os.Build.VERSION.SDK_INT < 9)
return false;
if (parent == null || view == null || parent.getAdapter() == null) {
return false;
}
if (mStatus.getCurrentStatus() != STATUS_STICKERS)
return false;
if (mPlugin == null || !(mPlugin instanceof InternalPlugin))
return false;
if (null != view) {
View image = view.findViewById(R.id.image);
if (null != image) {
final String dragInfo = (String) parent.getAdapter().getItem(position);
int size = mThumbSize;
Bitmap bitmap;
try {
bitmap = ImageLoader.getPluginItemBitmap((InternalPlugin) mPlugin, dragInfo, FeatherIntent.PluginType.TYPE_STICKER, StickerType.Small, size, size);
int offsetx = Math.abs(image.getWidth() - bitmap.getWidth()) / 2;
int offsety = Math.abs(image.getHeight() - bitmap.getHeight()) / 2;
return getDragController().startDrag(image, bitmap, offsetx, offsety, StickersPanel.this, dragInfo, DragControllerService.DRAG_ACTION_MOVE, animate);
} catch (Exception e) {
e.printStackTrace();
}
return getDragController().startDrag(image, StickersPanel.this, dragInfo, DragControllerService.DRAG_ACTION_MOVE, animate);
}
}
return false;
}
use of com.aviary.android.feather.library.plugins.PluginManager.InternalPlugin 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