Android Open Source - TileView Tile






From Project

Back to project page TileView.

License

The source code is released under:

MIT License

If you think the Android project TileView 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.qozix.tileview.tiles;
/*  w  w w.  j  av a2s . c om*/
import android.content.Context;
import android.graphics.Bitmap;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;

import com.qozix.tileview.graphics.BitmapDecoder;

public class Tile {

  private int left;
  private int top;
  private int width;
  private int height;
  private String file;

  private ImageView imageView;
  private Bitmap bitmap;

  private boolean hasBitmap;

  public Tile() {

  }

  public Tile( int l, int t, int w, int h, String f ) {
    left = l;
    top = t;
    width = w;
    height = h;
    file = f;
  }

  public int getLeft() {
    return left;
  }

  public int getTop() {
    return top;
  }

  public int getWidth() {
    return width;
  }

  public int getHeight() {
    return height;
  }

  public ImageView getImageView() {
    return imageView;
  }

  public String getFileName() {
    return file;
  }

  public void decode( Context context, TileCache cache, BitmapDecoder decoder ) {
    if ( hasBitmap ) {
      return;
    }
    if ( cache != null ) {
      Bitmap cached = cache.getBitmap( file );
      if ( cached != null ) {
        bitmap = cached;
        return;
      }
    }
    bitmap = decoder.decode( file, context );
    hasBitmap = ( bitmap != null );
    if ( cache != null ) {
      cache.addBitmap( file, bitmap );
    }
  }

  public void render( Context context ) {
    if ( imageView == null ) {
      imageView = new ImageView( context );
      imageView.setAdjustViewBounds( false );
      imageView.setScaleType( ImageView.ScaleType.MATRIX );
    }    
    imageView.setImageBitmap( bitmap );
  }

  public void destroy() {
    if ( imageView != null ) {
      imageView.clearAnimation();
      imageView.setImageBitmap( null );
      ViewParent parent = imageView.getParent();
      if ( parent != null && parent instanceof ViewGroup ) {
        ViewGroup group = (ViewGroup) parent;
        group.removeView( imageView );
      }
      imageView = null;
    }
    bitmap = null;
    hasBitmap = false;
  }

  @Override
  public boolean equals( Object o ) {
    if ( o instanceof Tile ) {
      Tile m = (Tile) o;
      return ( m.getLeft() == getLeft() )
          && ( m.getTop() == getTop() )
          && ( m.getWidth() == getWidth() )
          && ( m.getHeight() == getHeight() )
          && ( m.getFileName().equals( getFileName() ) );
    }
    return false;
  }

  @Override
  public String toString() {
    return "(left=" + left + ", top=" + top + ", width=" + width + ", height=" + height + ", file=" + file + ")";
  }

}




Java Source Code List

com.qozix.animation.AnimationListener.java
com.qozix.animation.Animator.java
com.qozix.animation.TweenHandler.java
com.qozix.animation.TweenListener.java
com.qozix.animation.Tween.java
com.qozix.animation.easing.EasingEquation.java
com.qozix.animation.easing.Linear.java
com.qozix.animation.easing.Strong.java
com.qozix.layouts.AnchorLayout.java
com.qozix.layouts.FixedLayout.java
com.qozix.layouts.ScalingLayout.java
com.qozix.layouts.StaticLayout.java
com.qozix.layouts.TranslationLayout.java
com.qozix.layouts.ZoomPanLayout.java
com.qozix.os.AsyncTask.java
com.qozix.tileview.TileView.java
com.qozix.tileview.detail.DetailLevelEventListener.java
com.qozix.tileview.detail.DetailLevelPatternParserDefault.java
com.qozix.tileview.detail.DetailLevelPatternParser.java
com.qozix.tileview.detail.DetailLevelSet.java
com.qozix.tileview.detail.DetailLevelSetupListener.java
com.qozix.tileview.detail.DetailLevel.java
com.qozix.tileview.detail.DetailManager.java
com.qozix.tileview.geom.PositionManager.java
com.qozix.tileview.graphics.BitmapDecoderAssets.java
com.qozix.tileview.graphics.BitmapDecoderHttp.java
com.qozix.tileview.graphics.BitmapDecoder.java
com.qozix.tileview.hotspots.HotSpotEventListener.java
com.qozix.tileview.hotspots.HotSpotManager.java
com.qozix.tileview.hotspots.HotSpot.java
com.qozix.tileview.markers.CalloutManager.java
com.qozix.tileview.markers.MarkerEventListener.java
com.qozix.tileview.markers.MarkerManager.java
com.qozix.tileview.paths.DrawablePath.java
com.qozix.tileview.paths.PathHelper.java
com.qozix.tileview.paths.PathManager.java
com.qozix.tileview.samples.SampleManager.java
com.qozix.tileview.tiles.TileCache.java
com.qozix.tileview.tiles.TileManager.java
com.qozix.tileview.tiles.TileRenderHandler.java
com.qozix.tileview.tiles.TileRenderListener.java
com.qozix.tileview.tiles.TileRenderTask.java
com.qozix.tileview.tiles.TileTransitionListener.java
com.qozix.tileview.tiles.Tile.java
com.qozix.tileview.tiles.selector.TileSetSelectorByRange.java
com.qozix.tileview.tiles.selector.TileSetSelectorClosest.java
com.qozix.tileview.tiles.selector.TileSetSelectorMinimalUpScale.java
com.qozix.tileview.tiles.selector.TileSetSelector.java
com.qozix.utils.ViewCurator.java
com.qozix.widgets.Scroller.java