Android Open Source - RazorRunner-AndroidProject Profile Activity






From Project

Back to project page RazorRunner-AndroidProject.

License

The source code is released under:

Apache License

If you think the Android project RazorRunner-AndroidProject 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 edu.uark.csce.razorrunner;
/*  w  w w. j  ava2 s .c  o  m*/
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;


public class ProfileActivity extends Activity {

  TextView nameText, genderText, weightText, ageText;
//  RadioButton maleRadioButton, femaleRadioButton;
//  Spinner ageSpinner, weightSpinner;
  
  SharedPreferences sharedPreferences;

  static final private int MENU_PREFERENCES = Menu.FIRST + 1;
  private static final int SHOW_PREFERENCES = 1;


  //TODO: Erase just about everything in this file and replace with textviews and shit
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    
    nameText = (TextView) findViewById(R.id.nameResult);
    ageText = (TextView) findViewById(R.id.ageResult);
    weightText = (TextView) findViewById(R.id.weightResult);
    genderText = (TextView) findViewById(R.id.genderResult);
    
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    updateUIFromPreferences();
    
  }

  private void updateUIFromPreferences() {

     /** Getting the values stored in the shared object via preference activity */
        boolean userGender = sharedPreferences.getBoolean("prefUserGender", false);
        String userName = sharedPreferences.getString("prefUserName","");
        String userWeight = sharedPreferences.getString("prefUserWeight", "");
        String userAge = sharedPreferences.getString("prefUserAge", "");
 
        /** Setting the values on textview objects to display in the ShowActivity */
        if(userGender)
          genderText.setText("Male");
        else
          genderText.setText("Female");
        
        nameText.setText(userName);
        weightText.setText(userWeight);
        ageText.setText(userAge);
      
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    // getMenuInflater().inflate(R.menu.earthquake, menu);
    super.onCreateOptionsMenu(menu);
    menu.add(0, MENU_PREFERENCES, Menu.NONE, R.string.menu_preferences);

    return true;
  }

  @SuppressWarnings("rawtypes")
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch (item.getItemId()) {

    case (MENU_PREFERENCES): {
      Class c = UserSettingsActivity.class;
      Intent i = new Intent(this, c);

      startActivityForResult(i, SHOW_PREFERENCES);
      return true;
    }
    }
    return false;
  }
  
  @SuppressWarnings("rawtypes")
  public void updateProfile(View view)
  {
    Class c = UserSettingsActivity.class;
    Intent i = new Intent(this, c);

    startActivityForResult(i, SHOW_PREFERENCES);
  }
  @Override
  public void onActivityResult(int reqCode, int resCode, Intent data) {
    if(reqCode == SHOW_PREFERENCES)
    {
      updateUIFromPreferences();
    }
  }

  public void backToHome(View view)
  {
    finish();
  }
}




Java Source Code List

edu.uark.csce.razorrunner.ActivityUtils.java
edu.uark.csce.razorrunner.BuildConfig.java
edu.uark.csce.razorrunner.DistanceNotifier.java
edu.uark.csce.razorrunner.HistoryActivity.java
edu.uark.csce.razorrunner.Manifest.java
edu.uark.csce.razorrunner.OverviewActivity.java
edu.uark.csce.razorrunner.PedometerSettings.java
edu.uark.csce.razorrunner.ProfileActivity.java
edu.uark.csce.razorrunner.RemoveDetection.java
edu.uark.csce.razorrunner.RequestDetection.java
edu.uark.csce.razorrunner.StepDetector.java
edu.uark.csce.razorrunner.StepDisplayer.java
edu.uark.csce.razorrunner.StepListener.java
edu.uark.csce.razorrunner.UserActivityRecognition.java
edu.uark.csce.razorrunner.UserSettingsActivity.java
edu.uark.csce.razorrunner.UserStepRecognition.java
edu.uark.csce.razorrunner.WorkoutActivity.java
edu.uark.csce.razorrunner.WorkoutContentProvider.java
edu.uark.csce.razorrunner.WorkoutData.java
edu.uark.csce.razorrunner.WorkoutItemAdapter.java