From c637c0bde1916d0e9135a9ff395489bdd0a0e20a Mon Sep 17 00:00:00 2001 From: gumartinm Date: Wed, 23 May 2012 09:08:17 +0200 Subject: [PATCH] Latest changes in Android MobiAds No time for comments --- Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java | 2 +- Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java | 8 +++++--- .../MobiAds/src/de/android/mobiads/provider/IndexerProvider.java | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java b/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java index 00dab75..2fc737d 100644 --- a/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java +++ b/Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java @@ -27,7 +27,7 @@ public class MobiAdsMainActivity extends Activity { * 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; diff --git a/Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java b/Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java index 8e2209e..3c4a83e 100644 --- a/Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java +++ b/Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java @@ -115,7 +115,7 @@ public class MobiAdsBatch { 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 @@ -204,10 +204,10 @@ public class MobiAdsBatch { 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; @@ -272,6 +272,8 @@ public class MobiAdsBatch { 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... diff --git a/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java b/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java index 417c027..6ac3c21 100644 --- a/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java +++ b/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java @@ -215,7 +215,9 @@ public class IndexerProvider extends ContentProvider { // 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); } @@ -224,8 +226,8 @@ public class IndexerProvider extends ContentProvider { 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. -- 2.1.4