Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CATROID-IDE-11 Adding User Defined Bricks Crashes App #4673

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class AddUserDataToUserDefinedBrickFragment : Fragment() {
}

private var dataTypeToAdd: UserDefinedBrickDataType? = null
private var activity: AppCompatActivity? = null
private var addUserDataUserBrickEditText: TextInputEditText? = null
private var addUserDataUserBrickTextLayout: TextInputLayout? = null
private var scrollView: ScrollView? = null
Expand Down Expand Up @@ -84,7 +83,7 @@ class AddUserDataToUserDefinedBrickFragment : Fragment() {
as UserDefinedBrickDataType
}
userDefinedBrick?.let {
val userBrickView = userDefinedBrick?.getView(getActivity())
val userBrickView = userDefinedBrick?.getView(requireActivity())
userBrickSpace.addView(userBrickView)
userBrickTextView = userDefinedBrick?.currentUserDefinedDataTextView
}
Expand Down Expand Up @@ -129,12 +128,12 @@ class AddUserDataToUserDefinedBrickFragment : Fragment() {
}
}

activity = getActivity() as AppCompatActivity
activity?.let {
Utils.showStandardSystemKeyboard(activity)
val actionBar = activity?.supportActionBar
val appCompatActivity = requireActivity() as AppCompatActivity
appCompatActivity.let {
Utils.showStandardSystemKeyboard(appCompatActivity)
val actionBar = appCompatActivity.supportActionBar
if (actionBar != null) {
activity?.supportActionBar?.setTitle(R.string.category_user_bricks)
appCompatActivity.supportActionBar?.setTitle(R.string.category_user_bricks)
}
}

Expand All @@ -146,12 +145,12 @@ class AddUserDataToUserDefinedBrickFragment : Fragment() {

override fun onAttach(context: Context) {
super.onAttach(context)
Utils.showStandardSystemKeyboard(activity)
Utils.showStandardSystemKeyboard(requireActivity())
}

override fun onDetach() {
super.onDetach()
Utils.hideStandardSystemKeyboard(activity)
Utils.hideStandardSystemKeyboard(requireActivity())
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
Expand All @@ -172,7 +171,7 @@ class AddUserDataToUserDefinedBrickFragment : Fragment() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.next) {
val fragmentManager = parentFragmentManager
Utils.hideStandardSystemKeyboard(activity)
Utils.hideStandardSystemKeyboard(requireActivity())
fragmentManager.let {
val addUserDefinedBrickFragment =
fragmentManager.findFragmentByTag(AddUserDefinedBrickFragment.TAG)
Expand Down