Skip to content

Commit

Permalink
Bugfix on image picking
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisfeld committed Oct 4, 2021
1 parent 3177e94 commit 0676a65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LifxAppEclipse/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<classpathentry kind="lib" path="libs-local/annotation-1.1.0.jar"/>
<classpathentry kind="lib" path="libs-local/core-1.1.0-rc03.jar"/>
<classpathentry kind="lib" path="libs-local/appcompat-1.3.1.jar"/>
<classpathentry kind="lib" path="libs-local/constraintlayout-2.1.0.jar"/>
<classpathentry kind="lib" path="libs-local/constraintlayout-2.1.1.jar"/>
<classpathentry kind="lib" path="libs-local/lifecycle-extensions-2.2.0.jar"/>
<classpathentry kind="lib" path="libs-local/material-1.4.0.jar"/>
<classpathentry kind="lib" path="libs-local/savedstate-1.0.0.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion LifxTools/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ public class PickedImageDialogFragment extends DialogFragment {
* The overhead size taken when prescaling the image before setting contrast and saturation.
*/
private static final int PRESCALE_OVERHEAD_FACTOR = 4;
/**
* Flag indicating if ok has been pressed.
*/
private boolean isOkPressed = false;

/**
* Display a dialog for handling a picked image for a tile chain.
*
* @param activity the current activity
* @param model the light model.
* @param bitmap the picked image.
* @param model the light model.
* @param bitmap the picked image.
* @param listener The listener waiting for the response
*/
public static void displayPickedImageDialog(final FragmentActivity activity,
Expand Down Expand Up @@ -204,13 +208,14 @@ public final Dialog onCreateDialog(final Bundle savedInstanceState) {
builder.setTitle(R.string.title_dialog_image)
.setView(view) //
.setNegativeButton(R.string.button_cancel, (dialog, id) -> {
// Send the positive button event back to the host activity
// Send the negative button event back to the host activity
if (mListener != null && mListener.getValue() != null) {
mListener.getValue().onDialogNegativeClick(PickedImageDialogFragment.this);
}
}) //
.setPositiveButton(R.string.button_ok, (dialog, id) -> {
// Send the negative button event back to the host activity
// Send the positive button event back to the host activity
isOkPressed = true;
if (mListener != null && mListener.getValue() != null) {
mListener.getValue().onDialogPositiveClick(PickedImageDialogFragment.this, mCurrentColors);
}
Expand All @@ -229,8 +234,7 @@ public final void onCancel(@Nonnull final DialogInterface dialogInterface) {
@Override
public final void onPause() {
super.onPause();
// this dialog does not support onPause as it has serialization issues in colors.
if (mListener != null && mListener.getValue() != null) {
if (mListener != null && mListener.getValue() != null && !isOkPressed) {
mListener.getValue().onDialogNegativeClick(PickedImageDialogFragment.this);
}
dismiss();
Expand Down

0 comments on commit 0676a65

Please sign in to comment.