Android Open Source - iEtueri Subject List Adapter






From Project

Back to project page iEtueri.

License

The source code is released under:

GNU General Public License

If you think the Android project iEtueri 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 subject;
/* ww  w .j a  va  2  s.c  o m*/
import java.util.ArrayList;
import java.util.List;

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

import com.javils.ietueri.R;

/**
 * Created by Javier Luque Sanabria on 19/02/14.
 */
public class SubjectListAdapter extends ArrayAdapter<Subject> {

  private List<Subject> objects = new ArrayList<Subject>();
  private int resource;
  private Context context;
  private TextView text;

  public SubjectListAdapter(Context context, int resource, List<Subject> objects) {
    super(context, resource, objects);
    this.context = context;
    this.resource = resource;
    this.objects = objects;
  }

  @Override
  public int getCount() {
    return objects.size();
  }

  @Override
  public Subject getItem(int i) {
    return objects.get(i);
  }

  @Override
  public long getItemId(int i) {
    return i;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;

    // If don't have view, take it!
    if (view == null) {
      LayoutInflater layout = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = layout.inflate(resource, null);
    }

    Subject subject = getItem(position);

    // Fill the structure of the item
    text = (TextView) view.findViewById(R.id.subject_list_item_subject_name);
    text.setText(subject.getName());
    text = (TextView) view.findViewById(R.id.subject_list_item_subject_number_tasks);
    text.setText("Tareas: " + subject.getNumberOfTasks());
    text = (TextView) view.findViewById(R.id.subject_list_item_subject_average);
    float average = (subject.getNote() / subject.getNumberOfExams());
    if (Float.isNaN(average))
      average = 0;
    text.setText("Media: " + average);
    text = (TextView) view.findViewById(R.id.subject_list_item_subject_number_exams);
    text.setText("Examenes: " + subject.getNumberOfExams());
    text = (TextView) view.findViewById(R.id.detail_course_subject_subjectId);
    text.setText("" + subject.getId());

    return view;
  }
}




Java Source Code List

courses.CourseDetailFragment.java
courses.Course.java
courses.CoursesAdapter.java
courses.CoursesFragment.java
courses.NewCourseFragment.java
exams.Exam.java
exams.ExamsAdapter.java
exams.ExamsFragment.java
exams.NewExamFragment.java
homework.HomeworkAdapter.java
homework.HomeworkFragment.java
homework.Homework.java
homework.NewHomeworkFragment.java
navigationdrawer.DrawerListAdapter.java
navigationdrawer.DrawerList.java
navigationdrawer.MainActivity.java
navigationdrawer.NavigationDrawerCallbacks.java
navigationdrawer.NavigationDrawerController.java
navigationdrawer.NavigationDrawerFragment.java
navigationdrawer.OpenBrowser.java
schedule.CalendarManager.java
schedule.Event.java
schedule.EventsManager.java
schedule.FindEvents.java
schedule.RefreshScheduleEventsData.java
schedule.ScheduleFragment.java
schedule.ScheduleTodayAdapter.java
subject.DetailSubjectFragment.java
subject.NewSubjectFragment.java
subject.SubjectFragment.java
subject.SubjectListAdapter.java
subject.Subject.java
today.NewEventRepetitionDialogFragment.java
today.NewEventTodayFragment.java
today.TodayFragment.java
utility.DatabaseContract.java
utility.DatabaseHelper.java
utility.DatePickerDialogFragment.java
utility.OnBackPressed.java
utility.OnClickButtonXml.java
utility.PriorityDialogFragment.java
utility.TimePickerDialogFragment.java