Android Open Source - Aviary-Android-SDK Slider Effect Panel






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.effects;
//from  www.  ja v  a 2  s.  co  m
import java.util.Locale;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import com.aviary.android.feather.R;
import com.aviary.android.feather.library.content.ToolEntry;
import com.aviary.android.feather.library.filters.FilterLoaderFactory;
import com.aviary.android.feather.library.filters.FilterLoaderFactory.Filters;
import com.aviary.android.feather.library.services.IAviaryController;
import com.aviary.android.feather.library.tracking.Tracker;
import com.aviary.android.feather.widget.AviarySeekBar;
import com.aviary.android.feather.widget.AviaryWheel;
import com.aviary.android.feather.widget.AviaryWheel.OnWheelChangeListener;

public abstract class SliderEffectPanel extends AbstractOptionPanel implements OnSeekBarChangeListener, OnClickListener, OnWheelChangeListener {

  enum SliderStyle {
    SeekBarStyle, WheelStyle
  };

  private SliderStyle mStyle;
  AviaryWheel mWheel;
  AviarySeekBar mSeekBar;
  String mResourceName;
  View mButtonMinus, mButtonPlus;

  public SliderEffectPanel ( IAviaryController context, ToolEntry entry, Filters type, String resourcesBaseName ) {
    super( context, entry );
    mStyle = SliderStyle.WheelStyle;

    mFilter = FilterLoaderFactory.get( type );
    mResourceName = resourcesBaseName;
  }

  @Override
  public void onCreate( Bitmap bitmap, Bundle options ) {
    super.onCreate( bitmap, options );

    mButtonMinus = getOptionView().findViewById( R.id.aviary_button_minus );
    mButtonPlus = getOptionView().findViewById( R.id.aviary_button_plus );

    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar = (AviarySeekBar) getOptionView().findViewById( R.id.aviary_seekbar );
      mSeekBar.setProgress( 50 );
    } else {
      mWheel = (AviaryWheel) getOptionView().findViewById( R.id.aviary_wheel );
      mWheel.setValue( 50 );
    }
  }

  @Override
  public void onActivate() {
    super.onActivate();
    mButtonMinus.setOnClickListener( this );
    mButtonPlus.setOnClickListener( this );

    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar.setOnSeekBarChangeListener( this );
    } else {
      mWheel.setOnWheelChangeListener( this );
      disableHapticIsNecessary( mWheel );
    }
  }

  @Override
  public void onDeactivate() {
    super.onDeactivate();
    mButtonMinus.setOnClickListener( null );
    mButtonPlus.setOnClickListener( null );

    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar.setOnSeekBarChangeListener( null );
    } else {
      mWheel.setOnWheelChangeListener( this );
    }
  }

  protected void setValue( int value ) {
    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar.setProgress( value );
    } else {
      mWheel.setValue( value );
    }
  }

  @Override
  public void onClick( View v ) {
    final int id = v.getId();
    if ( id == mButtonMinus.getId() ) {
      decreaseValue();
    } else if ( id == mButtonPlus.getId() ) {
      increaseValue();
    }
  }

  protected void decreaseValue() {
    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar.setProgress( mSeekBar.getProgress() - 1 );
    } else {
      mWheel.setValue( mWheel.getValue() - 1 );
    }
  }

  protected void increaseValue() {
    if ( mStyle == SliderStyle.SeekBarStyle ) {
      mSeekBar.setProgress( mSeekBar.getProgress() + 1 );
    } else {
      mWheel.setValue( mWheel.getValue() + 1 );
    }
  }

  @Override
  protected ViewGroup generateOptionView( LayoutInflater inflater, ViewGroup parent ) {
    if ( mStyle == SliderStyle.SeekBarStyle ) {
      return (ViewGroup) inflater.inflate( R.layout.aviary_panel_seekbar, parent, false );
    } else {
      return (ViewGroup) inflater.inflate( R.layout.aviary_panel_wheel, parent, false );
    }
  }

  @Override
  public final void onProgressChanged( SeekBar seekBar, int progress, boolean fromUser ) {
    onSliderChanged( progress, fromUser );
  }

  @Override
  public final void onStartTrackingTouch( SeekBar seekBar ) {
    Tracker.recordTag( getName().name().toLowerCase( Locale.US ) + ": SliderMoved" );
    onSliderStart( seekBar.getProgress() );
  }

  @Override
  public final void onStopTrackingTouch( SeekBar seekBar ) {
    onSliderEnd( seekBar.getProgress() );
  }

  @Override
  public final void onStartTrackingTouch( AviaryWheel view ) {
    Tracker.recordTag( getName().name().toLowerCase( Locale.US ) + ": WheelMoved" );
    onSliderStart( view.getValue() );
  }

  @Override
  public final void OnValueChanged( AviaryWheel view, int value ) {
    onSliderChanged( value, true );
  }

  @Override
  public void onStopTrackingTouch( AviaryWheel view ) {
    onSliderEnd( view.getValue() );
  }

  protected abstract void onSliderStart( int value );

  protected abstract void onSliderChanged( int value, boolean fromUser );

  protected abstract void onSliderEnd( int value );
}




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