Search in sources :

Example 1 with ImageViewSpotDraw

use of com.aviary.android.feather.widget.ImageViewSpotDraw in project mobile-android by photo.

the class SpotDrawPanel method onActivate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
	 */
@Override
public void onActivate() {
    super.onActivate();
    ((ImageViewSpotDraw) mImageView).setOnDrawStartListener(this);
    mBackgroundDrawThread.start();
    mBackgroundDrawThread.setRadius((float) Math.max(1, mBrushSizes[0]), mPreviewWidth);
    updateSelection((View) mGallery.getSelectedView(), mGallery.getSelectedItemPosition());
    mToast = IToast.make(getContext().getBaseContext(), -1);
    mCircleDrawablePreview = new PreviewCircleDrawable(0);
    ImageView image = (ImageView) mToast.getView().findViewById(R.id.size_preview_image);
    image.setImageDrawable(mCircleDrawablePreview);
    mLensButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // boolean selected = arg0.isSelected();
            setSelectedTool(((ImageViewSpotDraw) mImageView).getDrawMode() == TouchMode.DRAW ? TouchMode.IMAGE : TouchMode.DRAW);
        }
    });
    mLensButton.setVisibility(View.VISIBLE);
    contentReady();
}
Also used : PreviewCircleDrawable(com.aviary.android.feather.graphics.PreviewCircleDrawable) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Example 2 with ImageViewSpotDraw

use of com.aviary.android.feather.widget.ImageViewSpotDraw in project mobile-android by photo.

the class DelayedSpotDrawPanel method onCreate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onCreate(android.graphics.Bitmap)
	 */
@Override
public void onCreate(Bitmap bitmap) {
    super.onCreate(bitmap);
    ConfigService config = getContext().getService(ConfigService.class);
    mBrushSizes = config.getSizeArray(R.array.feather_spot_brush_sizes);
    mBrushSize = mBrushSizes[0];
    defaultOption = Math.min(mBrushSizes.length - 1, Math.max(0, config.getInteger(R.integer.feather_spot_brush_selected_size_index)));
    mLensButton = (ImageButton) getContentView().findViewById(R.id.lens_button);
    mImageView = (ImageViewSpotDraw) getContentView().findViewById(R.id.image);
    ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
    ((ImageViewSpotDraw) mImageView).setDrawLimit(mLimitDrawArea ? 1000.0 : 0.0);
    mPreview = BitmapUtils.copy(mBitmap, Config.ARGB_8888);
    mImageView.setImageBitmap(mPreview, true, getContext().getCurrentImageViewMatrix(), UIConfiguration.IMAGE_VIEW_MAX_ZOOM);
    mGallery = (Gallery) getOptionView().findViewById(R.id.gallery);
    mGallery.setCallbackDuringFling(false);
    mGallery.setSpacing(0);
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mBrushSize = mBrushSizes[position];
            ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
            setSelectedTool(TouchMode.DRAW);
            updateSelection(view, position);
            hideSizePreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showSizePreview(mBrushSizes[position]);
            setSelectedTool(TouchMode.DRAW);
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            updateSizePreview(mBrushSizes[position]);
        }
    });
    mBackgroundDrawThread = new MyHandlerThread("filter-thread", Thread.MIN_PRIORITY);
    initAdapter();
}
Also used : ConfigService(com.aviary.android.feather.library.services.ConfigService) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Example 3 with ImageViewSpotDraw

use of com.aviary.android.feather.widget.ImageViewSpotDraw in project mobile-android by photo.

the class SpotDrawPanel method onCreate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onCreate(android.graphics.Bitmap)
	 */
@Override
public void onCreate(Bitmap bitmap) {
    super.onCreate(bitmap);
    mFilter = createFilter();
    ConfigService config = getContext().getService(ConfigService.class);
    mBrushSizes = config.getSizeArray(R.array.feather_spot_brush_sizes);
    mBrushSize = mBrushSizes[0];
    mLensButton = (ImageButton) getContentView().findViewById(R.id.lens_button);
    mImageView = (ImageViewSpotDraw) getContentView().findViewById(R.id.image);
    ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
    mPreview = BitmapUtils.copy(mBitmap, Config.ARGB_8888);
    mPreviewWidth = mPreview.getWidth();
    mPreviewHeight = mPreview.getHeight();
    mImageView.setImageBitmap(mPreview, true, getContext().getCurrentImageViewMatrix(), UIConfiguration.IMAGE_VIEW_MAX_ZOOM);
    int defaultOption = config.getInteger(R.integer.feather_spot_brush_selected_size_index);
    defaultOption = Math.min(Math.max(defaultOption, 0), mBrushSizes.length - 1);
    mGallery = (Gallery) getOptionView().findViewById(R.id.gallery);
    mGallery.setCallbackDuringFling(false);
    mGallery.setSpacing(0);
    mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {

        @Override
        public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
            mLogger.info("onScrollFinished: " + position);
            mBrushSize = mBrushSizes[position];
            ((ImageViewSpotDraw) mImageView).setBrushSize((float) mBrushSize);
            setSelectedTool(TouchMode.DRAW);
            updateSelection(view, position);
            hideSizePreview();
        }

        @Override
        public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
            showSizePreview(mBrushSizes[position]);
            setSelectedTool(TouchMode.DRAW);
        }

        @Override
        public void onScroll(AdapterView<?> parent, View view, int position, long id) {
            updateSizePreview(mBrushSizes[position]);
        }
    });
    mBackgroundDrawThread = new MyHandlerThread("filter-thread", Thread.MIN_PRIORITY);
    initAdapter();
}
Also used : ConfigService(com.aviary.android.feather.library.services.ConfigService) OnItemsScrollListener(com.aviary.android.feather.widget.Gallery.OnItemsScrollListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Example 4 with ImageViewSpotDraw

use of com.aviary.android.feather.widget.ImageViewSpotDraw in project mobile-android by photo.

the class DelayedSpotDrawPanel method onActivate.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
	 */
@Override
public void onActivate() {
    super.onActivate();
    disableHapticIsNecessary(mGallery);
    ((ImageViewSpotDraw) mImageView).setOnDrawStartListener(this);
    mBackgroundDrawThread.start();
    mBackgroundDrawThread.setRadius((float) Math.max(1, mBrushSizes[0]), mPreview.getWidth());
    mToast = IToast.make(getContext().getBaseContext(), -1);
    mCircleDrawablePreview = new PreviewCircleDrawable(0);
    ImageView image = (ImageView) mToast.getView().findViewById(R.id.size_preview_image);
    image.setImageDrawable(mCircleDrawablePreview);
    mLensButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // boolean selected = arg0.isSelected();
            setSelectedTool(((ImageViewSpotDraw) mImageView).getDrawMode() == TouchMode.DRAW ? TouchMode.IMAGE : TouchMode.DRAW);
        }
    });
    mLensButton.setVisibility(View.VISIBLE);
    // TODO: check if selection is correct when panel opens
    // updateSelection( (View) mGallery.getSelectedView(), mGallery.getSelectedItemPosition() );
    contentReady();
}
Also used : PreviewCircleDrawable(com.aviary.android.feather.graphics.PreviewCircleDrawable) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(com.aviary.android.feather.widget.AdapterView) ImageViewSpotDraw(com.aviary.android.feather.widget.ImageViewSpotDraw)

Aggregations

View (android.view.View)4 ImageView (android.widget.ImageView)4 AdapterView (com.aviary.android.feather.widget.AdapterView)4 ImageViewSpotDraw (com.aviary.android.feather.widget.ImageViewSpotDraw)4 OnClickListener (android.view.View.OnClickListener)2 PreviewCircleDrawable (com.aviary.android.feather.graphics.PreviewCircleDrawable)2 ConfigService (com.aviary.android.feather.library.services.ConfigService)2 OnItemsScrollListener (com.aviary.android.feather.widget.Gallery.OnItemsScrollListener)2