<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>
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();
}
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);
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() {
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)),