Android Open Source - SandB-Android Image






From Project

Back to project page SandB-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project SandB-Android 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 edu.grinnell.sandb.img;
/*w w w  .j a v a  2 s .  c o  m*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

/* Class to store the article images and image titles in a db */
public class Image {

  protected int id;
  protected int articleId;
  protected String url;
  protected byte[] image;
  protected String imgTitle;

  protected Image(int ArticleID, String articleURL, byte[] articleImage,
      String articleImgTitle) {
    articleId = ArticleID;
    url = articleURL;
    image = articleImage;
    imgTitle = articleImgTitle;
  }

  protected Image(int ID, int ArticleID, String articleURL,
      byte[] articleImage, String articleImgTitle) {
    this(ArticleID, articleURL, articleImage, articleImgTitle);
    id = ID;
  }

  public Drawable toDrawable(Context c) {
    
    Bitmap bm = toBitmap();
    Drawable d = new BitmapDrawable(c.getResources(), bm);
    d.setBounds(0, 0, 0 + d.getIntrinsicWidth(), 0 
                + d.getIntrinsicHeight()); 
    return d;  
  }
  
  public Bitmap toBitmap() {
    return (image != null) ? BitmapFactory.decodeByteArray(image, 0, image.length)
        : null;
  }
  
  public int getId() {
    return id;
  }

  public int getArticleId() {
    return articleId;
  }

  public String getURL() {
    return url;
  }

  public byte[] getImg() {
    return image;
  }

  public String getImgTitle() {
    return imgTitle;
  }

}




Java Source Code List

edu.grinnell.sandb.ArticleDetailActivity.java
edu.grinnell.sandb.ArticleDetailFragment.java
edu.grinnell.sandb.ArticleListAdapter.java
edu.grinnell.sandb.ArticleListFragment.java
edu.grinnell.sandb.CommentListAdapter.java
edu.grinnell.sandb.CommentListFragment.java
edu.grinnell.sandb.ImagePagerActivity.java
edu.grinnell.sandb.MainActivity.java
edu.grinnell.sandb.MainPrefs.java
edu.grinnell.sandb.ScarletAndBlackApplication.java
edu.grinnell.sandb.Utility.java
edu.grinnell.sandb.comments.CommentStorageHelper.java
edu.grinnell.sandb.comments.CommentTable.java
edu.grinnell.sandb.comments.Comment.java
edu.grinnell.sandb.data.ArticleStorageHelper.java
edu.grinnell.sandb.data.ArticleTable.java
edu.grinnell.sandb.data.Article.java
edu.grinnell.sandb.img.BodyImageGetter.java
edu.grinnell.sandb.img.ImageStorageHelper.java
edu.grinnell.sandb.img.ImageTable.java
edu.grinnell.sandb.img.Image.java
edu.grinnell.sandb.img.UniversalLoaderUtility.java
edu.grinnell.sandb.xmlpull.CommentParseTask.java
edu.grinnell.sandb.xmlpull.XmlCheckAgeTask.java
edu.grinnell.sandb.xmlpull.XmlFetchTask.java
edu.grinnell.sandb.xmlpull.XmlParseTask.java
edu.grinnell.sandb.xmlpull.XmlPullReceiver.java
edu.grinnell.sandb.xmlpull.XmlPullService.java