Android Open Source - GPA View Tasks Activity






From Project

Back to project page GPA.

License

The source code is released under:

Apache License

If you think the Android project GPA 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.bishal.android.taskmanager;
/*  w w  w  . j a  v a 2s.  co m*/
import com.bishal.android.taskmanager.adapters.TaskListAdapter;
import com.bishal.android.taskmanager.tasks.Task;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ToggleButton;

  public class ViewTasksActivity extends ListActivity implements LocationListener {

  private static final long LOCATION_FILTER_DISTANCE = 2;
  //private Button addButton;
  private TaskListAdapter adapter;
  private TaskManagerApplication app;
  //private Button removeButton;
  private TextView locationText;
  //private TextView timeText;
  private ToggleButton localTasksToggle;
  private LocationManager locationManager;
  private Location latestLocation;
  
  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.schedules);
        
        setUpViews();
        app = (TaskManagerApplication)getApplication();
        //if(getIntent().getExtras().getString("email"));
        
        adapter = new TaskListAdapter(this, app.getCurrentTasks());
        setListAdapter(adapter);
        setUpLocation();
    }
  
  @Override
  protected void onResume() {
    super.onResume();
    adapter.forceReload();
    
  }

  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    adapter.toggleTaskCompleteAtPosition(position);
    Task t = adapter.getItem(position);
    app.saveTask(t);
  }
  
  public void onLocationChanged(Location location) {
    latestLocation = location;
    String locationString = String.format(
        "@ %f, %f +/- %fm",
        location.getLatitude(),
        location.getLongitude(),
        location.getAccuracy());
    locationText.setText(locationString);
  }

  public void onProviderDisabled(String provider) { }

  public void onProviderEnabled(String provider) { }

  public void onStatusChanged(String provider, int status, Bundle extras) { }

  protected void removeCompletedTasks() {
    Long[] ids = adapter.removeCompletedTasks();
    app.deleteTasks(ids);
  }
  
  protected void showLocalTasks(boolean checked) {
    if (checked) {
      adapter.filterTasksByLocation(latestLocation, LOCATION_FILTER_DISTANCE);
    } else {
      adapter.removeLocationFilter();
    }
  }

  private void setUpViews() {
    ImageButton addButton = (ImageButton)findViewById(R.id.add_button);
    ImageButton removeButton = (ImageButton)findViewById(R.id.remove_button);
    localTasksToggle = (ToggleButton)findViewById(R.id.show_local_tasks_toggle);
    locationText = (TextView)findViewById(R.id.location_text);
    
//    locationText.setBackgroundResource(R.color.white);
//    locationText.setTextColor(getResources().getColor(R.color.black));
    // timeText = (TextView)findViewById(R.id.time_text);
    
    addButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
        Intent intent = new Intent(ViewTasksActivity.this, AddTaskActivity.class);
        startActivity(intent);
      }
    });
    removeButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
        removeCompletedTasks();
      }
    });
    localTasksToggle.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
        showLocalTasks(localTasksToggle.isChecked());
      }
    });

  }
  
  private void setUpLocation() {
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER,
                60,
                5,
                this);
  }

}




Java Source Code List

com.bishal.android.taskmanager.ACCOUNT_INFO.java
com.bishal.android.taskmanager.ADD_TASK.java
com.bishal.android.taskmanager.AddLocationMapActivity.java
com.bishal.android.taskmanager.AddTaskActivity.java
com.bishal.android.taskmanager.AlarmActivity.java
com.bishal.android.taskmanager.AlertDialogManager.java
com.bishal.android.taskmanager.AndroidAlarmService.java
com.bishal.android.taskmanager.CURRENT_LOCATION.java
com.bishal.android.taskmanager.DB_ADAPTER.java
com.bishal.android.taskmanager.DbHelper.java
com.bishal.android.taskmanager.GPA_HOME.java
com.bishal.android.taskmanager.GPS_FIELD.java
com.bishal.android.taskmanager.GPS_INFO.java
com.bishal.android.taskmanager.LOGIN.java
com.bishal.android.taskmanager.MyAlarmService.java
com.bishal.android.taskmanager.SCHEDULES.java
com.bishal.android.taskmanager.SEARCHING_PLACES.java
com.bishal.android.taskmanager.SIGNUP.java
com.bishal.android.taskmanager.Search_Education.java
com.bishal.android.taskmanager.Search_Hospital.java
com.bishal.android.taskmanager.SpecifyTime.java
com.bishal.android.taskmanager.TaskManagerActivity.java
com.bishal.android.taskmanager.TaskManagerApplication.java
com.bishal.android.taskmanager.ViewTasksActivity.java
com.bishal.android.taskmanager.YourAlarmService.java
com.bishal.android.taskmanager.adapters.TaskListAdapter.java
com.bishal.android.taskmanager.tasks.Task.java
com.bishal.android.taskmanager.tasks.TasksSQLiteOpenHelper.java
com.bishal.android.taskmanager.views.AddressOverlay.java
com.bishal.android.taskmanager.views.TaskListItem.java