Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_form_add_edit_service, container, false); String ServiceName = this.getActivity().getIntent().getStringExtra("service_name"); String ServiceDuration = this.getActivity().getIntent().getStringExtra("service_duration"); String ServiceDescription = this.getActivity().getIntent().getStringExtra("service_description"); Integer edit_or_new= this.getActivity().getIntent().getIntExtra("edit_or_new",1); String Uuid = this.getActivity().getIntent().getStringExtra("service_uuid"); EditText mServiceName = (EditText) root.findViewById(R.id.serviceName); mServiceName.setText(ServiceName); EditText mServiceDuration = (EditText) root.findViewById(R.id.serviceDuration); mServiceDuration.setText(ServiceDuration); EditText mServiceDescription = (EditText) root.findViewById(R.id.serviceDiscription); Button mServiceSave = (Button) root.findViewById(R.id.Save); Button mServiceDelete = (Button) root.findViewById(R.id.Delete); switch (edit_or_new) { case 0: mServiceDelete.setVisibility(View.GONE); mServiceSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.addServiceTypes(mServiceName.getText(),mServiceDescription.getText(),mServiceDuration.getText()); } }); break; case 1: mServiceSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.editServiceTypes(mServiceName.getText(),mServiceDescription.getText(),mServiceDuration.getText(),Uuid); } }); mServiceDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.deleteServiceTypes(Uuid); } }); break; default: break; } if (null != ServiceDescription) { mServiceDescription.setText(ServiceDescription); } else { mServiceDescription.setText("No Description"); } FontsUtil.setFont((ViewGroup) this.getActivity().findViewById(android.R.id.content)); return root; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_form_add_edit_service, container, false); String ServiceName = this.getActivity().getIntent().getStringExtra("service_name"); String ServiceDuration = this.getActivity().getIntent().getStringExtra("service_duration"); String ServiceDescription = this.getActivity().getIntent().getStringExtra("service_description"); String edit_or_new= this.getActivity().getIntent().getStringExtra("edit_or_new"); String Uuid = this.getActivity().getIntent().getStringExtra("service_uuid"); EditText mServiceName = (EditText) root.findViewById(R.id.serviceName); mServiceName.setText(ServiceName); EditText mServiceDuration = (EditText) root.findViewById(R.id.serviceDuration); mServiceDuration.setText(ServiceDuration); EditText mServiceDescription = (EditText) root.findViewById(R.id.serviceDiscription); Button mServiceSave = (Button) root.findViewById(R.id.Save); Button mServiceDelete = (Button) root.findViewById(R.id.Delete); switch (edit_or_new) { case "new_form": mServiceDelete.setVisibility(View.GONE); mServiceSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.addServiceTypes(mServiceName.getText(),mServiceDescription.getText(),mServiceDuration.getText()); } }); break; case "edit_form": mServiceSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.editServiceTypes(mServiceName.getText(),mServiceDescription.getText(),mServiceDuration.getText(),Uuid); } }); mServiceDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.deleteServiceTypes(Uuid); } }); break; default: break; } if (null != ServiceDescription) { mServiceDescription.setText(ServiceDescription); } else { mServiceDescription.setText("No Description"); } FontsUtil.setFont((ViewGroup) this.getActivity().findViewById(android.R.id.content)); return root; }