Android Open Source - digitalcampus Information Activity






From Project

Back to project page digitalcampus.

License

The source code is released under:

MIT License

If you think the Android project digitalcampus 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.llenguatges.digitalcampus.students;
/*from   w ww .  ja  va 2s  .c om*/
import java.util.ArrayList;
import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.llenguatges.digitalcampus.R;
import com.llenguatges.digitalcampus.adapters.StudentSubjectsAdapter;
import com.llenguatges.digitalcampus.database.StudentSubjectTable;
import com.llenguatges.digitalcampus.database.StudentTable;
import com.llenguatges.digitalcampus.database.SubjectTable;
import com.llenguatges.digitalcampus.objects.Student;
import com.llenguatges.digitalcampus.objects.Subject;

public class InformationActivity extends Activity {
  
  private Student student;
  private long id;
  private List<Long> subjectIdList;
  private List<Subject> subjectList;
  private StudentSubjectTable sst;
  private SubjectTable st;
  private ListView listView;
  private StudentSubjectsAdapter adapter;
  
  /**
   * Start interacting with the user.
   * Called when previous activity not finished.
   */
  protected void onResume(){
    super.onResume();
    setSubjects();
  }
  
  /**
   * Called when the activity is first created. 
   * This is where you all of static set up: customize ActionBar. 
   * This method also provides you with a Bundle containing the 
   * activity's previously frozen state, if there was one.
   */
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    setContentView(R.layout.activity_students_info);
    ActionBar acBar = getActionBar();
    acBar.setSubtitle("Student information");
    acBar.setDisplayHomeAsUpEnabled(true);
    id = extras.getLong("student");
    student = new Student(0, null, null, null, null, null, false, null);
    StudentTable st = new StudentTable(getApplicationContext());
    student = st.GetStudentById(id);
    this.setStudentFirstName(student.getFirstName());
    this.setStudentLastName(student.getLastName());
    this.setStudentDescription(student.getDescription());
    this.setStudentAge(student.getAge());
    if(student.getGender() == "M"){
      this.setStudentGender("Male");
    }else{
      this.setStudentGender("Female");
    }
    this.setPhoto();
  }
  
  /**
   * Set student's image image view
   */
    private void setPhoto() {
      ImageView iv = (ImageView) findViewById(R.id.studentImage);
    if(student.getPhoto() != null){
      iv.setImageBitmap(student.getPhoto());
    }    
  }
    
  /**
   * Set student's first name text view
   * @param firstName
   */
    public void setStudentFirstName(String firstName) {
    TextView studentFirstName = (TextView) findViewById(R.id.studentFirstName);
    studentFirstName.setText(firstName);
  }
    
    /**
     * Set student's last name text view
     * @param lastName
     */
    public void setStudentLastName(String lastName) {
    TextView studentLastName = (TextView) findViewById(R.id.studentLastName);
    studentLastName.setText(lastName);
  }
  
    /**
     * Set student's description text view
     * @param description
     */
  public void setStudentDescription(String description) {
    TextView studentDescription = (TextView) findViewById(R.id.studentDescription);
    studentDescription.setText(description);
  }
  
  /**
   * Set student's age text view
   * @param age
   */
  public void setStudentAge(String age) {
    TextView studentAge = (TextView) findViewById(R.id.studentAge);
    studentAge.setText(age);
  }
  
  /**
   * Set stundent's gender text view
   * @param gender
   */
  public void setStudentGender(String gender) {
    TextView studentGender = (TextView) findViewById(R.id.studentGender);
    studentGender.setText(gender);
  }
  
  /** 
   * Set student's subjects
   */
  public void setSubjects() {
    subjectList = new ArrayList<Subject>();
    subjectIdList = new ArrayList<Long>();
    st = new SubjectTable(getApplicationContext());
    sst = new StudentSubjectTable(getApplicationContext());
    subjectIdList = sst.GetSubjectIdFromTableByStudentId(id);
    for(int i = 0; i < subjectIdList.size(); i++){
      subjectList.add(st.GetSubjectById(subjectIdList.get(i)));
    }
    adapter = new StudentSubjectsAdapter(getApplicationContext(), subjectList);
    listView = (ListView) findViewById(R.id.studentsSubjectsListView);
    listView.setAdapter(adapter);
  }
  
    /**
     * This hook is called whenever an item in your options menu is selected.
     */
  public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle presses on the action bar items 
    switch (item.getItemId()) { 
      case android.R.id.home:
        finish();
        return true; 
      default: 
        return super.onOptionsItemSelected(item); 
    } 
  }

}




Java Source Code List

com.llenguatges.digitalcampus.BaseActivity.java
com.llenguatges.digitalcampus.MainActivity.java
com.llenguatges.digitalcampus.MyApplication.java
com.llenguatges.digitalcampus.adapters.CustomGridViewAdapter.java
com.llenguatges.digitalcampus.adapters.ExamAdapter.java
com.llenguatges.digitalcampus.adapters.NewSubSyllabusAdapter.java
com.llenguatges.digitalcampus.adapters.NewSubjectStudentAdapter.java
com.llenguatges.digitalcampus.adapters.SpinnerAdapter.java
com.llenguatges.digitalcampus.adapters.StudentAdapter.java
com.llenguatges.digitalcampus.adapters.StudentSubjectsAdapter.java
com.llenguatges.digitalcampus.adapters.SubjectAdapter.java
com.llenguatges.digitalcampus.adapters.SubjectStudentsAdapter.java
com.llenguatges.digitalcampus.adapters.SyllabusAdapter.java
com.llenguatges.digitalcampus.database.DAOHelper.java
com.llenguatges.digitalcampus.database.ExamTable.java
com.llenguatges.digitalcampus.database.StudentSubjectTable.java
com.llenguatges.digitalcampus.database.StudentTable.java
com.llenguatges.digitalcampus.database.SubjectMatterTable.java
com.llenguatges.digitalcampus.database.SubjectTable.java
com.llenguatges.digitalcampus.exams.ExamsActivity.java
com.llenguatges.digitalcampus.exams.NewExamActivity.java
com.llenguatges.digitalcampus.login.LoginActivity.java
com.llenguatges.digitalcampus.login.SessionManager.java
com.llenguatges.digitalcampus.objects.Exam.java
com.llenguatges.digitalcampus.objects.Item.java
com.llenguatges.digitalcampus.objects.StudentSubject.java
com.llenguatges.digitalcampus.objects.Student.java
com.llenguatges.digitalcampus.objects.SubjectMatter.java
com.llenguatges.digitalcampus.objects.Subject.java
com.llenguatges.digitalcampus.splash.SplashScreenActivity.java
com.llenguatges.digitalcampus.students.InformationActivity.java
com.llenguatges.digitalcampus.students.NewStudentActivity.java
com.llenguatges.digitalcampus.students.StudentsActivity.java
com.llenguatges.digitalcampus.subjects.InformationActivity.java
com.llenguatges.digitalcampus.subjects.NewSubjectActivity.java
com.llenguatges.digitalcampus.subjects.SubjectsActivity.java