use of xyz.zedler.patrick.grocy.helper.DownloadHelper in project grocy-android by patzly.
the class MasterStoreFragment method onViewCreated.
@Override
public void onViewCreated(@Nullable View view, @Nullable Bundle savedInstanceState) {
activity = (MainActivity) requireActivity();
debug = PrefsUtil.isDebuggingEnabled(activity);
// WEB
dlHelper = new DownloadHelper(activity, TAG);
grocyApi = activity.getGrocyApi();
gson = new Gson();
// VARIABLES
stores = new ArrayList<>();
storeNames = new ArrayList<>();
editStore = null;
isRefresh = false;
// VIEWS
binding.frameMasterStoreCancel.setOnClickListener(v -> activity.onBackPressed());
// swipe refresh
binding.swipeMasterStore.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(activity, R.color.surface));
binding.swipeMasterStore.setColorSchemeColors(ContextCompat.getColor(activity, R.color.secondary));
binding.swipeMasterStore.setOnRefreshListener(this::refresh);
// name
binding.editTextMasterStoreName.setOnFocusChangeListener((View v, boolean hasFocus) -> {
if (hasFocus) {
ViewUtil.startIcon(binding.imageMasterStoreName);
}
});
// description
binding.editTextMasterStoreDescription.setOnFocusChangeListener((View v, boolean hasFocus) -> {
if (hasFocus) {
ViewUtil.startIcon(binding.imageMasterStoreDescription);
}
});
MasterStoreFragmentArgs args = MasterStoreFragmentArgs.fromBundle(requireArguments());
editStore = args.getStore();
if (editStore != null) {
fillWithEditReferences();
} else if (savedInstanceState == null) {
resetAll();
new Handler().postDelayed(() -> activity.showKeyboard(binding.editTextMasterStoreName), 50);
}
if (savedInstanceState == null) {
load();
} else {
restoreSavedInstanceState(savedInstanceState);
}
// UPDATE UI
updateUI((getArguments() == null || getArguments().getBoolean(Constants.ARGUMENT.ANIMATED, true)) && savedInstanceState == null);
}
Aggregations