Helps you easily develop an Android application which only navigated by Fragments.
Helps you easily develop an Android application which only navigated by Fragments.
FragmentMaster is a library allows you easily develop an Android application which only navigated by Fragments.
MasterFragment
In FragmentMaster, every "page" is subclass of MasterFragment (Or other IMasterFragment, like MasterListFragment) not Activity.
// start YourMasterFragment
Request request = new Request(YourMasterFragment.class);
startFragment(request);The Request class is similar to the Android's Intent which is an abstract description of your operation. The difference is that Request is used to start a MasterFragment.
// pass data.
Request request = new Request(YourMasterFragment.class);
request.putExtra(YourMasterFragment.EXTRA_KEY, "Extra data");
startFragment(request);Request request = getRequest();
String extraData = request.getStringExtra(YourMasterFragment.EXTRA_KEY);Install FragmentMaster
Subclass MasterActivity, it is the host of all MasterFragments. And in its onCreate() add the codes below after setContentView() method:
setContentView(R.layout.master_activity);
FragmentMaster fragmentMaster = getFragmentMaster();
fragmentMaster.install(R.id.container, new Request(Home.class), true);The first parameter of install() is the id of your MasterFragment's container. All started MasterFragment will be added to this container.
The second parameter is a Request object which describes your home MasterFragment. The home MasterFragment will be started once the host MasterActivity is started.
If the third parameter is true, the host MasterActivity will be finished when the home MasterFragment is finished.
PageAnimator
FragmentMaster provides an API for you to add custom animation for each MasterFragment. The animation will be performed when starting, finishing and dragging by user.
// Transform the background page.
protected abstract void transformBackgroundPage(View page, float position,
boolean enter);// Transform the foreground page.
protected abstract void transformForegroundPage(View page, float position,
boolean enter);@Override
public PageAnimator onCreatePageAnimator() {
// return your own PageAnimator.
return YOUR_CUSTOM_ANIMATOR;
}There are some custom PageAnimators in the Sample project.
Copyright 2014 Feng Dai
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.No open issues yet, or sync has not completed.