/**
  * cache hit <==> for all ic in ics: ic.timecached >= now - timeout cache miss <==> exists ic in
  * ics: ic.timecached < now - timeout timeout zero or ics is empty ==> cache miss
  *
  * @return true if it's a cache hit, false otherwise
  */
 protected boolean isCacheHit(HashMap<Long, IConvertible> ics) {
   boolean isHit = true;
   long timeout = utilsPreferences.getInt("lasttimeout", 0) * 60L;
   if (timeout > 0 && !ics.isEmpty()) {
     long nowLessTimeout = AppUtils.getInstance().getDateTime() - timeout;
     Iterator<IConvertible> itr = ics.values().iterator();
     while (itr.hasNext() && isHit) {
       if (itr.next().getTimecached() < nowLessTimeout) isHit = false;
     }
   } else {
     isHit = false;
   }
   return isHit;
 }
 /**
  * cache hit <==> ic.timecached >= now - timeout cache miss <==> ic.timecached < now - timeout
  * timeout zero ==> cache miss
  *
  * @return true if it's a cache hit, false otherwise
  */
 protected boolean isCacheHit(IConvertible ic) {
   return AppUtils.getInstance().getDateTime() - ic.getTimecached()
       < utilsPreferences.getInt("lasttimeout", 0) * 60L;
 }
 /** Constructor (Dependency Injection Pattern) */
 public AbstractOfflineService() {
   utilsPreferences =
       contextProvider
           .get()
           .getSharedPreferences(AppUtils.getInstance().getPrefs(), Context.MODE_PRIVATE);
 }
 /**
  * cache hit <==> timecached >= now - timeout cache miss <==> timecached < now - timeout timeout
  * zero ==> cache miss
  *
  * @return true if it's a cache hit, false otherwise
  */
 protected boolean isCacheHit(long timecached) {
   return AppUtils.getInstance().getDateTime() - timecached
       < utilsPreferences.getInt("lasttimeout", 0) * 60L;
 }
 /** @return true if it's possible the online mode, false otherwise */
 protected boolean isOnline() {
   return AppUtils.getInstance().isWifiConnected()
       || AppUtils.getInstance().isMobileConnected()
           && utilsPreferences.getInt("lastmobile", 0) != 0;
 }