Android Open Source - myToDo Memo Options Dialog






From Project

Back to project page myToDo.

License

The source code is released under:

Apache License

If you think the Android project myToDo 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.gutspot.apps.android.mytodo.dialog;
//from  w w w .  ja v  a  2  s .c om
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;

import com.gutspot.apps.android.mytodo.MemoActivity;
import com.gutspot.apps.android.mytodo.ToDoActivity;
import com.gutspot.apps.android.mytodo.dao.MemoDAO;
import com.gutspot.apps.android.mytodo.utils.AlertUtil;

public class MemoOptionsDialog extends DialogFragment implements OnClickListener {
    private static final String[] options = new String[] { "??", "??" };

    private Context context;
    private long toDoId;
    private long memoId;

    public static MemoOptionsDialog newInstance(Context context, long toDoId, long memoId) {
        MemoOptionsDialog dialog = new MemoOptionsDialog();
        dialog.context = context;
        dialog.toDoId = toDoId;
        dialog.memoId = memoId;
        return dialog;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("????");
        builder.setItems(options, this);
        return builder.create();
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
        case 0:
            viewMemo();
            break;

        case 1:
            deleteMemo();
            break;

        default:

        }
    }

    private void viewMemo() {
        Intent intent = new Intent(context, MemoActivity.class);
        intent.putExtra("type", 3);
        intent.putExtra("todo_id", toDoId);
        intent.putExtra("memo_id", memoId);
        context.startActivity(intent);
    }

    private void deleteMemo() {
        String message = "??????Memo?";

        String yesLabel = "?";
        DialogInterface.OnClickListener yesListener = new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                MemoDAO memoDAO = new MemoDAO(context);
                memoDAO.remove(memoId);
                ((ToDoActivity) context).updateMemoListView();
            }
        };

        String noLabel = "???";
        DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        };

        AlertUtil.show(context, message, yesLabel, yesListener, noLabel, noListener);
    }
}




Java Source Code List

com.gutspot.apps.android.mytodo.MainActivity.java
com.gutspot.apps.android.mytodo.MemoActivity.java
com.gutspot.apps.android.mytodo.ToDoActivity.java
com.gutspot.apps.android.mytodo.adapter.MemoAdapter.java
com.gutspot.apps.android.mytodo.adapter.ToDoAdapter.java
com.gutspot.apps.android.mytodo.dao.AbstractDAO.java
com.gutspot.apps.android.mytodo.dao.MemoDAO.java
com.gutspot.apps.android.mytodo.dao.NoticeDAO.java
com.gutspot.apps.android.mytodo.dao.ToDoDAO.java
com.gutspot.apps.android.mytodo.dialog.DateTimeDialog.java
com.gutspot.apps.android.mytodo.dialog.MemoOptionsDialog.java
com.gutspot.apps.android.mytodo.dialog.ToDoOptionsDialog.java
com.gutspot.apps.android.mytodo.model.AbstractEntity.java
com.gutspot.apps.android.mytodo.model.Memo.java
com.gutspot.apps.android.mytodo.model.Notice.java
com.gutspot.apps.android.mytodo.model.ToDo.java
com.gutspot.apps.android.mytodo.utils.AlertUtil.java
com.gutspot.apps.android.mytodo.utils.DBOpenHelper.java
com.gutspot.apps.android.mytodo.utils.DateTimeUtil.java