Search in sources :

Example 1 with Setting

use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.

the class ABizLogic method newSetting.

protected Setting newSetting(String type, String value, String desc) {
    Setting extra = new Setting();
    extra.setType(type);
    extra.setValue(value);
    extra.setDescription(desc);
    return extra;
}
Also used : Setting(org.aisen.android.common.setting.Setting)

Example 2 with Setting

use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.

the class SDK method getJokes.

/**
 * 获取笑料百科列表
 *
 * @param id
 * @param direction
 * @param limit
 * @return
 * @throws TaskException
 */
public JokeBeans getJokes(long id, String direction, int limit, int type) throws TaskException {
    Setting action = newSetting("getJokes", "jokes", "获取笑话列表");
    action.getExtras().put(BASE_URL, newSettingExtra(BASE_URL, "http://stream-cn-api.tclclouds.com/api/", ""));
    Params params = new Params();
    if ("up".equalsIgnoreCase(direction) || "down".equalsIgnoreCase(direction)) {
    } else {
        direction = "up";
        id = 0;
    }
    params.addParameter("id", String.valueOf(id));
    params.addParameter("direction", String.valueOf(direction));
    params.addParameter("limit", String.valueOf(limit));
    params.addParameter("mode", String.valueOf(type));
    // 配置缓存器
    action.getExtras().put(CACHE_UTILITY, newSettingExtra(CACHE_UTILITY, JokesCacheUtility.class.getName(), ""));
    return doGet(action, params, JokeBeans.class);
}
Also used : Setting(org.aisen.android.common.setting.Setting) Params(org.aisen.android.network.http.Params)

Example 3 with Setting

use of org.aisen.android.common.setting.Setting 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 4 with Setting

use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.

the class VideoService method getPicture.

public static void getPicture(VideoBean video) throws Exception {
    if (TextUtils.isEmpty(AppContext.getAccount().getCookie())) {
        throw new TaskException("123", "解析链接失败");
    }
    HttpConfig config = new HttpConfig();
    config.baseUrl = video.getShortUrl();
    config.cookie = AppContext.getAccount().getCookie();
    config.addHeader("Content-Type", "text/html;charset=utf-8");
    Setting action = new Setting();
    action.setType("");
    action.setValue("");
    action.setDescription("");
    String response = new DefHttpUtility().doGet(config, action, null, String.class);
    Document dom = Jsoup.parse(response);
    video.setIdStr(KeyGenerator.generateMD5(video.getShortUrl()));
    Elements divs = dom.select("img");
    if (divs != null && divs.size() > 0) {
        video.setImage(divs.get(0).attr("src"));
        video.setImage(video.getImage().replace("bmiddle", "small").replace("thumbnail", "small"));
    }
    if (TextUtils.isEmpty(video.getImage())) {
        String longUrl = video.getLongUrl();
        if (TextUtils.isEmpty(longUrl)) {
            UrlsBean urlsBean = SinaSDK.getInstance(AppContext.getAccount().getAccessToken()).urlShort2Long(video.getShortUrl());
            if (urlsBean.getUrls() != null && urlsBean.getUrls().size() > 0) {
                longUrl = urlsBean.getUrls().get(0).getUrl_long();
                longUrl.replace("bmiddle", "small").replace("thumbnail", "small");
            }
        }
        if (!TextUtils.isEmpty(longUrl)) {
            video.setImage(longUrl);
        }
    }
}
Also used : TaskException(org.aisen.android.network.task.TaskException) Setting(org.aisen.android.common.setting.Setting) HttpConfig(org.aisen.android.network.http.HttpConfig) SpannableString(android.text.SpannableString) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) UrlsBean(org.aisen.weibo.sina.sinasdk.bean.UrlsBean) DefHttpUtility(org.aisen.android.network.http.DefHttpUtility)

Example 5 with Setting

use of org.aisen.android.common.setting.Setting in project AisenWeiBo by wangdan.

the class SinaSDK method statusesUserTimeLine.

/**
 * 返回用户最新发表的微博消息列表<br>
 * 建议使用该参数<br>
 * <br>
 * 如果:id、user_id、screen_name三个参数均未指定,则返回当前登录用户最近发表的微博消息列表。<br>
 * <br>
 *
 * @param user_id
 *            (false):用户ID,主要是用来区分用户ID跟微博昵称。当微博昵称为数字导致和用户ID产生歧义,
 *            特别是当微博昵称和用户ID一样的时候
 * @param since_id
 *            (false):若指定此参数,则只返回ID比since_id大的评论(比since_id发表时间晚)
 * @param max_id
 *            (false):若指定此参数,则返回ID小于或等于max_id的评论
 * @param count
 *            (false):单页返回的记录条数。(默认值20,最大200)
 * @param page
 *            (false):返回结果的页码。注意:有分页限制。
 * @param base_app
 *            (false):是否基于当前应用来获取数据。1为限制本应用微博,0为不做限制
 * @param feature
 *            (false):微博类型,0全部,1原创,2图片,3视频,4音乐. 返回指定类型的微博信息内容
 * @return
 */
public StatusContents statusesUserTimeLine(Params params) throws TaskException {
    if (!params.containsKey("count"))
        params.addParameter("count", getPageCount(getSetting("statusesUserTimeLine")));
    params.setEncodeAble(false);
    Setting action = getSetting("statusesUserTimeLine");
    action.getExtras().put(HTTP_UTILITY, newSettingExtra(HTTP_UTILITY, TimelineHttpUtility.class.getName(), ""));
    return doGet(action, configParams(params), StatusContents.class);
}
Also used : Setting(org.aisen.android.common.setting.Setting)

Aggregations

Setting (org.aisen.android.common.setting.Setting)26 Params (org.aisen.android.network.http.Params)17 TaskException (org.aisen.android.network.task.TaskException)11 HttpConfig (org.aisen.android.network.http.HttpConfig)7 ParseException (java.text.ParseException)6 JSONArray (com.alibaba.fastjson.JSONArray)3 JSONObject (com.alibaba.fastjson.JSONObject)3 ArrayList (java.util.ArrayList)2 LikeResultBean (org.aisen.weibo.sina.support.bean.LikeResultBean)2 SpannableString (android.text.SpannableString)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 DefHttpUtility (org.aisen.android.network.http.DefHttpUtility)1 PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)1 SearchsResultUser (org.aisen.weibo.sina.sinasdk.bean.SearchsResultUser)1 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)1 UrlsBean (org.aisen.weibo.sina.sinasdk.bean.UrlsBean)1 WallpaperBeans (org.aisen.weibo.sina.support.bean.WallpaperBeans)1 Document (org.jsoup.nodes.Document)1 Elements (org.jsoup.select.Elements)1