Android Open Source - Aviary-Android-SDK Gallery Bottom Indicator Drawable






From Project

Back to project page Aviary-Android-SDK.

License

The source code is released under:

AVIARY API TERMS OF USE Full Legal Agreement The following terms and conditions and the terms and conditions at http://www.aviary.com/terms (collectively, the ?Terms??) govern your use of any and ...

If you think the Android project Aviary-Android-SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.aviary.android.feather.graphics;
/*  ww w  .  jav a2  s. com*/
import android.content.Context;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

import com.aviary.android.feather.R;

/**
 * Drawable used to draw the gallery top indicator
 * 
 * @author alessandro
 */
public class GalleryBottomIndicatorDrawable extends Drawable {

  int mShadowColor, mFillColor, mStrokeColor1, mStrokeColor2;
  float mIndicatorSize;
  int mStrokeWidth;
  int mShadowDy;

  final Rect destRect = new Rect();
  final Paint paint;

  public GalleryBottomIndicatorDrawable ( Context context ) {
    Theme theme = context.getTheme();
    TypedArray array = theme.obtainStyledAttributes( null, R.styleable.AviaryGalleryTopIndicator, R.attr.aviaryOptionPanelTopIndicatorStyle, 0 );

    mShadowColor = array.getColor( R.styleable.AviaryGalleryTopIndicator_android_shadowColor, 0 );
    mShadowDy = (int) array.getFloat( R.styleable.AviaryGalleryTopIndicator_android_shadowDy, 0f );
    mFillColor = array.getColor( R.styleable.AviaryGalleryTopIndicator_aviary_color1, Color.WHITE );
    mStrokeColor1 = array.getColor( R.styleable.AviaryGalleryTopIndicator_aviary_strokeColor, Color.WHITE );
    mStrokeColor2 = array.getColor( R.styleable.AviaryGalleryTopIndicator_aviary_strokeColor2, Color.WHITE );
    mIndicatorSize = array.getFloat( R.styleable.AviaryGalleryTopIndicator_aviary_indicatorSize, 1f );
    mStrokeWidth = array.getDimensionPixelSize( R.styleable.AviaryGalleryTopIndicator_aviary_strokeWidth, 2 );

    array.recycle();

    paint = new Paint( Paint.ANTI_ALIAS_FLAG );
  }

  @Override
  public void draw( Canvas canvas ) {
    copyBounds( destRect );

    int halfHeight = destRect.height() / 2;
    int halfWidth = destRect.width() / 2;
    int triangleSize = (int) ( halfHeight * mIndicatorSize );

    int top = destRect.top + mStrokeWidth / 2;
    int left = destRect.left - mStrokeWidth;
    int right = destRect.right + mStrokeWidth;

    Path path = new Path();
    path.moveTo( left, top );
    path.lineTo( right, top );
    path.lineTo( right, top + halfHeight );

    path.lineTo( left + halfWidth + triangleSize, top + halfHeight );
    path.lineTo( left + halfWidth, top + halfHeight + triangleSize );
    path.lineTo( left + halfWidth - triangleSize, top + halfHeight );

    path.lineTo( left, top + halfHeight );
    path.lineTo( left, top );

    paint.setStyle( Style.FILL );

    if ( mShadowDy > 0 ) {
      path.offset( 0, mShadowDy );
      paint.setColor( mShadowColor );
      canvas.drawPath( path, paint );
      path.offset( 0, -mShadowDy );
    }

    paint.setColor( mFillColor );
    canvas.drawPath( path, paint );

    paint.setStyle( Style.STROKE );
    paint.setColor( mStrokeColor1 );
    paint.setStrokeWidth( mStrokeWidth );
    canvas.drawPath( path, paint );

    paint.setStyle( Style.STROKE );
    paint.setColor( mStrokeColor2 );
    canvas.drawLine( left + mStrokeWidth, top + mStrokeWidth, right - mStrokeWidth, top + mStrokeWidth, paint );

  }

  @Override
  public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
  }

  @Override
  public void setAlpha( int alpha ) {}

  @Override
  public void setColorFilter( ColorFilter cf ) {}

}




Java Source Code List

com.aviary.android.feather.AlertActivity.java
com.aviary.android.feather.AviaryMainController.java
com.aviary.android.feather.FeatherActivity.java
com.aviary.android.feather.async_tasks.AsyncImageManager.java
com.aviary.android.feather.async_tasks.DownloadImageAsyncTask.java
com.aviary.android.feather.async_tasks.ExifTask.java
com.aviary.android.feather.effects.AbstractContentPanel.java
com.aviary.android.feather.effects.AbstractOptionPanel.java
com.aviary.android.feather.effects.AbstractPanelLoaderService.java
com.aviary.android.feather.effects.AbstractPanel.java
com.aviary.android.feather.effects.AdjustEffectPanel.java
com.aviary.android.feather.effects.BordersPanel.java
com.aviary.android.feather.effects.ColorSplashPanel.java
com.aviary.android.feather.effects.CropPanel.java
com.aviary.android.feather.effects.DelayedSpotDrawPanel.java
com.aviary.android.feather.effects.DrawingPanel.java
com.aviary.android.feather.effects.EffectsPanel.java
com.aviary.android.feather.effects.EnhanceEffectPanel.java
com.aviary.android.feather.effects.MemePanel.java
com.aviary.android.feather.effects.NativeEffectRangePanel.java
com.aviary.android.feather.effects.SimpleStatusMachine.java
com.aviary.android.feather.effects.SliderEffectPanel.java
com.aviary.android.feather.effects.StickersPanel.java
com.aviary.android.feather.effects.TextPanel.java
com.aviary.android.feather.effects.TiltShiftPanel.java
com.aviary.android.feather.graphics.CdsPreviewTransformer.java
com.aviary.android.feather.graphics.GalleryBottomIndicatorDrawable.java
com.aviary.android.feather.graphics.GalleryTopIndicatorDrawable.java
com.aviary.android.feather.graphics.GlowBitmapDrawable.java
com.aviary.android.feather.graphics.GlowDrawable.java
com.aviary.android.feather.graphics.PluginDividerDrawable.java
com.aviary.android.feather.graphics.PreviewFillColorDrawable.java
com.aviary.android.feather.graphics.PreviewSpotDrawable.java
com.aviary.android.feather.graphics.RepeatableHorizontalDrawable.java
com.aviary.android.feather.opengl.AviaryGLSurfaceView.java
com.aviary.android.feather.utils.PackIconCallable.java
com.aviary.android.feather.utils.SimpleBitmapCache.java
com.aviary.android.feather.utils.ThreadUtils.java
com.aviary.android.feather.utils.TypefaceUtils.java
com.aviary.android.feather.utils.UIUtils.java
com.aviary.android.feather.widget.AdjustImageView.java
com.aviary.android.feather.widget.AviaryAbsSpinner.java
com.aviary.android.feather.widget.AviaryAdapterView.java
com.aviary.android.feather.widget.AviaryBadgeToolLayout.java
com.aviary.android.feather.widget.AviaryBottomBarViewFlipper.java
com.aviary.android.feather.widget.AviaryButton.java
com.aviary.android.feather.widget.AviaryEdgeEffect.java
com.aviary.android.feather.widget.AviaryGalleryTopIndicatorView.java
com.aviary.android.feather.widget.AviaryGallery.java
com.aviary.android.feather.widget.AviaryHighlightImageButton.java
com.aviary.android.feather.widget.AviaryImageRestoreSwitcher.java
com.aviary.android.feather.widget.AviaryImageSwitcher.java
com.aviary.android.feather.widget.AviaryNavBarViewFlipper.java
com.aviary.android.feather.widget.AviarySeekBar.java
com.aviary.android.feather.widget.AviaryTextView.java
com.aviary.android.feather.widget.AviaryToast.java
com.aviary.android.feather.widget.AviaryToggleButton.java
com.aviary.android.feather.widget.AviaryWheel.java
com.aviary.android.feather.widget.AviaryWorkspaceIndicator.java
com.aviary.android.feather.widget.AviaryWorkspace.java
com.aviary.android.feather.widget.CellLayout.java
com.aviary.android.feather.widget.CropImageView.java
com.aviary.android.feather.widget.DrawableHighlightView.java
com.aviary.android.feather.widget.EffectThumbLayout.java
com.aviary.android.feather.widget.HighlightView.java
com.aviary.android.feather.widget.IAPBuyButton.java
com.aviary.android.feather.widget.IAPDialogDetail.java
com.aviary.android.feather.widget.IAPDialogList.java
com.aviary.android.feather.widget.IAPDialogMain.java
com.aviary.android.feather.widget.ImageViewDrawableOverlay.java
com.aviary.android.feather.widget.ImageViewSpotDraw.java
com.aviary.android.feather.widget.ImageViewTiltiShiftTouch.java
com.aviary.android.feather.widget.ImageViewTouchAndDraw.java
com.aviary.android.feather.widget.PointCloud.java
com.aviary.android.feather.widget.ScrollerRunnable.java
com.aviary.android.feather.widget.VibrationHelper.java
com.aviary.android.feather.widget.VibrationWidget.java