Skip to content

Commit

Permalink
Fixed several exceptions from play store
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudM committed Feb 7, 2018
1 parent 7deb666 commit 3423467
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ public void onResult(PictureResponse response) {
if (response.status == CameraWS.ResponseCode.OK) {
onResultPicture(response.url);
} else {
Toast.makeText(getContext(), R.string.connection_ws_unreachable, Toast.LENGTH_LONG).show();
if (getContext() != null) {
Toast.makeText(getContext(), R.string.connection_ws_unreachable, Toast.LENGTH_LONG).show();
}
}
}

Expand Down Expand Up @@ -199,6 +201,9 @@ public void onClick(View v) {
}

private void askToDisconnectCamera() {

if(getContext() == null) return;

AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
.setTitle(R.string.alert_disconnect_camera_title)
.setMessage(R.string.alert_disconnect_camera_message)
Expand Down Expand Up @@ -236,6 +241,7 @@ private void onResultPicture(String url) {
new Response.Listener<File>() {
@Override
public void onResponse(File file) {
if(getContext() == null) return;
Uri uri = getUriForFile(getContext(),
"com.thibaudperso.sonycamera.fileprovider",
mTemporaryPreviewPicture);
Expand All @@ -244,14 +250,17 @@ public void onResponse(File file) {
intent.setDataAndType(uri, "image/jpeg");
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(intent, PREVIEW_PICTURE_ACTIVITY_RESULT);
if(getActivity() == null) return;
getActivity().overridePendingTransition(0, 0);
}
},
new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
}
});
Volley.newRequestQueue(getContext()).add(request);
if(getContext() != null) {
Volley.newRequestQueue(getContext()).add(request);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class SimpleLiveviewSlicer {
* know the data structure.
*/
static class Payload {
/** jpeg data container */
/**
* jpeg data container
*/
final byte[] jpegData;

/** padding data container */
/**
* padding data container
*/
final byte[] paddingData;

/**
Expand All @@ -44,7 +48,7 @@ private Payload(byte[] jpegData, byte[] paddingData) {
* Opens Liveview HTTP GET connection and prepares for reading Packet data.
*
* @param liveviewUrl Liveview data url that is obtained by DD.xml or result
* of startLiveview API.
* of startLiveview API.
* @throws IOException generic errors or exception.
*/
void open(String liveviewUrl) throws IOException {
Expand Down Expand Up @@ -72,10 +76,14 @@ void open(String liveviewUrl) throws IOException {
* @throws IOException generic errors or exception.
*/
void close() throws IOException {
if (mInputStream != null) {
mInputStream.close();
mInputStream = null;
try {
if (mInputStream != null) {
mInputStream.close();
mInputStream = null;
}
} catch (Exception ignored) {
}

if (mHttpConn != null) {
mHttpConn.disconnect();
mHttpConn = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ public void onDevicesListChanged(List<Device> devices) {
mAdapter.notifyDataSetChanged();
updateList();

Toast.makeText(getContext(), R.string.connection_camera_list_updated,
Toast.LENGTH_SHORT).show();
if(getContext() != null) {
Toast.makeText(getContext(), R.string.connection_camera_list_updated,
Toast.LENGTH_SHORT).show();
}

if (mConnectionDeviceListUpdateButton != null &&
mConnectionDeviceListUpdateProgress != null) {
Expand Down

0 comments on commit 3423467

Please sign in to comment.