Android Open Source - TodoList Main Activity






From Project

Back to project page TodoList.

License

The source code is released under:

Apache License

If you think the Android project TodoList 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 lyc.app;
// w w w .j  a va 2s . c om
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import lyc.app.fragment.FinishedTodoFragment;
import lyc.app.fragment.UnFinishedTodoFragment;


public class MainActivity extends ActionBarActivity implements ActionBar.TabListener {

  private static final String TAG = "MainActivity";
  private ActionBar actionBar;
  private UnFinishedTodoFragment unFinishedTodoFragment;
  private FinishedTodoFragment finishedTodoFragment;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    actionBar = getSupportActionBar();
    actionBar.setSubtitle(R.string.unfinished_todo_listview_title);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab first = actionBar.newTab();
    first.setText(R.string.unfinished_todo_listview_title);
    first.setTabListener(this);
    actionBar.addTab(first);

    ActionBar.Tab second = actionBar.newTab();
    second.setText(R.string.finished_todo_listview_title);
    second.setTabListener(this);
    actionBar.addTab(second);

    LocalBroadcastManager.getInstance(this)
        .registerReceiver(new BootReceiver(), new IntentFilter("dddd"));
    LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("dddd"));
  }

  @Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
    Log.d(TAG, ">>>> " + tab.getText() + ", " + tab.getPosition());
    switch (tab.getPosition()) {
      case 0:
        //unfinished tab, unfinished fragment add
        actionBar.setSubtitle(R.string.unfinished_todo_listview_title);
        if (unFinishedTodoFragment == null) {
          unFinishedTodoFragment = new UnFinishedTodoFragment();
        }
        ft.replace(R.id.main_content, unFinishedTodoFragment);
        break;
      case 1:
        //finished tab, finished fragment add
        actionBar.setSubtitle(R.string.finished_todo_listview_title);
        if (finishedTodoFragment == null) {
          finishedTodoFragment = new FinishedTodoFragment();
        }
        ft.replace(R.id.main_content, finishedTodoFragment);
        break;
      default:
        break;
    }
  }

  @Override
  public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
    Log.d(TAG, "<<<< " + tab.getText());
  }

  @Override
  public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
    Log.d(TAG, "<><><><> " + tab.getText());
  }

  public void refreshFinishedTodo(boolean isRefresh) {
    if (isRefresh) {
      Bundle args = new Bundle();
      args.putBoolean("is_refresh", true);
      finishedTodoFragment.setArguments(args);
    }
  }
}




Java Source Code List

lyc.app.AddActivity.java
lyc.app.App.java
lyc.app.BootReceiver.java
lyc.app.DateUtils.java
lyc.app.MainActivity.java
lyc.app.TodoService.java
lyc.app.adapter.TodoCursorAdapter.java
lyc.app.fragment.FinishedTodoFragment.java
lyc.app.fragment.UnFinishedTodoFragment.java
lyc.app.provider.TodoProvider.java
lyc.simplesqlite.annotation.Column.java
lyc.simplesqlite.annotation.Table.java
lyc.simplesqlite.exception.AnnotationNotFoundException.java
lyc.simplesqlite.util.MetaData.java
lyc.simplesqlite.util.StringUtils.java