* Target we publish for clients to send messages to IncomingHandler.
*/
final Messenger mMessenger = new Messenger(new IncomingHandler());
- /**TODO: I should use message with service to find out if the service is running instead of this booleanf field.*/
+ /**TODO: I should send a message to the service to find out if the service is running instead of this boolean field.*/
private boolean isEnabledService;
private static String cookie;
JSONObject objects = finalResult.getJSONObject(i);
if ((uriInsert = updatedIndexer(objects)) != null) {
try {
- downloadAds((String)objects.get("domain"), (String)objects.get("link"), (String) objects.get("id"));
+ downloadAds((String)objects.get("image"), (String) objects.get("id"));
((MobiAdsService)MobiAdsBatch.this.context).showNotification(1);
} catch (Throwable e1) {
//In case of any error, remove the index database and the file
return builder;
}
- public void downloadAds(String domain, String link, String path)
+ public void downloadAds(String image, String path)
throws MalformedURLException, URISyntaxException, FileNotFoundException, IOException {
final HttpGet httpGet = new HttpGet();
- final String URLAd = "http://" + domain + "/" + link;
+ final String URLAd = image;
HttpResponse httpResponse = null;
URL url = null;
OutputStream outputStream = null;
ContentValues values = new ContentValues();
values.put(Indexer.Index.COLUMN_NAME_ID_AD, new Integer((String) objects.get("id")));
values.put(Indexer.Index.COLUMN_NAME_PATH, (String) objects.get("id"));
+ values.put(Indexer.Index.COLUMN_NAME_TEXT, (String) objects.get("text"));
+ values.put(Indexer.Index.COLUMN_NAME_URL, (String) objects.get("link"));
//This method may throw SQLiteException (as a RunTimeException). So, without a try/catch block
//there could be a leaked cursor...
//TODO: review code looking for more cases like this one...
// If the values map doesn't contain the path or ad identifier number.
if ((values.containsKey(Indexer.Index.COLUMN_NAME_PATH) == false) ||
- (values.containsKey(Indexer.Index.COLUMN_NAME_ID_AD) == false)){
+ (values.containsKey(Indexer.Index.COLUMN_NAME_ID_AD) == false) ||
+ (values.containsKey(Indexer.Index.COLUMN_NAME_TEXT) == false) ||
+ (values.containsKey(Indexer.Index.COLUMN_NAME_URL) == false)){
throw new SQLException("Missed parameter. Failed to insert row into " + uri);
}
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
// Performs the insert and returns the ID of the new index.
- values.put(Indexer.Index.COLUMN_NAME_TEXT, "Texto de prueba");
- values.put(Indexer.Index.COLUMN_NAME_URL, "http://gumartinm.name");
+ //values.put(Indexer.Index.COLUMN_NAME_TEXT, "Texto de prueba");
+ //values.put(Indexer.Index.COLUMN_NAME_URL, "http://gumartinm.name");
long rowId = db.insert(
Indexer.Index.TABLE_NAME, // The table to insert into.
null, // A hack, SQLite sets this column value to null if values is empty.