Rules for arrangement methods by name

Hello there, I try to arrange methods in following order:

  1. onAttach(Activity)
  2. onCreate(Bundle)
  3. onCreateView(LayoutInflater, ViewGroup, Bundle)
  4. onActivityCreated(Bundle)
  5. onViewStateRestored(Bundle)
    
    
  6. onStart()
  7. etc.



But I don't know what rules should I apply to achive this. I tried following patterns onAttach, onAttach.*, .*onAttach.* and nothing helps. Thats why any help would be appreceated.

6 comments
Avatar
Yaroslav Lepenkin
Comment actions Permalink

Hi, Dmitry!

Screen Shot 2014-10-08 at 18.58.35.png

I've used settings from above and probably get the result you want. Maybe it also helps for you!

0
Comment actions Permalink

Thank you, Yaroslav, I tried this ordering, but then onCreateView is placed after onPause instead of onCreate.

0
Avatar
Yaroslav Lepenkin
Comment actions Permalink

Try to add "method" rule as a last rule. If it doesn't work, please provide source code you were arranging (if possible)

0
Comment actions Permalink

I already had this last rule you can see it here
Screenshot 2014-10-29 20.11.24.png
, and for example this code after auto arrangement:

public final class StubFragment extends BaseBigDialog
        implements AdapterView.OnItemClickListener, TitledFragment {

    public static StubFragment newInstance(String schemeId,
            GetSchemeAccountsRequest.Direction direction, String accountId) {
        final StubFragment fragment = new StubFragment();

        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return null;
    }

    protected void onAccountClicked(@NonNull Account account) {

    }

    protected final void initView(@NonNull final View root) {

    }

    protected void loadAccounts() {

    }

    protected void showItems(@NonNull final List<? extends Item> items) {

    }

    protected final void clearAdapter() {

    }

    protected final void showError(@NonNull final String errorMessage) {

    }

    private static List<Account> sortAccounts(final List<Account> accounts) {
        return null;
    }

    private void showSavedAccounts() {

    }

    private void updateFooter() {

    }

    public void onOperationFinished(GetSchemeAccounts.Result result) {

    }

    @SuppressWarnings("UnusedDeclaration")
    public final void onOperationFinished(final GetAccounts.Result accountsResult) {

    }

    @NonNull
    @Override
    public String getName() {
        return null;
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

    }
}

0
Avatar
Yaroslav Lepenkin
Comment actions Permalink

Yes, it's clear that first method (newInstance) should be located somewhere at the end of file.

Dmitry, what idea build are you using?
I was not able to reproduce it on the latest build. Please check them on http://confluence.jetbrains.com/display/IDEADEV/IDEA+14+EAP

If you are will be able to reproduce it on the latest build, please fill request in our issue tracker https://youtrack.jetbrains.com/issues/IDEA

0
Comment actions Permalink

Thank you, Yaroslav. I found out that I missed rule for public method.

0

Please sign in to leave a comment.