Android Open Source - digitalcampus Exam Adapter






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.adapters;
//from   w w w . ja  v a2  s  .com
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.llenguatges.digitalcampus.R;
import com.llenguatges.digitalcampus.database.StudentSubjectTable;
import com.llenguatges.digitalcampus.database.SubjectTable;
import com.llenguatges.digitalcampus.objects.Exam;
import com.llenguatges.digitalcampus.objects.Subject;

public class ExamAdapter extends ArrayAdapter<Exam> {

  private List<Exam> data;
  
  /**
   * Constructor
   * @param context
   * @param data
   */
  public ExamAdapter(Context _context, List<Exam> _examsArray) {
    super(_context, android.R.layout.simple_list_item_1);
    data = _examsArray;
  }
  
  /**
   * Get the data item associated with the specified position in the data set.
   * @param index
   * @return data
   */
  public Exam getItem(int index) {
    return this.data.get(index);
  }
  
  /**
   * Get how many items are in the data set represented by this Adapter.
   */
  public int getCount() {
    return this.data.size();
  }
  
  /**
   * Get a View that displays the data at the specified position in the data set.
   * @param position
   * @param converView
   * @param parent
   */
  public View getView(int position, View convertView, ViewGroup parent) {    
    View row = convertView;
    if (row == null) {
      LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      row = inflater.inflate(R.layout.exams_layout, parent, false);
    }
    Exam exam = new Exam(0, 0, null, null, null);
    exam = getItem(position);
    TextView date = (TextView) row.findViewById(R.id.examListDate);
    String[] sDate = exam.getDate().split("/");
    int day = Integer.parseInt(sDate[0].toString());
    int month = Integer.parseInt(sDate[1].toString()) + 1;
    int year = Integer.parseInt(sDate[2].toString());
    date.setText(day + "/" + month + "/" + year);
    date.setTextColor(Color.BLACK);
    TextView time = (TextView) row.findViewById(R.id.examListTime);
    time.setText(exam.getTime());
    time.setTextColor(Color.BLACK);
    TextView description = (TextView) row.findViewById(R.id.examListSubject);
    SubjectTable st = new SubjectTable(getContext());
    Subject subject = new Subject();
    subject = st.GetSubjectById(exam.getSubject());
    description.setText(subject.name);
    description.setTextColor(Color.BLACK);
    TextView classroom = (TextView) row.findViewById(R.id.examListClassroom);
    classroom.setText(exam.getClassroom());
    classroom.setTextColor(Color.BLACK);
    TextView student = (TextView) row.findViewById(R.id.examListStudents);
    StudentSubjectTable stsbTable = new StudentSubjectTable(getContext());
    int students = stsbTable.GetStudentIdFromTableBySubjectId(subject.id).size();
    student.setText(""+students);
    student.setTextColor(Color.BLACK);
    return row;
  }
  
}




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