Example usage for java.util Calendar after

List of usage examples for java.util Calendar after

Introduction

In this page you can find the example usage for java.util Calendar after.

Prototype

public boolean after(Object when) 

Source Link

Document

Returns whether this Calendar represents a time after the time represented by the specified Object.

Usage

From source file:biz.varkon.shelvesom.provider.gadgets.GadgetsUpdater.java

private boolean gadgetCoverUpdated(GadgetsStore.Gadget gadget, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;//from  w  w w  . j a v a  2 s  .  co  m

    final String tinyThumbnail = Preferences.getImageURLForUpdater(gadget);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(gadget));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + gadget, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(gadget.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + gadget, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + gadget, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + gadget, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.music.MusicUpdater.java

private boolean musicCoverUpdated(MusicStore.Music music, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;//from  w  w  w . j av a 2s . c  o m

    final String tinyThumbnail = Preferences.getImageURLForUpdater(music);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(music));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + music, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(music.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + music, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + music, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + music, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.software.SoftwareUpdater.java

private boolean softwareCoverUpdated(SoftwareStore.Software software, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;/*from w  ww . j  a v  a2s .  co  m*/

    final String tinyThumbnail = Preferences.getImageURLForUpdater(software);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(software));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + software, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(software.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + software, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + software, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + software, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.tools.ToolsUpdater.java

private boolean toolCoverUpdated(ToolsStore.Tool tool, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;// w ww  .  j  a  va  2s.  c  om

    final String tinyThumbnail = Preferences.getImageURLForUpdater(tool);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(tool));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + tool, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(tool.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + tool, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + tool, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + tool, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.toys.ToysUpdater.java

private boolean toyCoverUpdated(ToysStore.Toy toy, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;//from w ww.j  a va  2 s  .  c o m

    final String tinyThumbnail = Preferences.getImageURLForUpdater(toy);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(toy));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + toy, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(toy.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + toy, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + toy, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + toy, e);
                }
            }
        }
    }
    return false;
}

From source file:com.manning.blogapps.chapter11.PlanetManagerImpl.java

protected Set getNewEntriesRemote(PlanetSubscriptionData sub, FeedFetcher feedFetcher,
        FeedFetcherCache feedInfoCache) throws Exception {

    Set newEntries = new TreeSet();
    SyndFeed feed = null;/*from  w  w  w. j a  v  a  2s.c  o  m*/
    URL feedUrl = null;
    Date lastUpdated = new Date();
    try {
        feedUrl = new URL(sub.getFeedUrl());
        logger.debug("Get feed from cache " + sub.getFeedUrl());
        feed = feedFetcher.retrieveFeed(feedUrl);
        SyndFeedInfo feedInfo = feedInfoCache.getFeedInfo(feedUrl);
        if (feedInfo.getLastModified() != null) {
            long lastUpdatedLong = ((Long) feedInfo.getLastModified()).longValue();
            if (lastUpdatedLong != 0) {
                lastUpdated = new Date(lastUpdatedLong);
            }
        }
        Thread.sleep(100); // be nice
    } catch (Exception e) {
        logger.warn(
                "ERROR parsing " + sub.getFeedUrl() + " : " + e.getClass().getName() + " : " + e.getMessage());
        logger.debug(e);
        return newEntries; // bail out
    }
    if (lastUpdated != null && sub.getLastUpdated() != null) {
        Calendar feedCal = Calendar.getInstance();
        feedCal.setTime(lastUpdated);

        Calendar subCal = Calendar.getInstance();
        subCal.setTime(sub.getLastUpdated());

        if (!feedCal.after(subCal)) {
            if (logger.isDebugEnabled()) {
                String msg = MessageFormat.format("   Skipping ({0} / {1})",
                        new Object[] { lastUpdated, sub.getLastUpdated() });
                logger.debug(msg);
            }
            return newEntries; // bail out
        }
    }
    if (feed.getPublishedDate() != null) {
        sub.setLastUpdated(feed.getPublishedDate());
        saveSubscription(sub);
    }

    // Kludge for Feeds without entry dates: most recent entry is given
    // feed's last publish date (or yesterday if none exists) and earler
    // entries are placed at once day intervals before that.
    Calendar cal = Calendar.getInstance();
    if (sub.getLastUpdated() != null) {
        cal.setTime(sub.getLastUpdated());
    } else {
        cal.setTime(new Date());
        cal.add(Calendar.DATE, -1);
    }

    // Populate subscription object with new entries
    Iterator entries = feed.getEntries().iterator();
    while (entries.hasNext()) {
        try {
            SyndEntry romeEntry = (SyndEntry) entries.next();
            PlanetEntryData entry = new PlanetEntryData(feed, romeEntry, sub);
            if (entry.getPublished() == null) {
                logger.debug("No published date, assigning fake date for " + feedUrl);
                entry.setPublished(cal.getTime());
            }
            if (entry.getPermalink() == null) {
                logger.warn("No permalink, rejecting entry from " + feedUrl);
            } else {
                saveEntry(entry);
                newEntries.add(entry);
            }
            cal.add(Calendar.DATE, -1);
        } catch (Exception e) {
            logger.error("ERROR processing subscription entry", e);
        }
    }
    return newEntries;
}

From source file:biz.varkon.shelvesom.provider.books.BooksUpdater.java

private boolean bookCoverUpdated(BooksStore.Book book, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;/*ww  w  . jav a  2 s  . c  o m*/

    final String tinyThumbnail = Preferences.getImageURLForUpdater(book);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(book));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + book, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(book.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + book, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + book, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + book, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.comics.ComicsUpdater.java

private boolean comicCoverUpdated(ComicsStore.Comic comic, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;//  w  ww . j av  a 2s . com

    final String tinyThumbnail = Preferences.getImageURLForUpdater(comic);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(comic));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + comic, npe);
        }

        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(comic.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + comic, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + comic, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + comic, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.videogames.VideoGamesUpdater.java

private boolean videogameCoverUpdated(VideoGamesStore.VideoGame videogame,
        ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;/*w w w .  j a  v a 2s.c om*/

    final String tinyThumbnail = Preferences.getImageURLForUpdater(videogame);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(videogame));
        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + videogame, npe);
            return false;
        }
        HttpEntity entity = null;
        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(videogame.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + videogame, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + videogame, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + videogame, e);
                }
            }
        }
    }
    return false;
}

From source file:biz.varkon.shelvesom.provider.movies.MoviesUpdater.java

private boolean movieCoverUpdated(MoviesStore.Movie movie, ImageUtilities.ExpiringBitmap expiring) {
    expiring.lastModified = null;//  w  ww. ja v  a2s.  c om

    final String tinyThumbnail = Preferences.getImageURLForUpdater(movie);

    if (tinyThumbnail != null && !tinyThumbnail.equals("")) {
        HttpGet get = null;
        try {
            get = new HttpGet(Preferences.getImageURLForUpdater(movie));

        } catch (NullPointerException npe) {
            android.util.Log.e(LOG_TAG, "Could not check modification image for " + movie, npe);
        }

        HttpEntity entity = null;

        try {
            final HttpResponse response = HttpManager.execute(get);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                entity = response.getEntity();

                final Header header = response.getFirstHeader("Last-Modified");
                if (header != null) {
                    final Calendar calendar = Calendar.getInstance();
                    try {
                        calendar.setTime(mLastModifiedFormat.parse(header.getValue()));
                        expiring.lastModified = calendar;
                        return calendar.after(movie.getLastModified());
                    } catch (ParseException e) {
                        return false;
                    }
                }
            }
        } catch (IOException e) {
            android.util.Log.e(LOG_TAG, "Could not check modification date for " + movie, e);
        } catch (IllegalArgumentException iae) {
            android.util.Log.e(LOG_TAG, "Null get value for " + movie, iae);
        } finally {
            if (entity != null) {
                try {
                    entity.consumeContent();
                } catch (IOException e) {
                    android.util.Log.e(LOG_TAG, "Could not check modification date for " + movie, e);
                }
            }
        }
    }
    return false;
}