// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_ID = "id";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Image = "image";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Message = "message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Name = "name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Next_Message = "next_message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Next_SubName = "next_sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Original_ID = "original_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Prev_Message = "prev_message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Prev_SubName = "prev_sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_SubName = "sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Time = "time";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Table_Recalled_Messages = "recalls";


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import static com.qsboy.antirecall.db.DBHelper.Column_ID;
import static com.qsboy.antirecall.db.DBHelper.Column_Image;
import static com.qsboy.antirecall.db.DBHelper.Column_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Name;
import static com.qsboy.antirecall.db.DBHelper.Column_Next_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Next_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_Original_ID;
import static com.qsboy.antirecall.db.DBHelper.Column_Prev_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Prev_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_Time;
import static com.qsboy.antirecall.db.DBHelper.Table_Recalled_Messages;
                Column_Message + " = ? and " + Column_SubName + " = ?",
                new String[]{message, subName},
                null, null,
                Column_ID + " DESC");
        // 如果不存在上一条
        if (!cursor.moveToFirst())
            return false;
        int idMsg = cursor.getInt(0);
        cursor = db.query(getSafeName(name),
                new String[]{Column_ID},
                Column_Message + " = ? and " + Column_SubName + " = ?",
                new String[]{prevMessage, prevSubName},
                null, null,
                Column_ID + " DESC");

        if (!cursor.moveToFirst())
            return false;
        int idPreMsg = cursor.getInt(0);
        closeCursor();
        return idMsg - idPreMsg == 1;
    }

    public boolean existRecall(Messages messages) {
        if (!existTable(Table_Recalled_Messages))
            return false;
        cursor = db.query(Table_Recalled_Messages,
                new String[]{Column_ID},
                Column_Original_ID + " = ? and " +
                        Column_Name + " = ? and " +
                        Column_SubName + " = ? and " +
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_ID = "id";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Image = "image";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Message = "message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Name = "name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Next_Message = "next_message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Next_SubName = "next_sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Original_ID = "original_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Prev_Message = "prev_message";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Prev_SubName = "prev_sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_SubName = "sub_name";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Column_Time = "time";
// 
// Path: app/src/main/java/com/qsboy/antirecall/db/DBHelper.java
// public static final String Table_Recalled_Messages = "recalls";


// Path: app/src/main/java/com/qsboy/antirecall/db/Dao.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import static com.qsboy.antirecall.db.DBHelper.Column_ID;
import static com.qsboy.antirecall.db.DBHelper.Column_Image;
import static com.qsboy.antirecall.db.DBHelper.Column_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Name;
import static com.qsboy.antirecall.db.DBHelper.Column_Next_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Next_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_Original_ID;
import static com.qsboy.antirecall.db.DBHelper.Column_Prev_Message;
import static com.qsboy.antirecall.db.DBHelper.Column_Prev_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_SubName;
import static com.qsboy.antirecall.db.DBHelper.Column_Time;
import static com.qsboy.antirecall.db.DBHelper.Table_Recalled_Messages;

                Column_Message + " = ? and " + Column_SubName + " = ?",
                new String[]{message, subName},
                null, null,
                Column_ID + " DESC");
        // 如果不存在上一条
        if (!cursor.moveToFirst())
            return false;
        int idMsg = cursor.getInt(0);
        cursor = db.query(getSafeName(name),
                new String[]{Column_ID},
                Column_Message + " = ? and " + Column_SubName + " = ?",
                new String[]{prevMessage, prevSubName},
                null, null,
                Column_ID + " DESC");

        if (!cursor.moveToFirst())
            return false;
        int idPreMsg = cursor.getInt(0);
        closeCursor();
        return idMsg - idPreMsg == 1;
    }

    public boolean existRecall(Messages messages) {
        if (!existTable(Table_Recalled_Messages))
            return false;
        cursor = db.query(Table_Recalled_Messages,
                new String[]{Column_ID},
                Column_Original_ID + " = ? and " +
                        Column_Name + " = ? and " +
                        Column_SubName + " = ? and " +
                        Column_Message + " = ? and " +