-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from NordicSemiconductor/feature/force-update
Allowing reuploading images
- Loading branch information
Showing
4 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
sample/src/main/java/io/runtime/mcumgr/sample/dialog/YesNoDialogFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.runtime.mcumgr.sample.dialog; | ||
|
||
import android.app.Dialog; | ||
import android.os.Bundle; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.annotation.StringRes; | ||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.fragment.app.DialogFragment; | ||
|
||
public class YesNoDialogFragment extends DialogFragment { | ||
private static final String ARG_REQUEST_ID = "requestId"; | ||
private static final String ARG_TITLE_ID = "titleId"; | ||
private static final String ARG_QUESTION_ID = "questionId"; | ||
|
||
public interface Listener { | ||
void onAnswer(final int requestId, final boolean yes); | ||
} | ||
|
||
public static DialogFragment getInstance(final int requestId, | ||
@StringRes final int titleId, @StringRes final int questionId) { | ||
final DialogFragment fragment = new YesNoDialogFragment(); | ||
|
||
final Bundle args = new Bundle(); | ||
args.putInt(ARG_REQUEST_ID, requestId); | ||
args.putInt(ARG_TITLE_ID, titleId); | ||
args.putInt(ARG_QUESTION_ID, questionId); | ||
fragment.setArguments(args); | ||
|
||
return fragment; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) { | ||
final Bundle args = requireArguments(); | ||
final int requestId = args.getInt(ARG_REQUEST_ID); | ||
|
||
return new AlertDialog.Builder(requireContext()) | ||
.setTitle(args.getInt(ARG_TITLE_ID)) | ||
.setMessage(args.getInt(ARG_QUESTION_ID)) | ||
.setPositiveButton(android.R.string.yes, (dialog, which) -> { | ||
final Listener listener = (Listener) getParentFragment(); | ||
if (listener != null) | ||
listener.onAnswer(requestId, true); | ||
}) | ||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> { | ||
final Listener listener = (Listener) getParentFragment(); | ||
if (listener != null) | ||
listener.onAnswer(requestId, false); | ||
}) | ||
.create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters