Guest User

Untitled

a guest
Jan 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. package com.creativecoders.gymbuddy;
  2.  
  3. import com.creativecoders.gymbuddy.R;
  4.  
  5. import android.app.Activity;
  6. import android.content.Context;
  7. import android.content.SharedPreferences;
  8. import android.content.SharedPreferences.Editor;
  9. import android.os.Bundle;
  10. import android.view.View;
  11. import android.view.View.OnClickListener;
  12. import android.widget.EditText;
  13. import android.widget.TextView;
  14.  
  15. public class Benchmark extends Activity {
  16.  
  17. public static final String GB_PREFERENCES = "Prefs";
  18.  
  19. public static final String GB_PREFERENCES_BENCH = "Bench";
  20. public static final String GB_PREFERENCES_FLIES = "Flies";
  21.  
  22. SharedPreferences gBValues;
  23.  
  24. @Override
  25. public void onCreate(Bundle savedInstanceState) {
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.activity_benchmark);
  28.  
  29. gBValues = getSharedPreferences(GB_PREFERENCES, Context.MODE_PRIVATE);
  30.  
  31. }
  32.  
  33. public void onStart() {
  34. super.onStart();
  35.  
  36. findViewById(R.id.button5).setOnClickListener(new handleButton5());
  37.  
  38. }
  39.  
  40. class handleButton5 implements OnClickListener {
  41. public void onClick(View v) {
  42.  
  43. EditText editText1 = (EditText)findViewById(R.id.editText1);
  44. String sWeight = editText1.getText().toString();
  45. final double dWeight = Double.parseDouble(sWeight);
  46.  
  47. EditText editText2 = (EditText)findViewById(R.id.editText2);
  48. String sPush = editText2.getText().toString();
  49. final double dPush = Double.parseDouble(sPush);
  50.  
  51. EditText editText3 = (EditText)findViewById(R.id.editText3);
  52. String sSit = editText3.getText().toString();
  53. final double dSit = Double.parseDouble(sSit);
  54.  
  55. EditText editText4 = (EditText)findViewById(R.id.editText4);
  56. String sPull = editText4.getText().toString();
  57. final double dPull = Double.parseDouble(sPull);
  58.  
  59. double dBench = (((Math.floor(dWeight*.0664))*10)-10)+dPush;
  60. double dFlies = (Math.floor(((Math.floor(dBench*.6)/10)*10)));
  61.  
  62. int iBench = (int)dBench;
  63. int iFlies = (int)dFlies;
  64.  
  65. Editor editor1 = gBValues.edit();
  66. editor1.putInt(GB_PREFERENCES_BENCH, iBench);
  67. editor1.commit();
  68.  
  69. Editor editor2 = gBValues.edit();
  70. editor2.putInt(GB_PREFERENCES_FLIES, iFlies);
  71. editor2.commit();
  72.  
  73. }
  74. }
  75.  
  76. }
  77.  
  78. package com.creativecoders.gymbuddy;
  79.  
  80. import android.app.Activity;
  81. import android.content.Intent;
  82. import android.content.SharedPreferences;
  83. import android.os.Bundle;
  84. import android.view.View;
  85. import android.view.View.OnClickListener;
  86. import android.widget.TextView;
  87.  
  88. public class Upper100Start extends Activity {
  89.  
  90. public static final String GB_PREFERENCES = "Prefs";
  91. public static final String GB_PREFERENCES_CURLS = "Curls";
  92. SharedPreferences gBValues;
  93.  
  94. @Override
  95. public void onCreate(Bundle savedInstanceState) {
  96. super.onCreate(savedInstanceState);
  97. setContentView(R.layout.upper100start);
  98.  
  99. if (gBValues.contains(GB_PREFERENCES_CURLS)){
  100. TextView TextView2 = (TextView)findViewById(R.id.textView2);
  101. TextView2.setText(gBValues.getString(GB_PREFERENCES_CURLS, ""));
  102. }
  103.  
  104. }
  105. public void onStart() {
  106. super.onStart();
  107.  
  108. findViewById(R.id.button2).setOnClickListener(new handleButton2());
  109. findViewById(R.id.button3).setOnClickListener(new handleButton3());
  110. }
  111. class handleButton2 implements OnClickListener {
  112. public void onClick(View v) {
  113. Intent intent = new Intent(Upper100Start.this, Upper101.class);
  114. startActivity(intent);
  115. }
  116. }
  117. class handleButton3 implements OnClickListener {
  118. public void onClick(View v) {
  119. Intent intent = new Intent(Upper100Start.this, Main.class);
  120. startActivity(intent);
  121. }
  122. }
  123.  
  124. }
  125.  
  126. SharedPreferences settings = getSharedPreferences("mysettings",
  127. Context.MODE_PRIVATE);
  128.  
  129. SharedPreferences.Editor editor = settings.edit();
  130. editor.putString("mystring", "wahay");
  131. editor.commit();
  132.  
  133. SharedPreferences settings = getSharedPreferences("mysettings",
  134. Context.MODE_PRIVATE);
  135. String myString = settings.getString("mystring", "defaultvalue");
Add Comment
Please, Sign In to add comment