Android Open Source - AndroidGraph Graph Activity






From Project

Back to project page AndroidGraph.

License

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.

Java Source Code

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();
    }
}




Java Source Code List

Nimble.com.androidgraph.ApplicationTest.java
com.nimble.android_graph.Activities.FragmentList.java
com.nimble.android_graph.Activities.GraphActivity.java
com.nimble.android_graph.Activities.GraphFragment.java
com.nimble.android_graph.Activities.GroupsFragment.java
com.nimble.android_graph.Graph.CurveGraph.java
com.nimble.android_graph.Graph.LineGraph.java
com.nimble.android_graph.Graph.Line.java
com.nimble.android_graph.Graph.ScatterGraph.java
com.nimble.android_graph.Graph.SineWave.java
com.nimble.android_graph.Graph_Base.Coord2d.java
com.nimble.android_graph.Graph_Base.GraphDataSettings.java
com.nimble.android_graph.Graph_Base.GraphDrawBackground.java
com.nimble.android_graph.Graph_Base.GraphRelateToScreen.java
com.nimble.android_graph.Graph_Base.GraphThreading.java
com.nimble.android_graph.Graph_Base.GraphTouchEvent.java
com.nimble.android_graph.Graph_Base.GraphViewDimensions.java
com.nimble.android_graph.Graph_Base.GraphView.java
com.nimble.android_graph.Graph_Base.Point.java
com.nimble.android_graph.Graph_Base.Range2d.java
com.nimble.android_graph.Graph.sine_scatter.java
com.nimble.android_graph.generics.Methods.java
com.nimble.android_graph.generics.ViewManipulators.java
com.nimble.android_graph.generics.testingSuite.java