решено: проблема была в моем классе Intent, где я забыл добавить в это намерение дополнительные элементы.
в классе Intent:
fun putExtras(extras: Bundle){
intent.putExtras(extras)
}
в классе FragmentOperation
Intent(context).putExtras(bundle)
Тогда остальной код работает
Исходный код
1)
Класс конфигурации
class Config : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.config)
FragmentOperation(this@Config).organizationNameConfig()
}
override fun onBackPressed() {
val dialog = Dialog(this@Config, getString(R.string.titleCancelConfiguration), getString(R.string.messageCancelConfiguration), R.drawable.round_exit_to_app_white_48, 2)
dialog.setLeftButtonText(R.string.yes)
dialog.getLeftButton().setOnClickListener {
dialog.dismiss()
finish()
}
dialog.setRightButtonText(R.string.back)
dialog.getRightButton().setOnClickListener {
dialog.dismiss()
}
}
}
Фрагмент ConfigFindOrganization
class ConfigFindOrganization{
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.config_database, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity!!.findViewById<Button>(R.id.configConfirm).setOnClickListener {
if (inputIsValid()) {
Request(context!!).findOrganization(organizationName.text.toString())
}
}
}
private fun inputIsValid(): Boolean {
val validation = Validation(context!!)
validation.checkEditTextInput(organizationName, R.string.inputDatabaseAddress)
return validation.inputIsValid()
}
Класс запроса
public class Request {
private Context context;
private Arguments arguments;
public Request(Context context) {
this.context = context;
this.arguments = new Arguments(((Activity) context).getIntent().getExtras()); -> Here is the error
try {
} catch (Exception e) {
Log.i("output", "no arguments has been found " + e.toString());
}
setBasicParams();
}
}
Класс аргументов
class Arguments(private val bundle: Bundle) {} -> null value is passed
2)
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.flashit.attendance, PID: 9636
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter bundle
at com.flashit.attendance.Arguments.<init>(Arguments.kt:5)
at com.flashit.attendance.Request.<init>(Request.java:48)
at com.flashit.attendance.ConfigFindOrganization$onViewCreated$1.onClick(ConfigFindOrganization.kt:24)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
3) Да, но я не вижу ошибок в своем коде