mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-02 15:15:09 +00:00
Fixes some potential null pointer exceptions reported by Coverity
This commit is contained in:
@@ -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 {
|
||||
@@ -335,11 +337,13 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
DatagramPacket packet = new DatagramPacket(bytes, bytes.length, client, port);
|
||||
socket.send(packet);
|
||||
//Log.i("KDE/LanLinkProvider","Udp identity package sent to address "+packet.getAddress());
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("KDE/LanLinkProvider","Sending udp identity package failed. Invalid address? ("+ipstr+")");
|
||||
Log.e("KDE/LanLinkProvider", "Sending udp identity package failed. Invalid address? (" + ipstr + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
socket.close();
|
||||
|
||||
}
|
||||
|
@@ -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 {
|
||||
@@ -172,7 +173,7 @@ public class ShareActivity extends ActionBarActivity {
|
||||
if (subject != null && subject.endsWith("YouTube")) {
|
||||
int index = text.indexOf(": http://youtu.be/");
|
||||
if (index > 0) {
|
||||
text = text.substring(index+2); //Skip ": "
|
||||
text = text.substring(index + 2); //Skip ": "
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ public class ShareActivity extends ActionBarActivity {
|
||||
try {
|
||||
new URL(text);
|
||||
isUrl = true;
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
isUrl = false;
|
||||
}
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_SHARE);
|
||||
@@ -191,8 +192,7 @@ public class ShareActivity extends ActionBarActivity {
|
||||
}
|
||||
device.sendPackage(np);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user