Android Open Source - android-screenshot-gallery Gallery App






From Project

Back to project page android-screenshot-gallery.

License

The source code is released under:

Apache License

If you think the Android project android-screenshot-gallery 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.demondevelopers.screenshotgallery;
// ww w . j  ava2  s . c  om
import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;


public class GalleryApp extends Application
{
  private static final String KEY_ZOOM_IMG = "zoom-image";
  
  private BitmapCache mImageCache = new BitmapCache();
  
  
  public static GalleryApp from(Context context)
  {
    if(context == null){
      throw new IllegalStateException("cannot get app from null context");
    }
    return (GalleryApp)context.getApplicationContext();
  }
  
  public void putImageIntoCache(String key, Bitmap bitmap)
  {
    mImageCache.put(key, bitmap);
  }
  
  public Bitmap getImageFromCache(String key)
  {
    return mImageCache.get(key);
  }
  
  public void purgeImageCache()
  {
    mImageCache.evictAll();
  }
  
  public void putZoomImage(Bitmap bitmap)
  {
    if(bitmap == null){
      mImageCache.remove(KEY_ZOOM_IMG);
    }
    else{
      mImageCache.put(KEY_ZOOM_IMG, bitmap);
    }
  }
  
  public Bitmap getZoomImage()
  {
    return mImageCache.get(KEY_ZOOM_IMG);
  }
  
  public static class BitmapCache extends LruCache<String, Bitmap>
  {
    public BitmapCache()
    {
      super(Math.min(30 * 1024 * 1024, 
        (int)(0.08d * Runtime.getRuntime().maxMemory())));
    }
    
    @Override
    protected int sizeOf(String key, Bitmap value)
    {
      return value.getRowBytes() * value.getHeight();
    }
  }
}




Java Source Code List

com.demondevelopers.screenshotgallery.AboutFragment.java
com.demondevelopers.screenshotgallery.BaseActivity.java
com.demondevelopers.screenshotgallery.BaseFragment.java
com.demondevelopers.screenshotgallery.FitTopDecorOnlyLayout.java
com.demondevelopers.screenshotgallery.GalleryApp.java
com.demondevelopers.screenshotgallery.ImageUtils.java
com.demondevelopers.screenshotgallery.MainActivity.java
com.demondevelopers.screenshotgallery.OverlayDecorLayout.java
com.demondevelopers.screenshotgallery.PictureActivity.java
com.demondevelopers.screenshotgallery.PictureFragment.java
com.demondevelopers.screenshotgallery.PictureGridFragment.java
com.demondevelopers.screenshotgallery.PictureView.java
com.demondevelopers.screenshotgallery.ThumbView.java