Android Open Source - ArchPad C Distance






From Project

Back to project page ArchPad.

License

The source code is released under:

GNU General Public License

If you think the Android project ArchPad 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.Andryyo.ArchPad.archeryFragment;
/*from w ww.ja v  a2s .c o  m*/
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.Andryyo.ArchPad.CShot;
import com.Andryyo.ArchPad.database.CSQLiteOpenHelper;

import java.io.*;
import java.util.Vector;

/**
 * Created with IntelliJ IDEA.
 * User: ???????
 * Date: 19.04.13
 * Time: 23:03
 * To change this template use File | Settings | File Templates.
 */
public class CDistance implements Serializable{
    private long _id;
    public int arrowsInEnd;
    public int numberOfEnds;
    public long targetId;
    public Vector<Vector<CShot>> ends;
    private long roundId;
    public long arrowId;


    public CDistance(int numberOfEnds, int arrowsInEnd, long targetId, long arrowId, long roundId)  {
        this.numberOfEnds = numberOfEnds;
        this.arrowsInEnd = arrowsInEnd;
        this.targetId = targetId;
        this.arrowId = arrowId;
        this.roundId = roundId;
        ends = new Vector<Vector<CShot>>();
        ends.add(new Vector<CShot>());
    }

    public CDistance(Cursor cursor)
    {
        try
        {
            ends = (Vector<Vector<CShot>>) CSQLiteOpenHelper.setObjectBytes(cursor.getBlob(cursor.getColumnIndex("ends")));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        _id = cursor.getLong(cursor.getColumnIndex("_id"));
        numberOfEnds = cursor.getInt(cursor.getColumnIndex("numberOfEnds"));
        arrowsInEnd = cursor.getInt(cursor.getColumnIndex("arrowsInEnd"));
        targetId = cursor.getLong(cursor.getColumnIndex("targetId"));
        arrowId = cursor.getLong(cursor.getColumnIndex("arrowId"));
        roundId = cursor.getLong(cursor.getColumnIndex("roundId"));
    }

    public boolean addShot(CShot shot)   {
        ends.lastElement().add(shot);
        if (ends.lastElement().size() == arrowsInEnd)
        {
            ends.add(new Vector<CShot>());
        }
        if (ends.size() ==  numberOfEnds+1)
        {
            ends.remove(ends.lastElement());
            return false;
        }
        else
            return true;
    }

    public void deleteLastShot()    {
        if (ends.lastElement().size()>0)
        {
            ends.lastElement().remove(ends.lastElement().lastElement());
        }
        else
        if (ends.size()>1)
            {
                ends.remove(ends.lastElement());
                ends.lastElement().remove(ends.lastElement().lastElement());
            }
    }

    public boolean isEmpty()    {
        if (ends.isEmpty())
            return true;
        else
        if ((ends.size()==1)&&(ends.lastElement().isEmpty()))
            return true;
        else
        return false;
    }

    public void writeToDatabase(SQLiteDatabase database)
    {
        try
        {
        ContentValues values = new ContentValues();
        values.put("ends", CSQLiteOpenHelper.getObjectBytes(ends));
        values.put("numberOfEnds",numberOfEnds);
        values.put("arrowsInEnd", arrowsInEnd);
        values.put("targetId",targetId);
        values.put("arrowId",arrowId);
        values.put("roundId",roundId);
        database.insert(CSQLiteOpenHelper.TABLE_DISTANCES,null,values);
        }
        catch (Exception e)
        {
        }
    }

    public long getId()  {
        return _id;
    }


}




Java Source Code List

com.Andryyo.ArchPad.CArrow.java
com.Andryyo.ArchPad.CShot.java
com.Andryyo.ArchPad.MainActivity.java
com.Andryyo.ArchPad.archeryFragment.CArcheryFragment.java
com.Andryyo.ArchPad.archeryFragment.CCurrentEndView.java
com.Andryyo.ArchPad.archeryFragment.CDistanceTemplate.java
com.Andryyo.ArchPad.archeryFragment.CDistance.java
com.Andryyo.ArchPad.archeryFragment.CRoundTemplate.java
com.Andryyo.ArchPad.archeryFragment.CRound.java
com.Andryyo.ArchPad.archeryFragment.IOnShotAddListener.java
com.Andryyo.ArchPad.archeryFragment.?EndsCounterView.java
com.Andryyo.ArchPad.database.CSQLiteOpenHelper.java
com.Andryyo.ArchPad.note.CNoteCreateActivity.java
com.Andryyo.ArchPad.note.CNotesFragment.java
com.Andryyo.ArchPad.sight.CSightSelectFragment.java
com.Andryyo.ArchPad.sight.?SightPropertiesFragment.java
com.Andryyo.ArchPad.start.CArrowSelectView.java
com.Andryyo.ArchPad.start.CColorSelectView.java
com.Andryyo.ArchPad.start.CRoundSelectView.java
com.Andryyo.ArchPad.start.CStartFragment.java
com.Andryyo.ArchPad.start.CTargetSelectView.java
com.Andryyo.ArchPad.start.IOnFragmentSwapRequiredListener.java
com.Andryyo.ArchPad.statistics.CBorderedTextView.java
com.Andryyo.ArchPad.statistics.CRecordViewFragment.java
com.Andryyo.ArchPad.statistics.CStatisticsFragment.java
com.Andryyo.ArchPad.statistics.IOnUpdateListener.java
com.Andryyo.ArchPad.target.CEditableTargetView.java
com.Andryyo.ArchPad.target.CRing.java
com.Andryyo.ArchPad.target.CTargetView.java
com.Andryyo.ArchPad.target.CTarget.java
com.Andryyo.ArchPad.target.CZoomableTargetView.java