Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent a potential NPE

  • Loading branch information...
commit b68277c154d1f5b5c3f3ada3566cf94cbe0add38 1 parent 51edf15
@pilhuhn authored
View
5 AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.rhq.pocket"
- android:versionCode="1"
- android:versionName="1.0"
+ android:versionCode="2"
+ android:versionName="0.2"
android:installLocation="preferExternal"
>
@@ -12,7 +12,6 @@
<supports-screens android:largeScreens="true"/>
<supports-screens android:xlargeScreens="true"/>
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
View
15 src/org/rhq/pocket/resource/ResourceActivity.java
@@ -154,6 +154,12 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
+
+ if (item.getItemId()==R.id.pick_resource) {
+ pickResource();
+ return true;
+ }
+
switch (item.getItemId()) {
case R.id.list_alerts:
intent = new Intent(this, AlertActivity.class);
@@ -181,10 +187,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
startActivity(intent);
return true;
case R.id.add_to_favorites:
- addToFavorites(resource.getResourceId());
- return true;
- case R.id.pick_resource:
- pickResource();
+ addToFavorites(resource);
return true;
}
@@ -192,8 +195,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
- private void addToFavorites(int resourceId) {
- if (resourceId==-1) {
+ private void addToFavorites(ResourceWithType resource) {
+ if (resource==null || resource.getResourceId()==-1) {
Toast.makeText(this, "Select a resource first", Toast.LENGTH_SHORT).show();
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.