2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-02 23:25:10 +00:00

Fixes some potential null pointer exceptions reported by Coverity

This commit is contained in:
Albert Vaca
2015-04-04 14:25:02 -07:00
parent 11012e21e5
commit 9cf9f43118
4 changed files with 68 additions and 59 deletions

View File

@@ -328,6 +328,8 @@ public class LanLinkProvider extends BaseLinkProvider {
e.printStackTrace();
Log.e("KDE/LanLinkProvider","Failed to create DatagramSocket");
}
if (bytes != null) {
//Log.e("KDE/LanLinkProvider","Sending packet to "+iplist.size()+" ips");
for (String ipstr : iplist) {
try {
@@ -340,6 +342,8 @@ public class LanLinkProvider extends BaseLinkProvider {
Log.e("KDE/LanLinkProvider", "Sending udp identity package failed. Invalid address? (" + ipstr + ")");
}
}
}
socket.close();
}

View File

@@ -144,6 +144,7 @@ public class ShareActivity extends ActionBarActivity {
Device device = devicesList.get(i-1); //NOTE: -1 because of the title!
Bundle extras = intent.getExtras();
if (extras != null) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
try {
@@ -191,8 +192,7 @@ public class ShareActivity extends ActionBarActivity {
}
device.sendPackage(np);
}
}
finish();
}

View File

@@ -108,9 +108,12 @@ public class CustomDevicesActivity extends ListActivity {
InputMethodManager inputManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
View focus = getCurrentFocus();
if (focus != null) {
inputManager.hideSoftInputFromWindow(focus.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
void saveList() {
// add entry to list and save to preferences (unless empty)

View File

@@ -46,11 +46,13 @@ public class SmallEntryItem implements ListAdapter.Item {
View v = layoutInflater.inflate(android.R.layout.simple_list_item_1, null);
TextView titleView = (TextView)v.findViewById(android.R.id.text1);
if (titleView != null) titleView.setText(title);
if (titleView != null) {
titleView.setText(title);
if (clickListener != null) {
titleView.setOnClickListener(clickListener);
v.setBackgroundDrawable(layoutInflater.getContext().getResources().getDrawable(R.drawable.abc_list_selector_holo_dark));
}
}
return v;
}