Android Open Source - BBC-News-Reader Item Layout






From Project

Back to project page BBC-News-Reader.

License

The source code is released under:

Copyright (c) 2011, 2012, Digital Lizard (Oscar Key, Thomas Boby) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the...

If you think the Android project BBC-News-Reader 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

/*******************************************************************************
 * BBC News Reader//from w  w w. j  a v  a  2 s . c  om
 * Released under the BSD License. See README or LICENSE.
 * Copyright (c) 2011, Digital Lizard (Oscar Key, Thomas Boby)
 * All rights reserved.
 ******************************************************************************/
package com.digitallizard.bbcnewsreader;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ItemLayout extends LinearLayout {
  private int id;
  private TextView title;
  private ImageView image;
  private boolean imageLoaded;
  
  public boolean isItem() {
    // if the id is not -1 then this item has been set
    if (id != -1) {
      return true;
    }
    else {
      return false;
    }
  }
  
  @Override
  public int getId() {
    return id;
  }
  
  @Override
  public void setId(int id) {
    this.id = id;
  }
  
  public void setTitle(String text) {
    // check if we have a pointer to the title
    if (title != null) {
      title.setText(text); // set the text
    }
    else {
      // find the title then set it
      title = (TextView) this.findViewById(R.id.textNewsItemTitle);
      title.setText(text);
    }
  }
  
  void initImage() {
    // create a reference to the image view
    image = (ImageView) this.findViewById(R.id.imageNewsItem);
  }
  
  public void setImage(Bitmap bitmap) {
    if (image == null) {
      initImage();
    }
    if (image != null) {
      image.setImageBitmap(bitmap);
    }
  }
  
  public void setImage(int drawable) {
    if (image == null) {
      initImage();
    }
    if (image != null) {
      image.setImageResource(drawable);
    }
  }
  
  public void setImageSize(int width, int height) {
    if (image == null) {
      initImage();
    }
    if (image != null) {
      image.setLayoutParams(new LayoutParams(width, height));
    }
  }
  
  public void setImageLoaded(boolean loaded) {
    imageLoaded = loaded;
  }
  
  public boolean isImageLoaded() {
    return imageLoaded;
  }
  
  public ItemLayout(Context context) {
    super(context); // just call the super function
    id = -1;
  }
  
  public ItemLayout(Context context, AttributeSet attrs) {
    super(context, attrs); // just call the super function
    id = -1;
  }
}




Java Source Code List

com.digitallizard.bbcnewsreader.ArticleActivity.java
com.digitallizard.bbcnewsreader.CategoryActivity.java
com.digitallizard.bbcnewsreader.CategoryChooserActivity.java
com.digitallizard.bbcnewsreader.CategoryChooserAdapter.java
com.digitallizard.bbcnewsreader.CategoryPagerAdapter.java
com.digitallizard.bbcnewsreader.Eula.java
com.digitallizard.bbcnewsreader.ItemAdapter.java
com.digitallizard.bbcnewsreader.ItemLayout.java
com.digitallizard.bbcnewsreader.Item.java
com.digitallizard.bbcnewsreader.RSSManager.java
com.digitallizard.bbcnewsreader.ReaderActivity.java
com.digitallizard.bbcnewsreader.ResourceInterface.java
com.digitallizard.bbcnewsreader.ResourceService.java
com.digitallizard.bbcnewsreader.ServiceManager.java
com.digitallizard.bbcnewsreader.SettingsActivity.java
com.digitallizard.bbcnewsreader.data.DatabaseHandler.java
com.digitallizard.bbcnewsreader.data.DatabaseHelper.java
com.digitallizard.bbcnewsreader.data.DatabaseProvider.java
com.digitallizard.bbcnewsreader.data.ItemClearer.java
com.digitallizard.bbcnewsreader.data.WrapBackwards.java
com.digitallizard.bbcnewsreader.fragments.ArticleFragment.java
com.digitallizard.bbcnewsreader.fragments.CategoryChooserFragment.java
com.digitallizard.bbcnewsreader.fragments.CategoryFragment.java
com.digitallizard.bbcnewsreader.fragments.FrontpageFragment.java
com.digitallizard.bbcnewsreader.resource.web.HtmlParser.java
com.digitallizard.bbcnewsreader.resource.web.ImageDownloader.java
com.digitallizard.bbcnewsreader.resource.web.QueueItem.java
com.digitallizard.bbcnewsreader.resource.web.WebManager.java
com.digitallizard.bbcnewsreader.widget.ReaderWidget.java
com.digitallizard.bbcnewsreader.widget.WidgetConfigActivity.java
com.hlidskialf.android.preference.SeekBarPreference.java