Search in sources :

Example 1 with WallpaperBeans

use of org.aisen.weibo.sina.support.bean.WallpaperBeans in project AisenWeiBo by wangdan.

the class SDK method getWallpaper.

/**
     * 获取壁纸列表
     *
     * @param page
     * @return
     * @throws TaskException
     */
public WallpaperBeans getWallpaper(int page) throws TaskException {
    Setting action = newSetting("getWallpaper", "wallpaper/newestorhot/content", "获取最新壁纸列表");
    action.getExtras().put(BASE_URL, newSettingExtra(BASE_URL, "http://apps.tclclouds.com/api/", ""));
    Params params = new Params();
    // 1:最新;2:最热)
    params.addParameter("flag", "2");
    params.addParameter("page", String.valueOf(page));
    params.addParameter("per_page", "30");
    params.addParameter("encoder", "debug");
    // 配置缓存器
    action.getExtras().put(CACHE_UTILITY, newSettingExtra(CACHE_UTILITY, WallpaperCacheUtility.class.getName(), ""));
    WallpaperBeans beans = doGet(action, params, WallpaperBeans.class);
    if (beans.getItem() == null || beans.getItem().getWallpaperList() == null) {
        throw new TaskException(TaskException.TaskError.resultIllegal.toString());
    }
    return beans;
}
Also used : TaskException(org.aisen.android.network.task.TaskException) WallpaperBeans(org.aisen.weibo.sina.support.bean.WallpaperBeans) Setting(org.aisen.android.common.setting.Setting) Params(org.aisen.android.network.http.Params)

Example 2 with WallpaperBeans

use of org.aisen.weibo.sina.support.bean.WallpaperBeans in project AisenWeiBo by wangdan.

the class WallpaperCacheUtility method addCacheData.

@Override
public void addCacheData(Setting action, Params params, IResult result) {
    int page = Integer.parseInt(params.getParameter("page"));
    // 简单点,只存第一份缓存
    if (page == 1) {
        WallpaperBeans beans = (WallpaperBeans) result;
        SinaDB.getDB().deleteAll(null, WallpaperBean.class);
        SinaDB.getDB().insert(null, beans.getItem().getWallpaperList());
        CacheTimeUtils.saveTime("Wallpaper", null);
    }
}
Also used : WallpaperBeans(org.aisen.weibo.sina.support.bean.WallpaperBeans)

Example 3 with WallpaperBeans

use of org.aisen.weibo.sina.support.bean.WallpaperBeans in project AisenWeiBo by wangdan.

the class WallpaperCacheUtility method findCacheData.

@Override
public IResult findCacheData(Setting action, Params params) {
    int page = Integer.parseInt(params.getParameter("page"));
    // 只有第一次加载数据的时候才加载缓存
    if (page == 1) {
        // 根据id倒序
        List<WallpaperBean> beanList = SinaDB.getDB().select(null, WallpaperBean.class);
        if (beanList.size() > 0) {
            WallpaperBeans beans = new WallpaperBeans();
            beans.setItem(new WallpaperBeans.Data());
            beans.getItem().setWallpaperList(beanList);
            beans.setFromCache(true);
            beans.setEndPaging(beanList.size() == 0);
            beans.setOutofdate(CacheTimeUtils.isOutofdate("Wallpaper", null));
            return beans;
        }
    }
    return null;
}
Also used : WallpaperBeans(org.aisen.weibo.sina.support.bean.WallpaperBeans) WallpaperBean(org.aisen.weibo.sina.support.bean.WallpaperBean)

Aggregations

WallpaperBeans (org.aisen.weibo.sina.support.bean.WallpaperBeans)3 Setting (org.aisen.android.common.setting.Setting)1 Params (org.aisen.android.network.http.Params)1 TaskException (org.aisen.android.network.task.TaskException)1 WallpaperBean (org.aisen.weibo.sina.support.bean.WallpaperBean)1