Android Open Source - GasTracker Stats






From Project

Back to project page GasTracker.

License

The source code is released under:

Copyright 2014 kurtzy317

If you think the Android project GasTracker 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.mindalsoblown.gastracker;
//from w ww  .j  a  v  a  2  s .  com
import java.io.FileNotFoundException;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

public class Stats extends ActionBarActivity {
  DatabaseConnector connection;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stats);
    
    try {
      connection = new DatabaseConnector(openFileInput("ID"));
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    
    Entry entry = connection.GetAveragesForUser();
    //get text boxes in view detail screen
    TextView txtGallons = (TextView)findViewById(R.id.txtGallonsAvg);
    TextView txtCarMPG = (TextView)findViewById(R.id.txtCarAvg);
    TextView txtCalculatedMPG = (TextView)findViewById(R.id.txtCalculatedAvg);
    TextView txtAverageMPG = (TextView)findViewById(R.id.txtAverageAvg);
    TextView txtTrip = (TextView)findViewById(R.id.txtTripAvg);
    TextView lblCar = (TextView)findViewById(R.id.lblCarMpgStat);
    TextView lblAverage = (TextView)findViewById(R.id.lblAverageMpgStat);
    
    if (!connection.GetUserSetting("CarMPG"))
    {
      txtAverageMPG.setVisibility(View.GONE);
      txtCarMPG.setVisibility(View.GONE);
      lblAverage.setVisibility(View.GONE);
      lblCar.setVisibility(View.GONE);
      
    }
    txtGallons.setText(entry.getGallons().toString());
    txtCarMPG.setText(entry.getCarMPG().toString());
    txtCalculatedMPG.setText(entry.getCalculatedMPG().toString());
    txtAverageMPG.setText(entry.getAverageMPG().toString());
    txtTrip.setText(entry.getTripMiles().toString());
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.stats, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
}




Java Source Code List

com.mindalsoblown.gastracker.AddEntry.java
com.mindalsoblown.gastracker.DatabaseConnector.java
com.mindalsoblown.gastracker.Entry.java
com.mindalsoblown.gastracker.FillUpDetail.java
com.mindalsoblown.gastracker.History.java
com.mindalsoblown.gastracker.Login.java
com.mindalsoblown.gastracker.MainMenu.java
com.mindalsoblown.gastracker.Register.java
com.mindalsoblown.gastracker.Stats.java
com.mindalsoblown.gastracker.User.java