Android Open Source - fileEx Image Reader Task






From Project

Back to project page fileEx.

License

The source code is released under:

Apache License

If you think the Android project fileEx 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 android.howard.exp.adapter;
/*w  w w.  ja  v a 2  s.c o m*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.ThumbnailUtils;
import android.os.AsyncTask;
import android.widget.ImageView;

public class ImageReaderTask extends AsyncTask<String, String, Bitmap> {
  private ImageCache cache;
  private ImageView mImageView;
  private int x, y;

  /**
   * @param mContext
   */
  public ImageReaderTask(Context mContext, ImageView mImageView, int x, int y) {
    super();
    this.mImageView = mImageView;
    this.x = x;
    this.y = y;
    cache = ImageCache.getInstance(mContext);
  }

  @Override
  protected Bitmap doInBackground(String... path) {
    return getImageFrmSomeWhere(path[0], path[0], this.x, this.y);
  }

  @Override
  protected void onPostExecute(Bitmap result) {
    if(result!=null)
    mImageView.setImageBitmap(result);
  }

  private Bitmap getImageFrmSomeWhere(String memKey, String pathString,
      int x, int y) {
    Bitmap bp = cache.get(memKey);
    if (bp == null) {
      bp = readImageFrmSd(pathString, x, y);
      cache.add(memKey, bp);
    }
    return bp;
  }

  private Bitmap readImageFrmSd(String path, int x, int y) {
    Bitmap bp = BitmapFactory.decodeFile(path);
    bp = ThumbnailUtils.extractThumbnail(bp, x, y);
    return bp;
  }
}




Java Source Code List

android.howard.exp.adapter.ImageCache.java
android.howard.exp.adapter.ImageReaderTask.java
android.howard.exp.adapter.NaviAdapter.java
android.howard.exp.adapter.ViedioReaderTask.java
android.howard.exp.bean.RootItemBean.java
android.howard.exp.fragment.BaseFragment.java
android.howard.exp.fragment.MenuDrawer.java
android.howard.exp.fragment.RootPage.java
android.howard.exp.fragment.TextReader.java
android.howard.exp.utils.TextFileReader.java
android.howard.exp.views.FlectImageView.java
android.howard.exp.views.ListViewCompat.java
android.howard.exp.views.SlideView.java
com.bpok.fileex.FileExApp.java