Add realization of taking value from bundle qr
This commit is contained in:
parent
ce36d38d01
commit
15afc5f8b3
@ -21,7 +21,7 @@ import ru.myitschool.work.ui.qr.scan.QrScanDestination;
|
|||||||
public class QrResultFragment extends Fragment {
|
public class QrResultFragment extends Fragment {
|
||||||
|
|
||||||
private FragmentQrResultBinding binding;
|
private FragmentQrResultBinding binding;
|
||||||
private Bundle resultQr;
|
private String resultQr;
|
||||||
private QrResultViewModel viewModel;
|
private QrResultViewModel viewModel;
|
||||||
|
|
||||||
public QrResultFragment() {
|
public QrResultFragment() {
|
||||||
@ -35,7 +35,7 @@ public class QrResultFragment extends Fragment {
|
|||||||
getParentFragmentManager().setFragmentResultListener(QrScanDestination.REQUEST_KEY, this, new FragmentResultListener() {
|
getParentFragmentManager().setFragmentResultListener(QrScanDestination.REQUEST_KEY, this, new FragmentResultListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) {
|
public void onFragmentResult(@NonNull String requestKey, @NonNull Bundle result) {
|
||||||
resultQr = result;
|
resultQr = QrScanDestination.INSTANCE.getDataIfExist(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -69,8 +69,8 @@ public class QrResultFragment extends Fragment {
|
|||||||
if (getContext() != null) {
|
if (getContext() != null) {
|
||||||
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login", Context.MODE_PRIVATE);
|
||||||
String login = sharedPreferences.getString("login", null);
|
String login = sharedPreferences.getString("login", null);
|
||||||
if (login != null && getView() != null) {
|
if (login != null && resultQr != null) {
|
||||||
viewModel.update(login, "12314543654745676");
|
viewModel.update(login, resultQr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ data object QrScanDestination {
|
|||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun packToBundle(data: String): Bundle {
|
internal fun packToBundle(data: String): Bundle {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user