Android Open Source - Tree-Task Tree View






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 va 2s  .c  o m
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.ghsoft.treetask.R;
import com.ghsoft.treetask.TaskNode;

public class TreeView extends ActionBarActivity {

  private TaskNode task;
  private WebView treeDisplay;

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tree_view);

    Object sTask = getIntent().getSerializableExtra("task");
    
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    task = (TaskNode) sTask;

    setTitle(task.getName());

    treeDisplay = (WebView) findViewById(R.id.treeDisplay);
    treeDisplay.setBackgroundColor(Color.argb(1, 0, 0, 0));

    HtmlTreeBuilder builder = new HtmlTreeBuilder(task.getHead().getTask(), TreeView.this);

    String data = builder.getHtml();

    treeDisplay.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "UTF-8", "");

    treeDisplay.setWebViewClient(new WebViewClient() {
      // Override URL
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        String[] parts = url.split(",");

        TaskNode h = (TaskNode) task.getHead().getTask();
        for (int i = 1; i < parts.length; i++) {
          h = (TaskNode) h.getChild((Integer.parseInt(parts[i])));
        }

        Intent i = new Intent(TreeView.this, TaskView.class);
        i.putExtra("task", h);
        i.putExtra("treeView", task);
        i.putExtra("parentCount", parts.length - 1);
        finish();
        startActivity(i);
        overridePendingTransition(R.anim.slide_from, R.anim.short_zoom);

        return true;
      }
    });

  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case android.R.id.home:
      onBackPressed();
      break;
    }
    return true;
  }

  @Override
  public void onBackPressed() {

    Intent i = new Intent(TreeView.this, TaskView.class);
    i.putExtra("task", task);
    finish();
    startActivity(i);
    overridePendingTransition(R.anim.back_short_zoom, R.anim.slide_up_from);

  }

}




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