com.blogspot.applications4android.comicreader.core
Class Strip

java.lang.Object
  extended by com.blogspot.applications4android.comicreader.core.Strip

public final class Strip
extends java.lang.Object

Data-structure for holding info on a comic-strip


Field Summary
static int BITMAP_MEM_LIMIT
          Limit to the amount of memory to be used by the bitmap (in B)
 
Constructor Summary
Strip(java.lang.String html, java.lang.String imgR)
          Default constructor
Strip(java.lang.String html, java.lang.String imgR, boolean read, boolean fav, java.lang.String prev, java.lang.String next, java.lang.String title, java.lang.String text)
          Constructor with initialization
 
Method Summary
 java.lang.String currentTitleAsValidFilename()
          Creates a valid file name out of the strip's title
 boolean downloadImage(ComicParser p)
          Downloads the image of the strip if it doesn't exist already
 Bitmap getBitmapFromFile()
          This gets the bitmap from the file (to be used only for comics which can have large strips) You should have called 'getImage' before calling this function!
 java.lang.String getImage(ComicParser p)
          Fetches the image of the strip
 java.lang.String getImagePath()
          Returns the path to the stored image file
 java.lang.String getNext()
          Get the next comic strip
 java.lang.String getPrevious()
          Get the previous comic strip
 java.lang.String getStripUrl()
          Returns the strip url
 java.lang.String getText()
          Get the strip text
 java.lang.String getTitle()
          Get the strip title
 boolean hasNext()
          Is there a next strip for this strip
 boolean hasPrevious()
          Is there a previous strip for this strip
 boolean hasText()
          Checks whether the strip has hover-text or not
 boolean isFavorite()
          Whether this strip is favorite
 boolean isRead()
          Whether this strip has been read
static Strip readFromJsonObject(JSONObject obj)
          Helper function to initialize the contents of the strip
 void setAsFavorite(boolean fav)
          Set this comic as favorite
 void setAsRead(boolean read)
          Mark this strip as read/un-read
 void setNext(java.lang.String uid)
          Set the next comic strip
 void setPrevious(java.lang.String uid)
          Set the previous comic strip
 void setText(java.lang.String txt)
          Set the strip text
 void setTitle(java.lang.String title)
          Set the strip title
 void toJsonString(java.lang.StringBuilder sb)
          Convert the contents of this strip into json string
 java.lang.String uid()
          Returns the UID for this strip (nothing but the html-url)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BITMAP_MEM_LIMIT

public static final int BITMAP_MEM_LIMIT
Limit to the amount of memory to be used by the bitmap (in B)

See Also:
Constant Field Values
Constructor Detail

Strip

public Strip(java.lang.String html,
             java.lang.String imgR)
Default constructor

Parameters:
html - html url
imgR - image file root

Strip

public Strip(java.lang.String html,
             java.lang.String imgR,
             boolean read,
             boolean fav,
             java.lang.String prev,
             java.lang.String next,
             java.lang.String title,
             java.lang.String text)
Constructor with initialization

Parameters:
html - html url
imgR - image file root
read - strip read before?
fav - favorite strip?
prev - previous comic strip
next - next comic strip
title - strip title
text - strip text
Method Detail

readFromJsonObject

public static Strip readFromJsonObject(JSONObject obj)
                                throws JSONException
Helper function to initialize the contents of the strip

Parameters:
obj - json object
Returns:
strip object
Throws:
JSONException

toJsonString

public void toJsonString(java.lang.StringBuilder sb)
Convert the contents of this strip into json string

Parameters:
sb - string-builder where to append the contents

getBitmapFromFile

public Bitmap getBitmapFromFile()
                         throws java.io.FileNotFoundException,
                                BitMapException
This gets the bitmap from the file (to be used only for comics which can have large strips) You should have called 'getImage' before calling this function!

Returns:
bitmap object
Throws:
java.io.FileNotFoundException
BitMapException

getImage

public java.lang.String getImage(ComicParser p)
                          throws ClientProtocolException,
                                 java.net.URISyntaxException,
                                 java.io.IOException,
                                 ComicSDCardFull
Fetches the image of the strip

Parameters:
p - parser which generates strip info
Returns:
path to the image
Throws:
java.io.IOException
java.net.URISyntaxException
ClientProtocolException
ComicSDCardFull

downloadImage

public boolean downloadImage(ComicParser p)
                      throws ClientProtocolException,
                             java.net.URISyntaxException,
                             java.io.IOException,
                             ComicSDCardFull
Downloads the image of the strip if it doesn't exist already

Parameters:
p - parser which generates strip info
Returns:
true if the image had to be downloaded, else false
Throws:
java.io.IOException
java.net.URISyntaxException
ClientProtocolException
ComicSDCardFull

currentTitleAsValidFilename

public java.lang.String currentTitleAsValidFilename()
Creates a valid file name out of the strip's title

Returns:
valid file name

setAsRead

public void setAsRead(boolean read)
Mark this strip as read/un-read

Parameters:
read - read/un-read

setAsFavorite

public void setAsFavorite(boolean fav)
Set this comic as favorite

Parameters:
fav - favorite or not

setPrevious

public void setPrevious(java.lang.String uid)
Set the previous comic strip

Parameters:
uid - previous strip

setNext

public void setNext(java.lang.String uid)
Set the next comic strip

Parameters:
uid - next strip

setText

public void setText(java.lang.String txt)
Set the strip text

Parameters:
txt - text

setTitle

public void setTitle(java.lang.String title)
Set the strip title

Parameters:
title - title

uid

public java.lang.String uid()
Returns the UID for this strip (nothing but the html-url)

Returns:
uid

getStripUrl

public java.lang.String getStripUrl()
Returns the strip url

Returns:
url

getImagePath

public java.lang.String getImagePath()
Returns the path to the stored image file

Returns:
image file path

isRead

public boolean isRead()
Whether this strip has been read

Returns:
true if it has been read

isFavorite

public boolean isFavorite()
Whether this strip is favorite

Returns:
true if is favorite

getPrevious

public java.lang.String getPrevious()
Get the previous comic strip

Returns:
previous strip

hasPrevious

public boolean hasPrevious()
Is there a previous strip for this strip

Returns:
true if it has

getNext

public java.lang.String getNext()
Get the next comic strip

Returns:
next strip

hasNext

public boolean hasNext()
Is there a next strip for this strip

Returns:
true if it has

getTitle

public java.lang.String getTitle()
Get the strip title

Returns:
title

getText

public java.lang.String getText()
Get the strip text

Returns:
text

hasText

public boolean hasText()
Checks whether the strip has hover-text or not

Returns:
true if it has