Back to project page AndroidGraph.
The source code is released under:
MIT License
If you think the Android project AndroidGraph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nimble.android_graph.Activities; /* ww w .ja va 2 s. c o m*/ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.View; import com.nimble.androidgraph.R; /** * Created by Michael Leith on 23/07/2014. */ public class GraphActivity extends FragmentActivity { static final boolean SLIDE_RIGHT = true; static final boolean SLIDE_LEFT = false; static final boolean PREVIOUS = false, NEXT = true; FragmentList fragmentList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); getActionBar().hide(); fragmentList = new FragmentList(this); FragmentManager fragmentTransaction = getSupportFragmentManager(); fragmentTransaction.beginTransaction() .replace(R.id.fragment_main, fragmentList.next()) .commit(); fragmentTransaction.executePendingTransactions(); } public void nextLeft(View v) { switchFragment(PREVIOUS); } public void nextRight(View v) { switchFragment(NEXT); } private void switchFragment(boolean direction) { switchFragment( direction == NEXT ? SLIDE_RIGHT : SLIDE_LEFT, fragmentList.getCurrent(), fragmentList.previous()); } private void switchFragment(boolean anim, Fragment previous, GroupsFragment fragment ) { int in = 0, out = 0; if(anim == SLIDE_RIGHT) { in = R.anim.anim_slide_in_right; out = R.anim.anim_slide_out_right; } else { in = R.anim.anim_slide_in_left; out = R.anim.anim_slide_out_left; } previous.onPause(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(in, out) .hide(previous); if(fragment.shown) { fragment.onResume(); fragmentTransaction.show(fragment) .commit(); } else { fragmentTransaction.add(R.id.fragment_main, fragment) .commit(); } fragmentList.run(); } @Override public void onStart() { super.onStart(); fragmentList.run(); } @Override public void onStop() { super.onStop(); fragmentList.onStop(); } }