I’m trying to implement android-target-instructions library and I want to skip when user click on a skip button in the library it says .finish() to skip but nothing happened anyone can help ?
the library i’m talking about for reference
https://github.com/Kyash/android-target-instructions?tab=readme-ov-file#customize-simpletarget-layout
private fun showInstructions() {
val userCredentials = CommonUtilities.getUserTokenAndName(requireActivity())
val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireActivity())
if (!userCredentials.first.isNullOrEmpty()
&& !userCredentials.second.isNullOrEmpty()
// && CommonUtilities.isHomeFirstTimeOpening(requireActivity())
) {
val target1 = SimpleTarget.Builder(requireActivity())
.setTarget(binding.oscarChiefIc)
.setTitle("Floating Action Button")
.setHighlightRadius(100f) // Circle shape
.setDescription("Discover culinary inspirations - click to explore recipes and ingredients.")
.setMessageLayoutResId(R.layout.instruction_layout) // This is custom layout
.build()
val target2 = SimpleTarget.Builder(requireActivity())
.setTarget(binding.scanIcon)
.setTitle("Floating Action Button")
.setMessageLayoutResId(R.layout.instruction_layout) // This is custom layout
.setHighlightRadius(100f) // Circle shape
.setDescription("Scan all your products and add it to your cart.")
.build()
val inflater = LayoutInflater.from(requireContext())
val popupView: View = inflater.inflate(R.layout.popup_message_view, null)
val width = LinearLayout.LayoutParams.WRAP_CONTENT
val height = LinearLayout.LayoutParams.WRAP_CONTENT
val focusable = false
val popupWindow = PopupWindow(popupView, width, height, focusable)
val skipBtn = popupView.findViewById<Button>(R.id.skipBtn)
val targets = arrayListOf(target1, target2)
view?.post {
popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0)
}
skipBtn.setOnClickListener {
popupWindow.dismiss()
parentFragmentManager.beginTransaction()
.replace(R.id.container_frameLayout, NewHomeFragment()).addToBackStack(null).commit()
}
TargetInstructions.with(requireActivity())
.setTargets(targets)
.start()
}
sharedPrefs.edit().putBoolean(HOME_FIRST_RUN, false).apply()
}
I tried to make it reload the fragment but the problem that the steps still found because it has to be dismissed when clicking on it