From: gumartinm Date: Fri, 4 May 2012 06:51:39 +0000 (+0200) Subject: List with web links. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=48f3a803afc5aa32e5bc1e02214a7732e5e69823;p=JavaForFun List with web links. Click on the item and you go to the specified web advertising. --- diff --git a/Android/MobiAds/res/drawable-hdpi/alert_dialog_icon.png b/Android/MobiAds/res/drawable-hdpi/alert_dialog_icon.png old mode 100755 new mode 100644 diff --git a/Android/MobiAds/res/values/strings.xml b/Android/MobiAds/res/values/strings.xml index 83f2cf0..8a0a490 100644 --- a/Android/MobiAds/res/values/strings.xml +++ b/Android/MobiAds/res/values/strings.xml @@ -5,7 +5,7 @@ MobiAds Receive notifications about offers and discounts. Do you really want to close the application? - Connection error with MobiAd server. + Connection error with MobiAds server. The username or password you entered is incorrect. Username Password diff --git a/Android/MobiAds/src/de/android/mobiads/MobiAdsLoginActivity.java b/Android/MobiAds/src/de/android/mobiads/MobiAdsLoginActivity.java index 6f0ccc8..5d9318a 100644 --- a/Android/MobiAds/src/de/android/mobiads/MobiAdsLoginActivity.java +++ b/Android/MobiAds/src/de/android/mobiads/MobiAdsLoginActivity.java @@ -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(); } diff --git a/Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java b/Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java index 0c6d929..41ca3d1 100644 --- a/Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java +++ b/Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java @@ -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 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)), diff --git a/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java b/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java index 272aff0..417c027 100644 --- a/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java +++ b/Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java @@ -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; /**