com.blogspot.applications4android.comicreader.core
Class Comic

java.lang.Object
  extended by com.blogspot.applications4android.comicreader.core.ComicParser
      extended by com.blogspot.applications4android.comicreader.core.Comic
Direct Known Subclasses:
DailyComic, IndexedComic

public abstract class Comic
extends ComicParser

Base class for all comic series


Field Summary
static int DIALOG_DATE
          use date picker dialog
static int DIALOG_NUMBER
          use number picker dialog
protected  java.lang.String mFirstUid
          uid for first comic
protected  java.lang.String mLatestUid
          uid for latest comic
protected  java.lang.String mPrevSessionUid
          uid for the previous session comic
static int NAV_CURRENT
          navigate to current strip
static int NAV_FIRST
          navigate to first strip
static int NAV_LATEST
          navigate to latest strip
static int NAV_LATEST_FORCE
          navigate to latest strip forcefully
static int NAV_NEXT
          navigate to next strip
static int NAV_PREV_SESSION
          navigate to previous session
static int NAV_PREVIOUS
          navigate to previous strip
static int NAV_RANDOM
          navigate to random strip
static java.lang.String PROPS
          properties folder name
static int TYPE_CACHING
          background caching
static int TYPE_FAVORITE
          favorite comics
static int TYPE_LATEST
          latest comics
static int TYPE_PREV_SESSION
          previous session
static int TYPE_PREVIEW
          preview comics
 
Constructor Summary
Comic()
          Constructor
 
Method Summary
 void clearCache()
          Helper function to clear the cache
 void clearHistory()
          Clears all the history associated with this comic
 boolean currentHasImageText()
          Whether the current comic has image text or not
 java.lang.String currentTitleAsValidFilename()
          Creates a valid file name out of the strip's title
abstract  int dialogType()
          Type of dialog to be used for choosing comics
 void downloadCurrentStrip()
          Download the current strip
abstract  Bound getBound()
          Returns the bound for the current comic
 java.lang.String getComicName()
          Get the english name for this comic
abstract  java.lang.String getComicWebPageUrl()
          Get the main page url for the current comic series
 Strip getCurrentStrip()
          Gets the current strip
 float getDefaultZoom()
          Returns the default value of zoom
 Strip getFirstStrip()
          Gets the first strip
protected abstract  java.lang.String getFirstStripUrl()
          Gets the url for the first strip
 Strip getLatestStrip()
          Gets latest strip
 Strip getLatestStripForcefully()
          Gets latest strip forcefully (used during background caching)
protected abstract  java.lang.String getLatestStripUrl()
          Gets the url for the latest strip
 int getLaunchType()
          get the launch type
 java.lang.String getName()
          Get the comic name
 Strip getNextStrip()
          Gets the next strip
protected abstract  java.lang.String getNextStripUrl()
          Gets the url for the next strip
 Strip getPreviousSessionStrip()
          Gets the previous session strip
 Strip getPreviousStrip()
          Gets the previous strip
protected abstract  java.lang.String getPreviousStripUrl()
          Gets the url for the previous strip
 Strip getRandomStrip()
          Gets the random strip
protected abstract  java.lang.String getRandomStripUrl()
          Gets the url for the previous strip
 Strip getStripFromUrl(java.lang.String url)
          Gets the strip from the given url
 boolean hasPreviousSession()
          Tells whether the comic has any previous sessions or not
protected  boolean hasUid(java.lang.String uid)
          Query whether the uid already exists in the history
 boolean isCurrentFavorite()
          Whether the current comic is favorite or not
protected  boolean isCurrentFirstStrip()
          Checks whether the current strip is first strip or not
protected  boolean isCurrentLatestStrip()
          Checks whether the current strip is latest strip or not
 Strip navigateStrip(int type)
          Helper function to provide unified interface for navigation among the strips
protected  Strip queryUid(java.lang.String uid)
          Helper function to query for a strip and create if it doesn't exist
 int readOnlyUnread()
          Reads unread strips count for the current comic
 void readProperties()
          Helper function to read the properties of this comic from its json file
 void setCacheEnabled(boolean cache)
          Tell to this comic whether caching is enabled or not.
 void setComicName(java.lang.String name)
          Set the english name for this comic
 void setCurrentAsFavorite(boolean val)
          Sets the current strip as favorite or not
 void setDefaultZoom(float zoom)
          Set the default value of zoom
 void setLaunchType(int type)
          Set the launch type for this comic
protected abstract  java.lang.String[] urlsNotForCaching()
          Gives out the list of urls (can be regexes) which are not supposed to be cached using 'mStrips'
 void writeProperties()
          Helper function to write the properties of this comic into its json file
 
Methods inherited from class com.blogspot.applications4android.comicreader.core.ComicParser
htmlNeeded, parse, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPS

public static final java.lang.String PROPS
properties folder name

See Also:
Constant Field Values

TYPE_PREV_SESSION

public static final int TYPE_PREV_SESSION
previous session

See Also:
Constant Field Values

TYPE_LATEST

public static final int TYPE_LATEST
latest comics

See Also:
Constant Field Values

TYPE_FAVORITE

public static final int TYPE_FAVORITE
favorite comics

See Also:
Constant Field Values

TYPE_PREVIEW

public static final int TYPE_PREVIEW
preview comics

See Also:
Constant Field Values

TYPE_CACHING

public static final int TYPE_CACHING
background caching

See Also:
Constant Field Values

NAV_LATEST

public static final int NAV_LATEST
navigate to latest strip

See Also:
Constant Field Values

NAV_LATEST_FORCE

public static final int NAV_LATEST_FORCE
navigate to latest strip forcefully

See Also:
Constant Field Values

NAV_FIRST

public static final int NAV_FIRST
navigate to first strip

See Also:
Constant Field Values

NAV_NEXT

public static final int NAV_NEXT
navigate to next strip

See Also:
Constant Field Values

NAV_PREVIOUS

public static final int NAV_PREVIOUS
navigate to previous strip

See Also:
Constant Field Values

NAV_RANDOM

public static final int NAV_RANDOM
navigate to random strip

See Also:
Constant Field Values

NAV_CURRENT

public static final int NAV_CURRENT
navigate to current strip

See Also:
Constant Field Values

NAV_PREV_SESSION

public static final int NAV_PREV_SESSION
navigate to previous session

See Also:
Constant Field Values

DIALOG_DATE

public static final int DIALOG_DATE
use date picker dialog

See Also:
Constant Field Values

DIALOG_NUMBER

public static final int DIALOG_NUMBER
use number picker dialog

See Also:
Constant Field Values

mLatestUid

protected java.lang.String mLatestUid
uid for latest comic


mFirstUid

protected java.lang.String mFirstUid
uid for first comic


mPrevSessionUid

protected java.lang.String mPrevSessionUid
uid for the previous session comic

Constructor Detail

Comic

public Comic()
Constructor

Method Detail

setCacheEnabled

public void setCacheEnabled(boolean cache)
Tell to this comic whether caching is enabled or not. This'll be used to decide whether to forcefully download the latest comic or not.

Parameters:
cache - true if it is, else false

setLaunchType

public void setLaunchType(int type)
Set the launch type for this comic

Parameters:
type - launch type

getLaunchType

public int getLaunchType()
get the launch type

Returns:
launch type

getName

public java.lang.String getName()
Get the comic name

Returns:
name

getCurrentStrip

public Strip getCurrentStrip()
Gets the current strip

Returns:
current strip

getComicName

public java.lang.String getComicName()
Get the english name for this comic

Returns:
name

setComicName

public void setComicName(java.lang.String name)
Set the english name for this comic

Parameters:
name - name to be set

readOnlyUnread

public int readOnlyUnread()
                   throws java.io.FileNotFoundException,
                          java.io.IOException,
                          JSONException
Reads unread strips count for the current comic

Returns:
unread strips count
Throws:
java.io.FileNotFoundException
java.io.IOException
JSONException

readProperties

public void readProperties()
                    throws java.io.FileNotFoundException,
                           java.io.IOException,
                           JSONException
Helper function to read the properties of this comic from its json file

Throws:
java.io.FileNotFoundException
java.io.IOException
JSONException

writeProperties

public void writeProperties()
                     throws java.io.IOException,
                            ComicSDCardFull
Helper function to write the properties of this comic into its json file

Throws:
java.io.IOException
ComicSDCardFull

getDefaultZoom

public float getDefaultZoom()
Returns the default value of zoom

Returns:
zoom value

setDefaultZoom

public void setDefaultZoom(float zoom)
Set the default value of zoom

Parameters:
zoom - zoom value

hasPreviousSession

public boolean hasPreviousSession()
Tells whether the comic has any previous sessions or not

Returns:
true if it has, else false

setCurrentAsFavorite

public void setCurrentAsFavorite(boolean val)
Sets the current strip as favorite or not

Parameters:
val - true if it is to be set as favorite

isCurrentFavorite

public boolean isCurrentFavorite()
Whether the current comic is favorite or not

Returns:
true if it is

currentHasImageText

public boolean currentHasImageText()
Whether the current comic has image text or not

Returns:
true if it is

currentTitleAsValidFilename

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

Returns:
valid file name

clearCache

public void clearCache()
Helper function to clear the cache


clearHistory

public void clearHistory()
Clears all the history associated with this comic


navigateStrip

public Strip navigateStrip(int type)
                    throws ComicException
Helper function to provide unified interface for navigation among the strips

Parameters:
type - navigation type
Returns:
strip
Throws:
ComicException

getLatestStrip

public Strip getLatestStrip()
Gets latest strip

Returns:
latest strip

getLatestStripForcefully

public Strip getLatestStripForcefully()
Gets latest strip forcefully (used during background caching)

Returns:
latest strip

getFirstStrip

public Strip getFirstStrip()
Gets the first strip

Returns:
first strip

getRandomStrip

public Strip getRandomStrip()
Gets the random strip

Returns:
random strip

getNextStrip

public Strip getNextStrip()
Gets the next strip

Returns:
next strip

getPreviousStrip

public Strip getPreviousStrip()
Gets the previous strip

Returns:
previous strip

getPreviousSessionStrip

public Strip getPreviousSessionStrip()
Gets the previous session strip

Returns:
previous session strip

getStripFromUrl

public Strip getStripFromUrl(java.lang.String url)
                      throws ClientProtocolException,
                             java.net.URISyntaxException,
                             java.io.IOException,
                             ComicSDCardFull
Gets the strip from the given url

Parameters:
url - url
Returns:
strip
Throws:
ComicSDCardFull
java.io.IOException
java.net.URISyntaxException
ClientProtocolException

downloadCurrentStrip

public void downloadCurrentStrip()
                          throws ClientProtocolException,
                                 java.net.URISyntaxException,
                                 java.io.IOException,
                                 ComicSDCardFull
Download the current strip

Throws:
ClientProtocolException
java.net.URISyntaxException
java.io.IOException
ComicSDCardFull

getComicWebPageUrl

public abstract java.lang.String getComicWebPageUrl()
Get the main page url for the current comic series

Returns:
desired url

getBound

public abstract Bound getBound()
Returns the bound for the current comic

Returns:
bound

dialogType

public abstract int dialogType()
Type of dialog to be used for choosing comics

Returns:
int

getLatestStripUrl

protected abstract java.lang.String getLatestStripUrl()
Gets the url for the latest strip

Returns:
url

getFirstStripUrl

protected abstract java.lang.String getFirstStripUrl()
Gets the url for the first strip

Returns:
url

getNextStripUrl

protected abstract java.lang.String getNextStripUrl()
Gets the url for the next strip

Returns:
url

getPreviousStripUrl

protected abstract java.lang.String getPreviousStripUrl()
Gets the url for the previous strip

Returns:
url

getRandomStripUrl

protected abstract java.lang.String getRandomStripUrl()
Gets the url for the previous strip

Returns:
url

urlsNotForCaching

protected abstract java.lang.String[] urlsNotForCaching()
Gives out the list of urls (can be regexes) which are not supposed to be cached using 'mStrips'

Returns:
list

isCurrentLatestStrip

protected boolean isCurrentLatestStrip()
Checks whether the current strip is latest strip or not

Returns:
true if it is

isCurrentFirstStrip

protected boolean isCurrentFirstStrip()
Checks whether the current strip is first strip or not

Returns:
true if it is

hasUid

protected boolean hasUid(java.lang.String uid)
Query whether the uid already exists in the history

Parameters:
uid - uid
Returns:
true if it is, else false

queryUid

protected Strip queryUid(java.lang.String uid)
Helper function to query for a strip and create if it doesn't exist

Parameters:
uid - key to be queried
Returns:
strip