NexusDialog icon indicating copy to clipboard operation
NexusDialog copied to clipboard

Allow form elements visibility

Open Rodolfocartas opened this issue 10 years ago • 7 comments

I've added the ability to hide elements and sections.

Rodolfocartas avatar Jun 22 '15 21:06 Rodolfocartas

Thanks for your contribution!

I'm reviewing the code changes, but would you please squash the commits into one? I'll add my comments once that's done. Thanks.

dkharrat avatar Jun 28 '15 02:06 dkharrat

@Rodolfocartas any update on your branch?

dkharrat avatar Aug 04 '15 02:08 dkharrat

When this PR will be merged? Thanks.

dneykov avatar Jun 23 '17 08:06 dneykov

@dneykov: It hasn't been merged yet because I haven't received an update from @Rodolfocartas regarding my comments. In any case, it's likely that this PR is out-of-sync with master, so it might have to be re-implemented.

If you need this functionality, one way to get it is to do it on the View object directly. Each FormElement provides access to the its underlying view.

dkharrat avatar Jun 23 '17 19:06 dkharrat

Thanks for your quick response. I will take your suggestions.

dneykov avatar Jun 23 '17 19:06 dneykov

@dkharrat When I try to access the view is giving an error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.github.dkharrat.nexusdialog.FormModel.getValue(java.lang.String)' on a null object reference

Here is what I'm trying:

tmpElement = new EditTextController(this, field.getId(), field.getLabel(), "", field.isRequired());
        
if(field.isHidden()) {
    tmpElement.getView().setVisibility(View.INVISIBLE);
}

return tmpElement;

Thanks

dneykov avatar Jul 07 '17 14:07 dneykov

@dneykov you're getting this crash due to the view not being completely initialized yet. They are initialized once the FormActivity's onCreate method is done. After that, you should be able to access the view of any fields. Something like this should work:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getFormController().getElement(fieldId).getView().setVisibility(View.GONE);
    }

Hope this helps. I think it would be useful to get this hide/show functionality builtin to the library. I'll look into implementing it soon.

dkharrat avatar Jul 10 '17 09:07 dkharrat