parent
c1f755fcdb
commit
87cae22510
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.micode.notes.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
|
||||
import net.micode.notes.data.Notes.NoteColumns;
|
||||
|
||||
/**
|
||||
* 回收站异常类
|
||||
* <p>
|
||||
* 定义回收站操作过程中可能出现的各种异常
|
||||
* </p>
|
||||
*/
|
||||
public class TrashException extends Exception {
|
||||
private static final String TAG = "TrashException";
|
||||
|
||||
/**
|
||||
* 异常类型枚举
|
||||
*/
|
||||
public enum ErrorType {
|
||||
INVALID_NOTE_ID("Invalid note ID"),
|
||||
SYSTEM_FOLDER_ERROR("Cannot operate on system folder"),
|
||||
NOTE_NOT_FOUND("Note not found"),
|
||||
DATABASE_ERROR("Database operation failed"),
|
||||
ALREADY_IN_TRASH("Note is already in trash"),
|
||||
NOT_IN_TRASH("Note is not in trash"),
|
||||
EMPTY_TRASH("Trash is already empty"),
|
||||
UNKNOWN_ERROR("Unknown error occurred");
|
||||
|
||||
private final String message;
|
||||
|
||||
ErrorType(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
private ErrorType errorType;
|
||||
private long noteId;
|
||||
|
||||
public TrashException(ErrorType errorType) {
|
||||
super(errorType.getMessage());
|
||||
this.errorType = errorType;
|
||||
this.noteId = -1;
|
||||
Log.e(TAG, "TrashException: " + errorType.getMessage());
|
||||
}
|
||||
|
||||
public TrashException(ErrorType errorType, long noteId) {
|
||||
super(errorType.getMessage() + " (ID: " + noteId + ")");
|
||||
this.errorType = errorType;
|
||||
this.noteId = noteId;
|
||||
Log.e(TAG, "TrashException: " + errorType.getMessage() + " (ID: " + noteId + ")");
|
||||
}
|
||||
|
||||
public TrashException(ErrorType errorType, Throwable cause) {
|
||||
super(errorType.getMessage(), cause);
|
||||
this.errorType = errorType;
|
||||
this.noteId = -1;
|
||||
Log.e(TAG, "TrashException: " + errorType.getMessage(), cause);
|
||||
}
|
||||
|
||||
public ErrorType getErrorType() {
|
||||
return errorType;
|
||||
}
|
||||
|
||||
public long getNoteId() {
|
||||
return noteId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:gravity="center"
|
||||
android:text="@string/trash_folder_name"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/trash_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:divider="@android:drawable/divider_horizontal_bright"
|
||||
android:dividerHeight="1dp"
|
||||
android:scrollbarStyle="outsideOverlay" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/trash_empty"
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_restore"
|
||||
android:icon="@android:drawable/ic_menu_revert"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_restore" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_permanently_delete"
|
||||
android:icon="@android:drawable/ic_menu_delete"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_permanently_delete" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_empty_trash"
|
||||
android:icon="@android:drawable/ic_menu_delete"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_empty_trash" />
|
||||
|
||||
</menu>
|
||||
Loading…
Reference in new issue