Latest changes in Android MobiAds
authorgumartinm <gustavo@gumartinm.name>
Wed, 23 May 2012 07:08:17 +0000 (09:08 +0200)
committergumartinm <gustavo@gumartinm.name>
Wed, 23 May 2012 07:08:17 +0000 (09:08 +0200)
No time for comments

Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java
Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java
Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java

index 00dab75..2fc737d 100644 (file)
@@ -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;
 
index 8e2209e..3c4a83e 100644 (file)
@@ -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...
index 417c027..6ac3c21 100644 (file)
@@ -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.