private void loadLogFromDatabase() { final LogEntry log = DataStore.loadLogOffline(geocode); if (log != null) { typeSelected = log.getType(); date.setTime(new Date(log.date)); text = log.log; } else if (StringUtils.isNotBlank(Settings.getSignature()) && Settings.isAutoInsertSignature() && StringUtils.isBlank(currentLogText())) { insertIntoLog( LogTemplateProvider.applyTemplates(Settings.getSignature(), new LogContext(cache, null)), false); } }
@Override public final void endElement(final String uri, final String localName, final String qName) throws SAXException { try { if (localName.equalsIgnoreCase("geolutin_id")) { trackable.setGeocode(content); } if (localName.equalsIgnoreCase("nom")) { trackable.setName(content); } if (localName.equalsIgnoreCase("description")) { trackable.setDetails(content); isMultiline = false; } if (localName.equalsIgnoreCase("esprit_nom")) { if (isInApparition) { logEntryBuilder.setAuthor(content); } else { trackable.setOwner(content); } } if (StringUtils.isNotBlank(content) && localName.equalsIgnoreCase("date_naissance")) { final Date date = DATE_FORMAT.parse(content); trackable.setReleased(date); } if (StringUtils.isNotBlank(content) && localName.equalsIgnoreCase("distance_parcourue")) { trackable.setDistance(Float.parseFloat(content)); } if (localName.equalsIgnoreCase("date_apparition_disparition")) { logEntryBuilder.setDate(DATE_FORMAT.parse(content).getTime()); } if (localName.equalsIgnoreCase("commentaires")) { logEntryBuilder.setLog(content); } if (localName.equalsIgnoreCase("type")) { logEntryBuilder.setLogType(getLogType(content)); } if (localName.equalsIgnoreCase("geolutin")) { trackable.setLogs(logsEntries); // manage spotted field if (!logsEntries.isEmpty()) { // retrieve the first logEntry final LogEntry lastLog = logsEntries.get(0); if (lastLog.getType() == LogType.PLACED_IT) { // it's in a cache trackable.setSpottedType(Trackable.SPOTTED_CACHE); trackable.setSpottedName(lastLog.cacheName); } else if (lastLog.getType() == LogType.RETRIEVED_IT) { trackable.setSpottedName(lastLog.author); // it's in someone hands trackable.setSpottedType(Trackable.SPOTTED_USER); trackable.setSpottedName(lastLog.author); } else { Log.e("GeolutinsHandler.endElement unknown logtype:" + lastLog.getType()); } } } if (localName.equalsIgnoreCase("apparition_disparition")) { isInApparition = false; logsEntries.add(logEntryBuilder.build()); } } catch (final ParseException | NumberFormatException e) { Log.e("Parsing GeoLutins", e); } }