Android Open Source - Aviary-Android-SDK Abstract Panel Loader Service






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;
/*www  . ja v a2  s .  c  o m*/
import java.io.IOException;

import com.aviary.android.feather.R;
import com.aviary.android.feather.common.log.LoggerFactory;
import com.aviary.android.feather.common.log.LoggerFactory.Logger;
import com.aviary.android.feather.common.log.LoggerFactory.LoggerType;
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.BaseContextService;
import com.aviary.android.feather.library.services.IAviaryController;

/**
 * This class is the delegate class for creating the appropriate tool panel
 * for the given tool name
 */
public class AbstractPanelLoaderService extends BaseContextService {

  public static final String NAME = "AbstractPanelLoaderService";

  public AbstractPanelLoaderService ( IAviaryController context ) {
    super( context );
  }

  /**
   * Passing a {@link ToolEntry} return an instance of {@link AbstractPanel} used to
   * create the requested tool.
   * 
   * @param entry
   * @return
   */
  public AbstractPanel createNew( ToolEntry entry ) {

    AbstractPanel panel = null;
    final IAviaryController context = getContext();

    switch ( entry.name ) {
      case ADJUST:
        panel = new AdjustEffectPanel( context, entry, Filters.ADJUST );
        break;

      case BRIGHTNESS:
        panel = new NativeEffectRangePanel( context, entry, Filters.BRIGHTNESS, "brightness" );
        break;

      case SATURATION:
        panel = new NativeEffectRangePanel( context, entry, Filters.SATURATION, "saturation" );
        break;

      case CONTRAST:
        panel = new NativeEffectRangePanel( context, entry, Filters.CONTRAST, "contrast" );
        break;

      case SHARPNESS:
        panel = new NativeEffectRangePanel( context, entry, Filters.SHARPNESS, "sharpen" );
        break;

      case COLORTEMP:
        panel = new NativeEffectRangePanel( context, entry, Filters.COLORTEMP, "temperature" );
        break;

      case ENHANCE:
        panel = new EnhanceEffectPanel( context, entry, Filters.ENHANCE );
        break;

      case EFFECTS:
        panel = new EffectsPanel( context, entry );
        break;

      case BORDERS:
        panel = new BordersPanel( context, entry );
        break;

      case CROP:
        panel = new CropPanel( context, entry );
        break;

      case RED_EYE:
        panel = new DelayedSpotDrawPanel( context, entry, Filters.RED_EYE, false );
        break;

      case WHITEN:
        panel = new DelayedSpotDrawPanel( context, entry, Filters.WHITEN, false );
        break;

      case BLEMISH:
        panel = new DelayedSpotDrawPanel( context, entry, Filters.BLEMISH, false );
        break;

      case DRAWING:
        panel = new DrawingPanel( context, entry );
        break;

      case STICKERS:
        panel = new StickersPanel( context, entry );
        break;

      case TEXT:
        panel = new TextPanel( context, entry );
        break;

      case MEME:
        panel = new MemePanel( context, entry );
        break;

      case COLOR_SPLASH:
        panel = new ColorSplashPanel( context, entry );
        break;

      case TILT_SHIFT:
        panel = new TiltShiftPanel( context, entry );
        break;

      default:
        Logger logger = LoggerFactory.getLogger( "EffectLoaderService", LoggerType.ConsoleLoggerType );
        logger.error( "Effect with " + entry.name + " could not be found" );
        break;
    }
    return panel;
  }

  /** The Constant mAllEntries. */
  static final ToolEntry[] mAllEntries;

  static {
    mAllEntries = new ToolEntry[] { new ToolEntry( FilterLoaderFactory.Filters.ENHANCE, R.drawable.aviary_tool_ic_enhance, R.string.feather_enhance ),

    new ToolEntry( FilterLoaderFactory.Filters.TILT_SHIFT, R.drawable.aviary_tool_ic_focus, R.string.feather_tool_tiltshift ),

    new ToolEntry( FilterLoaderFactory.Filters.EFFECTS, R.drawable.aviary_tool_ic_effects, R.string.feather_effects ),

    new ToolEntry( FilterLoaderFactory.Filters.BORDERS, R.drawable.aviary_tool_ic_frames, R.string.feather_borders ),

    new ToolEntry( FilterLoaderFactory.Filters.STICKERS, R.drawable.aviary_tool_ic_stickers, R.string.feather_stickers ),

    new ToolEntry( FilterLoaderFactory.Filters.CROP, R.drawable.aviary_tool_ic_crop, R.string.feather_crop ),

    new ToolEntry( FilterLoaderFactory.Filters.ADJUST, R.drawable.aviary_tool_ic_orientation, R.string.feather_adjust ),

    new ToolEntry( FilterLoaderFactory.Filters.BRIGHTNESS, R.drawable.aviary_tool_ic_brightness, R.string.feather_brightness ),

    new ToolEntry( FilterLoaderFactory.Filters.CONTRAST, R.drawable.aviary_tool_ic_contrast, R.string.feather_contrast ),

    new ToolEntry( FilterLoaderFactory.Filters.SATURATION, R.drawable.aviary_tool_ic_saturation, R.string.feather_saturation ),

    new ToolEntry( FilterLoaderFactory.Filters.COLORTEMP, R.drawable.aviary_tool_ic_warmth, R.string.feather_tool_temperature ),

    new ToolEntry( FilterLoaderFactory.Filters.SHARPNESS, R.drawable.aviary_tool_ic_sharpen, R.string.feather_sharpen ),

    new ToolEntry( FilterLoaderFactory.Filters.COLOR_SPLASH, R.drawable.aviary_tool_ic_colorsplash, R.string.feather_tool_colorsplash ),

    new ToolEntry( FilterLoaderFactory.Filters.DRAWING, R.drawable.aviary_tool_ic_draw, R.string.feather_draw ),

    new ToolEntry( FilterLoaderFactory.Filters.TEXT, R.drawable.aviary_tool_ic_text, R.string.feather_text ),

    new ToolEntry( FilterLoaderFactory.Filters.RED_EYE, R.drawable.aviary_tool_ic_redeye, R.string.feather_red_eye ),

    new ToolEntry( FilterLoaderFactory.Filters.WHITEN, R.drawable.aviary_tool_ic_whiten, R.string.feather_whiten ),

    new ToolEntry( FilterLoaderFactory.Filters.BLEMISH, R.drawable.aviary_tool_ic_blemish, R.string.feather_blemish ),

    new ToolEntry( FilterLoaderFactory.Filters.MEME, R.drawable.aviary_tool_ic_meme, R.string.feather_meme ), };
  }

  /**
   * Return a list of available effects.
   * 
   * @return the effects
   */
  public ToolEntry[] getToolsEntries() {
    return mAllEntries;
  }

  public ToolEntry findEntry( Filters name ) {
    for ( ToolEntry entry : mAllEntries ) {
      if ( entry.name.equals( name ) ) {
        return entry;
      }
    }
    return null;
  }

  public ToolEntry findEntry( String name ) {
    for ( ToolEntry entry : mAllEntries ) {
      if ( entry.name.name().equals( name ) ) {
        return entry;
      }
    }
    return null;
  }

  public static final ToolEntry[] getAllEntries() {
    return mAllEntries;
  }

  /**
   * Check if the current application context has a valid folder "stickers" inside its
   * assets folder.
   * 
   * @return true, if successful
   */
  public boolean hasStickers() {
    try {
      String[] list = null;
      list = getContext().getBaseContext().getAssets().list( "stickers" );
      return list.length > 0;
    } catch ( IOException e ) {
    }

    return false;
  }

  @Override
  public void dispose() {}
}




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