List with web links.
authorgumartinm <gustavo@gumartinm.name>
Fri, 4 May 2012 06:51:39 +0000 (08:51 +0200)
committergumartinm <gustavo@gumartinm.name>
Fri, 4 May 2012 06:51:39 +0000 (08:51 +0200)
Click on the item and you go to the specified web advertising.

Android/MobiAds/res/drawable-hdpi/alert_dialog_icon.png [changed mode: 0755->0644]
Android/MobiAds/res/values/strings.xml
Android/MobiAds/src/de/android/mobiads/MobiAdsLoginActivity.java
Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java
Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java

index 83f2cf0..8a0a490 100644 (file)
@@ -5,7 +5,7 @@
     <string name="app_name">MobiAds</string>
     <string name="app_description">Receive notifications about offers and discounts.</string>
     <string name="alert_dialog_cancel">Do you really want to close the application?</string>
-    <string name="error_dialog_connection_error">Connection error with MobiAd server.</string>
+    <string name="error_dialog_connection_error">Connection error with MobiAds server.</string>
     <string name="error_dialog_userpwd_error">The username or password you entered is incorrect.</string>
     <string name="username">Username</string>
     <string name="password">Password</string>
index 6f0ccc8..5d9318a 100644 (file)
@@ -65,12 +65,15 @@ public class MobiAdsLoginActivity extends Activity {
                httpResponse = httpClient.execute(httpPost);
                } catch (UnsupportedEncodingException e) {
                        Log.e(TAG, "Error while encoding POST parameters.", e);
+                       return;
                } catch (ClientProtocolException e) {
                        Log.e(TAG, "Error while executing HTTP client connection.", e);
                        createErrorDialog(R.string.error_dialog_connection_error);
+                       return;
                } catch (IOException e) {
                        Log.e(TAG, "Error while executing HTTP client connection.", e);
                        createErrorDialog(R.string.error_dialog_connection_error);
+                       return;
                } finally {
                        httpClient.getConnectionManager().shutdown();
                }
index 0c6d929..41ca3d1 100644 (file)
@@ -5,21 +5,25 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+
 import de.android.mobiads.R;
 import de.android.mobiads.provider.Indexer;
 import android.app.Activity;
+import android.content.Intent;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ListView;
 
 public class MobiAdsListActivity extends Activity {
        private static final String TAG = "MobiAdsListActivity";
        
-    /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -35,6 +39,16 @@ public class MobiAdsListActivity extends Activity {
         for(final AdsEntry entry : getAdsEntries()) {
                newsEntryAdapter.add(entry);
         }
+        
+        newsEntryListView.setOnItemClickListener(new OnItemClickListener() {
+
+                       @Override
+                       public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                               Uri uri = Uri.parse(newsEntryAdapter.getItem(position).getTitle());
+                               startActivity( new Intent( Intent.ACTION_VIEW, uri ) );
+                               }
+        });
+        
     }
     
     private List<AdsEntry> getAdsEntries() {
@@ -51,14 +65,17 @@ public class MobiAdsListActivity extends Activity {
                                                file = this.openFileInput(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_PATH)));
                                                bitMap = BitmapFactory.decodeStream(file);
                                        } catch (FileNotFoundException e) {
+                                               continue;
                                        } catch (IllegalArgumentException e) {
                                                continue;
                                        }
                                        finally {
-                                               try {
-                                                       file.close();
-                                               } catch (IOException e) {
-                                                       Log.w(TAG, "Error while closing image file.");
+                                               if (file != null) {
+                                                       try {
+                                                               file.close();
+                                                       } catch (IOException e) {
+                                                               Log.w(TAG, "Error while closing image file.");
+                                                       }
                                                }
                                        }
                                        entries.add(new AdsEntry(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_URL)), 
index 272aff0..417c027 100644 (file)
@@ -12,7 +12,6 @@ import android.database.sqlite.SQLiteQueryBuilder;
 import android.database.sqlite.SQLiteReadOnlyDatabaseException;
 import android.net.Uri;
 import android.text.TextUtils;
-import android.util.Log;
 
 
 /**