Android Open Source - ArchPad ? Sight Properties Fragment






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.sight;
// w ww . j a v a 2 s  .co m
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.*;
import com.Andryyo.ArchPad.R;
import com.Andryyo.ArchPad.database.CSQLiteOpenHelper;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * Created with IntelliJ IDEA.
 * User: ???????
 * Date: 06.05.13
 * Time: 17:08
 * To change this template use File | Settings | File Templates.
 */
public class ?SightPropertiesFragment extends FragmentActivity implements Spinner.OnItemSelectedListener {

    private long currentSightId;
    private EditText editTextX;
    private EditText editTextY;

    @Override
    public void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sight_properties);
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.setTitle("?????????? ??????????????? ????????");
        getWindow().setAttributes(params);
        CSightSelectFragment fragment = (CSightSelectFragment)getSupportFragmentManager().findFragmentById(R.id.sight_select_fragment);
        fragment.setOnItemSelectedListener(this);
        fragment.setSelection(PreferenceManager.getDefaultSharedPreferences(this).getLong("sightId",0));
        editTextX = (EditText) findViewById(R.id.sight_x);
        editTextY = (EditText) findViewById(R.id.sight_y);
    }

    public void onClick(View view)  {
        switch (view.getId())
        {
            case R.id.dec_y:
            {
                if (editTextY.getText().toString().equals(""))
                    editTextY.setText("0.0");
                BigDecimal b = new BigDecimal(editTextY.getText().toString());
                b = b.subtract(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP);
                editTextY.setText(b.toString());
                break;
            }
            case R.id.dec_x:
            {
                if (editTextX.getText().toString().equals(""))
                    editTextX.setText("0.0");
                BigDecimal b = new BigDecimal(editTextX.getText().toString());
                b = b.subtract(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP);
                editTextX.setText(b.toString());
                break;
            }
            case R.id.inc_y:
            {
                if (editTextY.getText().toString().equals(""))
                    editTextY.setText("0.0");
                BigDecimal b = new BigDecimal(editTextY.getText().toString());
                b = b.add(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP);
                editTextY.setText(b.toString());
                break;
            }
            case R.id.inc_x:
            {
                if (editTextX.getText().toString().equals(""))
                    editTextX.setText("0.0");
                BigDecimal b = new BigDecimal(editTextX.getText().toString());
                b = b.add(new BigDecimal(0.1)).setScale(1, RoundingMode.HALF_UP);
                editTextX.setText(b.toString());
                break;
            }
        }
    }

    @Override
    public void onItemSelected(AdapterView<?> adapterView, View view, int i, long id) {
        if (currentSightId!=0)
            CSQLiteOpenHelper.getHelper(this).updateSight(currentSightId,
                    editTextX.getText().toString(),
                    editTextY.getText().toString()
                            );
        PreferenceManager.getDefaultSharedPreferences(this).edit().putLong("sightId",id).commit();
        currentSightId = id;
        String[] strings = CSQLiteOpenHelper.getHelper(this).getSight(id);
        editTextX.setText(strings[0]);
        editTextY.setText(strings[1]);

    }

    @Override
    public void onNothingSelected(AdapterView<?> adapterView) {
        currentSightId = 0;
    }

    @Override
    public void onPause()   {
        super.onPause();
        CSQLiteOpenHelper.getHelper(this).updateSight(currentSightId,
                editTextX.getText().toString(),
                editTextY.getText().toString()
        );
    }

}




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