Android Open Source - AndroidGraph Graph Threading






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.Graph_Base;
//  w ww.  j  a v a 2s  . c  om
import android.content.Context;
import android.util.AttributeSet;

import java.util.concurrent.Semaphore;

/**
 * Created by Mike on 25/07/2014.
 */
public abstract class GraphThreading extends GraphViewDimensions implements Runnable {

    Thread drawThread = new Thread(this);
    boolean drawing = false;

    protected Semaphore working;
    protected  Runnable drawingPrep;

    Semaphore waiting;

    GraphThreading(Context context)
    {
        super(context);
    }

    public GraphThreading(Context context, AttributeSet attr)
    {
        super(context, attr);
    }

    public void start() {
        if(drawing) {
            waiting.release();
        }
        else if (!drawing) {
            drawing = true;
            waiting = new Semaphore(1, false);
            working = new Semaphore(1, true);
            drawThread.start();
        }
    }

    public void stop() {
        if (drawing) {
            try {
                waiting.acquire();
            }
            catch(Exception e) {}
        }
    }

    public void onStop()
    {
        try {
            drawing = false;
            waiting.release();
        }
        catch(Exception e) {

        }
    }

    @Override
    public void run() {

        /**
        while(graphHeight.y <= 0 || graphWidth.y <= 0) {}

        while (drawing) {
            try {
                waiting.acquire();

                postInvalidate();

                waiting.release();

                Thread.sleep(16);

            } catch (Exception exc) {
                Log.e("thread", exc.toString());
            }
        }
         */
    }
}




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