Android Open Source - Tree-Task Edit Task






From Project

Back to project page Tree-Task.

License

The source code is released under:

Apache License

If you think the Android project Tree-Task 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.ghsoft.treetaskapp;
//w w  w  .  j  a  v a  2  s . c  o  m
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.ghsoft.treetask.R;
import com.ghsoft.treetask.Task;
import com.ghsoft.treetask.TaskDummy;
import com.ghsoft.treetask.TaskManager;
import com.ghsoft.treetask.TaskNode;

public class EditTask extends ModifyTaskActivity {

  private Task task;
  private boolean fromList;

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle(R.string.edit_task);
    getSubmitButton().setText(R.string.update);

    Object sTask = getIntent().getSerializableExtra("task");
    fromList = getIntent().getBooleanExtra("fromListView", false);

    task = (Task) sTask;

    getNameField().setText(task.getName());
    getdescriptionField().setText(task.getDescription());
    
    getPicker().setOldCenterColor(task.getColor());
    
    if (task.isHead()) {
      hideChangeWeightOption(true);
    } else {
      setWeightField(task.getWeight());
    }

  }

  @Override
  public void onSubmit() {
    // TODO Auto-generated method stub
    if (getNameField().getText().toString().length() < 1) {
      Toast.makeText(EditTask.this, R.string.supply_name, Toast.LENGTH_LONG).show();
      return;
    }

    if (task.setName(getNameField().getText().toString())) {
      if (task.setDescription(getdescriptionField().getText().toString())) {
        
        if (getChangeColor()) {
          task.setColor(getPicker().getColor());
        }
        
        if (getChangeWeight()) {
          task.setWeight(getWeightFieldValue());
        }
        
        TaskManager.save(task.getHead());
        Intent i = null;

        if (task instanceof TaskNode) {

          if (((TaskNode) task).getChild(0) instanceof TaskDummy) {
            i = new Intent(EditTask.this, NewTreeView.class);
          } else {
            i = new Intent(EditTask.this, TaskView.class);
          }
        } else {
          i = new Intent(EditTask.this, TaskView.class);
        }

        if (fromList) {
          i.putExtra("task", task.getParent());
        } else {
          i.putExtra("task", task);
        }

        finish();
        startActivity(i);
        overridePendingTransition(R.anim.back_short_zoom, R.anim.slide_down);

      } else {
        Toast.makeText(EditTask.this, R.string.description_less_than + " " + Task.maxDescriptionLen + " " + R.string.characters, Toast.LENGTH_LONG).show();
      }
    } else {
      Toast.makeText(EditTask.this, R.string.name_less_than + " " + Task.maxNameLen + " " + R.string.characters, Toast.LENGTH_LONG).show();
    }

  }

  @Override
  public void onBackPressed() {
    super.onBackPressed();

    Intent i = null;

    if (task instanceof TaskNode) {

      if (((TaskNode) task).getChild(0) instanceof TaskDummy) {
        i = new Intent(EditTask.this, NewTreeView.class);
      } else {
        i = new Intent(EditTask.this, TaskView.class);
      }
    } else {
      i = new Intent(EditTask.this, TaskView.class);
    }

    if (fromList) {
      i.putExtra("task", task.getParent());
    } else {
      i.putExtra("task", task);
    }

    finish();
    startActivity(i);
    overridePendingTransition(R.anim.back_short_zoom, R.anim.slide_down);

  }

}




Java Source Code List

com.ghsoft.treetask.MetaData.java
com.ghsoft.treetask.TaskDummy.java
com.ghsoft.treetask.TaskHead.java
com.ghsoft.treetask.TaskLeaf.java
com.ghsoft.treetask.TaskManager.java
com.ghsoft.treetask.TaskNode.java
com.ghsoft.treetask.Task.java
com.ghsoft.treetask.TextTreeBuilder.java
com.ghsoft.treetaskapp.About.java
com.ghsoft.treetaskapp.EditTask.java
com.ghsoft.treetaskapp.ExportView.java
com.ghsoft.treetaskapp.HtmlTreeBuilder.java
com.ghsoft.treetaskapp.MainListItem.java
com.ghsoft.treetaskapp.MainViewFragment.java
com.ghsoft.treetaskapp.Main.java
com.ghsoft.treetaskapp.ModifyTaskActivity.java
com.ghsoft.treetaskapp.NewTask.java
com.ghsoft.treetaskapp.NewTreeTask.java
com.ghsoft.treetaskapp.NewTreeView.java
com.ghsoft.treetaskapp.Settings.java
com.ghsoft.treetaskapp.TaskViewListItem.java
com.ghsoft.treetaskapp.TaskView.java
com.ghsoft.treetaskapp.TreeTaskProgressBar.java
com.ghsoft.treetaskapp.TreeView.java