use of com.aviary.android.feather.widget.ImageViewTouchAndDraw in project mobile-android by photo.
the class DrawingPanel method onGenerateResult.
/*
* (non-Javadoc)
*
* @see com.aviary.android.feather.effects.AbstractEffectPanel#onGenerateResult()
*/
@Override
protected void onGenerateResult() {
Bitmap bitmap = null;
if (!mBitmap.isMutable()) {
bitmap = BitmapUtils.copy(mBitmap, mBitmap.getConfig());
} else {
bitmap = mBitmap;
}
Canvas canvas = new Canvas(bitmap);
((ImageViewTouchAndDraw) mImageView).commit(canvas);
((ImageViewTouchAndDraw) mImageView).setImageBitmap(bitmap, false);
onComplete(bitmap, mActionList);
}
use of com.aviary.android.feather.widget.ImageViewTouchAndDraw in project mobile-android by photo.
the class DrawingPanel method onActivate.
/*
* (non-Javadoc)
*
* @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
*/
@Override
public void onActivate() {
super.onActivate();
disableHapticIsNecessary(mGalleryColor, mGallerySize);
initToast();
mGallerySize.setOnItemsScrollListener(new OnItemsScrollListener() {
@Override
public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
mSize = (Integer) mGallerySize.getAdapter().getItem(position);
final boolean soft = ((GallerySizeAdapter) mGallerySize.getAdapter()).getIsSoft(position);
if (soft)
mPaint.setMaskFilter(new BlurMaskFilter(mBlur, Blur.NORMAL));
else
mPaint.setMaskFilter(null);
updatePaint();
updateSelectedSize(view, position);
hideToastPreview();
}
@Override
public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
showToastPreview();
if (getSelectedTool() == DrawinTool.Zoom) {
setSelectedTool(DrawinTool.Draw);
}
}
@Override
public void onScroll(AdapterView<?> parent, View view, int position, long id) {
GallerySizeAdapter adapter = (GallerySizeAdapter) parent.getAdapter();
int size = (Integer) adapter.getItem(position);
int blur = adapter.getIsSoft(position) ? mBlur : 0;
boolean is_eraser = mGalleryColor.getSelectedItemPosition() == 0 || mGalleryColor.getSelectedItemPosition() == mGalleryColor.getAdapter().getCount() - 1;
if (is_eraser) {
updateToastPreview(size, Color.WHITE, blur, true);
} else {
updateToastPreview(size, mColor, blur, false);
}
}
});
mGalleryColor.setOnItemsScrollListener(new OnItemsScrollListener() {
@Override
public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
mColor = (Integer) parent.getAdapter().getItem(position);
final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
if (is_eraser) {
mColor = 0;
}
mPaint.setColor(mColor);
if (getSelectedTool() == DrawinTool.Zoom) {
if (is_eraser)
setSelectedTool(DrawinTool.Erase);
else
setSelectedTool(DrawinTool.Draw);
} else {
if (is_eraser && getSelectedTool() != DrawinTool.Erase)
setSelectedTool(DrawinTool.Erase);
else if (!is_eraser && getSelectedTool() != DrawinTool.Draw)
setSelectedTool(DrawinTool.Draw);
}
updatePaint();
updateSelectedColor(view, position);
hideToastPreview();
}
@Override
public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
showToastPreview();
if (getSelectedTool() == DrawinTool.Zoom) {
setSelectedTool(DrawinTool.Draw);
}
}
@Override
public void onScroll(AdapterView<?> parent, View view, int position, long id) {
final boolean is_eraser = position == 0 || (position == parent.getAdapter().getCount() - 1);
if (is_eraser) {
updateToastPreview(mSize, Color.WHITE, mBlur, true);
} else {
updateToastPreview(mSize, mBrushColors[position], mBlur, false);
}
}
});
mLensButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
boolean selected = arg0.isSelected();
arg0.setSelected(!selected);
if (arg0.isSelected()) {
setSelectedTool(DrawinTool.Zoom);
} else {
if (mGalleryColor.getSelectedItemPosition() == 0) {
setSelectedTool(DrawinTool.Erase);
} else {
setSelectedTool(DrawinTool.Draw);
}
updatePaint();
}
}
});
setSelectedTool(DrawinTool.Draw);
updatePaint();
updateSelectedSize((View) mGallerySize.getSelectedView(), mGallerySize.getSelectedItemPosition());
updateSelectedColor((View) mGalleryColor.getSelectedView(), mGalleryColor.getSelectedItemPosition());
((ImageViewTouchAndDraw) mImageView).setOnDrawStartListener(this);
((ImageViewTouchAndDraw) mImageView).setOnDrawPathListener(this);
mLensButton.setVisibility(View.VISIBLE);
getContentView().setVisibility(View.VISIBLE);
contentReady();
}
use of com.aviary.android.feather.widget.ImageViewTouchAndDraw in project mobile-android by photo.
the class DrawingPanel method setSelectedTool.
/**
* Sets the selected tool.
*
* @param which
* the new selected tool
*/
private void setSelectedTool(DrawinTool which) {
switch(which) {
case Draw:
((ImageViewTouchAndDraw) mImageView).setDrawMode(TouchMode.DRAW);
mPaint.setAlpha(255);
mPaint.setXfermode(null);
updatePaint();
break;
case Erase:
((ImageViewTouchAndDraw) mImageView).setDrawMode(TouchMode.DRAW);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mPaint.setAlpha(0);
updatePaint();
break;
case Zoom:
((ImageViewTouchAndDraw) mImageView).setDrawMode(TouchMode.IMAGE);
break;
}
mLensButton.setSelected(which == DrawinTool.Zoom);
setPanelEnabled(which != DrawinTool.Zoom);
mSelectedTool = which;
}
Aggregations