Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
(hopefully) fixed a crash that occurred on orientation change right b…
Browse files Browse the repository at this point in the history
…efore calling the image picker
  • Loading branch information
y20k committed Dec 26, 2015
1 parent 4db2171 commit 4ec3c1b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.y20k.transistor"
minSdkVersion 19
targetSdkVersion 23
versionCode 11
versionName "1.1.2 (Running Gun Blues)"
versionCode 12
versionName "1.1.3 (Running Gun Blues)"
}
buildTypes {
release {
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.y20k.transistor"
android:versionCode="11"
android:versionName="1.1.2 (Running Gun Blues)">
android:versionCode="12"
android:versionName="1.1.3 (Running Gun Blues)">

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />

Expand All @@ -23,7 +23,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:configChanges="keyboardHidden|orientation|screenSize">

<!-- Launcher -->
<intent-filter>
Expand Down Expand Up @@ -59,9 +60,10 @@
<activity
android:name=".InfosheetActivity"
android:label="@string/title_activity_infosheet"
android:parentActivityName=".MainActivity" >
android:parentActivityName=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize">

<meta-data
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.y20k.transistor.MainActivity" />

Expand All @@ -72,9 +74,10 @@
<activity
android:name=".PlayerActivity"
android:label="@string/title_activity_player"
android:parentActivityName=".MainActivity" >
android:parentActivityName=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize">

<meta-data
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.y20k.transistor.MainActivity" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
public void onResume() {
super.onResume();

// // get activity that this fragment is currently attached to
// mActivity = getActivity();

// handle incoming intent
handleNewStationIntent();
}
Expand Down Expand Up @@ -431,7 +434,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
} else {
// permission denied
}
return;
}
}
}
Expand Down Expand Up @@ -462,7 +464,7 @@ private void processNewImage(Uri newImageUri) {
Log.e(LOG_TAG, "Unable to save: " + newImage.toString());
}
} else {
Log.e(LOG_TAG, "Unable to get image from media picker: " + newImage.toString());
Log.e(LOG_TAG, "Unable to get image from media picker: " + newImageUri.toString());
// TODO handle error here
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
} else {
// permission denied
}
return;
}
}
}
Expand Down Expand Up @@ -344,7 +343,7 @@ private void processNewImage(Uri newImageUri) {
Bitmap stationImage = imageHelper.createCircularFramedImage(192);
mStationImageView.setImageBitmap(stationImage);
} else {
Log.e(LOG_TAG, "Unable to get image from media picker: " + newImage.toString());
Log.e(LOG_TAG, "Unable to get image from media picker: " + newImageUri.toString());
// TODO handle error here
}
}
Expand Down
30 changes: 18 additions & 12 deletions app/src/main/java/org/y20k/transistor/helpers/ImageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ else if (inputImageHeight > inputImageWidth) {
/* Return sampled down image for given Uri */
private Bitmap decodeSampledBitmapFromUri(Uri imageUri, int reqWidth, int reqHeight) {

Bitmap bitmap = null;
Bitmap bitmap;
ParcelFileDescriptor parcelFileDescriptor = null;

try {
Expand All @@ -147,21 +147,27 @@ private Bitmap decodeSampledBitmapFromUri(Uri imageUri, int reqWidth, int reqHei
e.printStackTrace();
}

FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
if (parcelFileDescriptor != null) {
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();

// decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
// decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);

// calculate inSampleSize
options.inSampleSize = calculateSampleParameter(options, reqWidth, reqHeight);
// calculate inSampleSize
options.inSampleSize = calculateSampleParameter(options, reqWidth, reqHeight);

// decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
// decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);

return bitmap;

} else {
return null;
}

return bitmap;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
*/
public class StationContextMenu extends DialogFragment {

/* Define log tag */
private static final String LOG_TAG = StationContextMenu.class.getSimpleName();


/* Keys */
private static final String ACTION_IMAGE_CHANGE_REQUESTED = "org.y20k.transistor.action.IMAGE_CHANGE_REQUESTED";
Expand Down

0 comments on commit 4ec3c1b

Please sign in to comment.