Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 1.61 KB

adal-fragments.md

File metadata and controls

80 lines (64 loc) · 1.61 KB

adal-fragments

BaseFragment - To simplify an using of fragments.
AbstractSplashFragment - An fragment with the splash screen logic implemented.
AbstractRequestFragment - An fragment prepared to cancel retrofit requests.

Download

Gradle:

dependencies {
  implementation 'com.massivedisaster.adal:adal-fragments:0.1.20'
}

Usage

BaseFragment:

public class FragmentA extends BaseFragment {
    @Override
    protected int layoutToInflate() {
        return R.layout.fragment_a;
    }

    @Override
    protected void doOnCreated() {
        getActivity().setTitle(R.string.sample_bangbus);
    }
}

AbstractSplashFragment:

public class FragmentSplash extends AbstractSplashFragment {

    @Override
    protected int layoutToInflate() {
        return R.layout.fragment_splash_screen;
    }

    @Override
    protected void onSplashStarted() {
        onSplashFinish(openHome());
    }

    private OnFinishSplashScreen openHome() {
        return new OnFinishSplashScreen() {
            @Override
            public void onFinish() {
                ActivityFragmentManager.open(getActivity(), ActivityToolbar.class, FragmentHome.class);
                getActivity().finish();
            }
        };
    }
}

AbstractRequestFragment:

public class FragmentRequest extends AbstractRequestFragment {

    @Override
    protected int layoutToInflate() {
        return R.layout.fragment_request;
    }

    @Override
    protected void doOnCreated() {
        addRequest(...);
    }
}

Contributing

CONTRIBUTING

License

MIT LICENSE