Android Open Source - StrTrainer_android Utilities_ Estimate1 R M






From Project

Back to project page StrTrainer_android.

License

The source code is released under:

GNU General Public License

If you think the Android project StrTrainer_android 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

/**
 *//from ww w .ja  v  a 2s.  co  m
 * StrTrainer /com/davefarinelli/strtrainer/OneRepMaxCalc.java
 *
 * Copyright (c) 2011 Dave Farinelli
 *
 * LICENSE:
 *
 * This file is part of StrTrainer, a companion Android app for the Starting Strength weight
 * training program (http://davefarinelli.com/developer/android).
 *
 * StrTrainer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
 * later version.
 *
 * StrTrainer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with StrTrainer.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * @author Dave Farinelli <davefarinelli[at]gmail[dot]com>
 * @license http://www.gnu.org/licenses/gpl.html
 * @copyright 2011 Dave Farinelli
 */

package com.davefarinelli.strtrainer;

import com.davefarinelli.strtrainer.R;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class Utilities_Estimate1RM extends Activity {
  /** Declaration of Shared Preference name */
  public static final String PREFS_NAME = "MyPrefsFile";
  
  // create widget handles
    TextView tvSquat5RM;
    TextView tvSquat1RM;
    TextView tvBench5RM;
    TextView tvBench1RM;
    TextView tvPress5RM;
    TextView tvPress1RM;
    TextView tvDeadlift5RM;
    TextView tvDeadlift1RM;
    TextView tvClean5RM;
    TextView tvClean1RM;
  
  /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.utilities_estimate_1rm);
        
        // Restore preferences
        SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
        float squat5RM = settings.getFloat("squatWorkSetValue", 0);
        float bench5RM = settings.getFloat("benchWorkSetValue", 0);
        float press5RM = settings.getFloat("pressWorkSetValue", 0);
        float deadlift5RM = settings.getFloat("deadliftWorkSetValue", 0);
        float clean5RM = settings.getFloat("cleanWorkSetValue", 0);
        
        // Initialize handles
        tvSquat5RM = (TextView)findViewById(R.id.tv_squat5rm);
        tvSquat1RM = (TextView)findViewById(R.id.tv_squat1rm);
        tvBench5RM = (TextView)findViewById(R.id.tv_bench5rm);
        tvBench1RM = (TextView)findViewById(R.id.tv_bench1rm);
        tvPress5RM = (TextView)findViewById(R.id.tv_press5rm);
        tvPress1RM = (TextView)findViewById(R.id.tv_press1rm);
        tvDeadlift5RM = (TextView)findViewById(R.id.tv_deadlift5rm);
        tvDeadlift1RM = (TextView)findViewById(R.id.tv_deadlift1rm);
        tvClean5RM = (TextView)findViewById(R.id.tv_clean_5rm);
        tvClean1RM = (TextView)findViewById(R.id.tv_clean_1rm);
        
        // calculate one rep max values from 5 rep max data
        int squat1RM = calculateOneRepMax(squat5RM);
        int bench1RM = calculateOneRepMax(bench5RM);
        int press1RM = calculateOneRepMax(press5RM);
        int deadlift1RM = calculateOneRepMax(deadlift5RM);
        int clean1RM = calculateOneRepMax(clean5RM);
        
        // Create strings to go into TextViews
        String squat5RM_String = Float.toString(squat5RM);
        String bench5RM_String = Float.toString(bench5RM);
        String press5RM_String = Float.toString(press5RM);
        String deadlift5RM_String = Float.toString(deadlift5RM);
        String clean5RM_String = Float.toString(clean5RM);
        
        String squat1RM_String = Integer.toString(squat1RM);
        String bench1RM_String = Integer.toString(bench1RM);
        String press1RM_String = Integer.toString(press1RM);
        String deadlift1RM_String = Integer.toString(deadlift1RM);
        String clean1RM_String = Integer.toString(clean1RM);
        
        // Set TextViews
        tvSquat5RM.setText(squat5RM_String);
        tvBench5RM.setText(bench5RM_String);
        tvPress5RM.setText(press5RM_String);
        tvDeadlift5RM.setText(deadlift5RM_String);
        tvClean5RM.setText(clean5RM_String);
        
        tvSquat1RM.setText(squat1RM_String);
        tvBench1RM.setText(bench1RM_String);
        tvPress1RM.setText(press1RM_String);
        tvDeadlift1RM.setText(deadlift1RM_String);
        tvClean1RM.setText(clean1RM_String);
    }

    // calculates one rep max using Brzycki's formula
    // 1RM = (Weight) * 36 / (37 - Reps)
  int calculateOneRepMax(float five_rep_max) {
    return (int) (five_rep_max * 5 * 0.0333 + five_rep_max);
  }
}




Java Source Code List

com.davefarinelli.strtrainer.About.java
com.davefarinelli.strtrainer.AppSettings_InitializeWorkSetValues.java
com.davefarinelli.strtrainer.AppSettings_ModifyIncrementValues.java
com.davefarinelli.strtrainer.AppSettings.java
com.davefarinelli.strtrainer.ComputeTab.java
com.davefarinelli.strtrainer.Compute.java
com.davefarinelli.strtrainer.Records.java
com.davefarinelli.strtrainer.StrTrainer.java
com.davefarinelli.strtrainer.Utilities_Estimate1RM.java
com.davefarinelli.strtrainer.Utilities.java