package com.ttstd.dialer.db.app;

import android.content.Context;

import java.util.List;

public class AppRepository {
    AppDao mAppDao;

    public AppRepository(Context context) {
        AppDatabase db = AppDatabase.getDatabase(context);
        mAppDao = db.appDao();
    }

    public int getTotalCount() {
        return mAppDao.getTotalCount();
    }

    public int getCountById() {
        return mAppDao.getCountById();
    }

    public AppInfo getAppInfo(String packageName, String className) {
        return mAppDao.getAppInfo(packageName, className);
    }

    public int getIdByPackageAndClass(String packageName, String className) {
        return mAppDao.getIdByPackageAndClass(packageName, className);
    }

    public int checkAppInfoExists(String packageName, String className) {
        return mAppDao.checkAppInfoExists(packageName, className);
    }

    // 获取所有APP
    public List<AppInfo> getAllApp() {
        return mAppDao.getAllApp();
    }

    // 获取在外面显示的APP
    public List<AppInfo> getOutsideApp() {
        return mAppDao.getOutsideApp();
    }

    // 获取在里面显示的APP
    public List<AppInfo> getInsideApp() {
        return mAppDao.getInsideApp();
    }

    // 根据ID获取APP
    public AppInfo getAppById(int id) {
        return mAppDao.getAppById(id);
    }

    // 搜索APP
    public List<AppInfo> searchApp(String query) {
        return mAppDao.searchApp("%" + query + "%");
    }

    // 添加APP
    public long insert(AppInfo appInfo) {
        return mAppDao.insert(appInfo);
    }

    public long[] insert(List<AppInfo> appInfos) {
        return mAppDao.insert(appInfos);
    }

    // 更新APP
    public int update(AppInfo appInfo) {
        return mAppDao.update(appInfo);
    }

    // 删除APP
    public int delete(AppInfo appInfo) {
        return mAppDao.delete(appInfo);
    }

    // 根据ID删除APP
    public int deleteById(int id) {
        return mAppDao.deleteById(id);
    }

    // 删除所有APP
    public int deleteAll() {
        return mAppDao.deleteAll();
    }
}
