Android Open Source - AnyadsTodos Archive Task Adapter






From Project

Back to project page AnyadsTodos.

License

The source code is released under:

GNU General Public License

If you think the Android project AnyadsTodos 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.dlacours.anyadstodos;
/* ww  w .  ja v  a  2 s  .  co m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class ArchiveTaskAdapter extends ArrayAdapter<Task> {
  /*This class is the intermediate between my archive list 
   * (initialized in ArchiveTasksActivity) and the ListView you see on the screen
   * It monitors the checkboxes in the Archive ListView*/
  
  
  private LayoutInflater inflater;
  
  public ArchiveTaskAdapter(Context context, TaskList archiveList) {
    super(context, R.layout.single_task, archiveList.getArchived());
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  public Task getItem(int position) {
    return TaskListController.getTaskList().getTasks().get(position);
  }
  
  public Task getUnarchItem(int position){
    return TaskListController.getUnarchList().getUnarchived().get(position);
  }
  
  public Task getArchItem(int position){
    return TaskListController.getArchList().getArchived().get(position);
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
    
    final int finalpos = position;
    
    if (convertView == null){
      convertView = inflater.inflate(R.layout.single_task, null); 
    }
    CheckBox checkbox = (CheckBox) convertView.findViewById(R.id.taskcheckbox);
    
    checkbox.setText(getItem(position).getTask());
    checkbox.setChecked(getItem(position).getChecked());
    checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
      
      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked){
          getItem(finalpos).setChecked(true);
          if(!getItem(finalpos).getRemoved()){
            SummariesActivity.CheckArchSum(1);
            SummariesActivity.UncheckArchSum(-1);
          }
        } else {
          getItem(finalpos).setChecked(false);
          if(!getItem(finalpos).getRemoved()){
            SummariesActivity.CheckArchSum(-1);
            SummariesActivity.UncheckArchSum(1);
          }
        }
        
      }
    });
    
    return convertView;
  }
}




Java Source Code List

com.dlacours.anyadstodos.ArchiveTaskAdapter.java
com.dlacours.anyadstodos.ArchiveTasksActivity.java
com.dlacours.anyadstodos.EditTaskAdapter.java
com.dlacours.anyadstodos.EditTasksActivity.java
com.dlacours.anyadstodos.MailItemsActivity.java
com.dlacours.anyadstodos.MailItemsAdapter.java
com.dlacours.anyadstodos.MainActivity.java
com.dlacours.anyadstodos.SummariesActivity.java
com.dlacours.anyadstodos.TaskListAdapter.java
com.dlacours.anyadstodos.TaskListController.java
com.dlacours.anyadstodos.TaskList.java
com.dlacours.anyadstodos.Task.java