Search in sources :

Example 1 with JokeBean

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

the class JokesFragment method onItemClick.

@Override
public void onItemClick(PLAAdapterView<?> parent, View view, int position, long id) {
    super.onItemClick(parent, view, position, id);
    final JokeBean bean = getAdapterItems().get(position);
    // 纯文
    if (bean.getItemType() == 0) {
        AisenUtils.showMenuDialog(this, view, getResources().getStringArray(R.array.jokes_menu), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    MobclickAgent.onEvent(getActivity(), "joke_text_copy");
                    AisenUtils.copyToClipboard(bean.getExcerpt());
                } else if (which == 1) {
                    MobclickAgent.onEvent(getActivity(), "joke_text_share");
                    startActivity(Utils.getShareIntent("", bean.getExcerpt(), ""));
                }
            }
        });
    } else // 图文
    if (bean.getItemType() == 1) {
        StatusContent statusContent = new StatusContent();
        PicUrls picUrls = new PicUrls();
        picUrls.setThumbnail_pic(bean.getImgUrl());
        statusContent.setText(bean.getExcerpt());
        statusContent.setPic_urls(new PicUrls[] { picUrls });
        PicsActivity.launch(getActivity(), statusContent, 0);
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) DialogInterface(android.content.DialogInterface) JokeBean(org.aisen.weibo.sina.support.bean.JokeBean)

Example 2 with JokeBean

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

the class JokesFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    super.onItemClick(parent, view, position, id);
    final JokeBean bean = getAdapterItems().get(position);
    // 纯文
    if (bean.getItemType() == 0) {
        AisenUtils.showMenuDialog(this, view, getResources().getStringArray(R.array.jokes_menu), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (which == 0) {
                    UMengUtil.onEvent(getActivity(), "joke_text_copy");
                    AisenUtils.copyToClipboard(bean.getExcerpt());
                } else if (which == 1) {
                    UMengUtil.onEvent(getActivity(), "joke_text_share");
                    startActivity(Utils.getShareIntent("", bean.getExcerpt(), ""));
                }
            }
        });
    } else // 图文
    if (bean.getItemType() == 1) {
        StatusContent statusContent = new StatusContent();
        PicUrls picUrls = new PicUrls();
        picUrls.setThumbnail_pic(bean.getImgUrl());
        statusContent.setText(bean.getExcerpt());
        statusContent.setPic_urls(new PicUrls[] { picUrls });
        PicsActivity.launch(getActivity(), statusContent, 0);
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) DialogInterface(android.content.DialogInterface) JokeBean(org.aisen.weibo.sina.support.bean.JokeBean)

Example 3 with JokeBean

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

the class JokesCacheUtility method findCacheData.

@Override
public IResult findCacheData(Setting action, Params params) {
    long id = Integer.parseInt(params.getParameter("id"));
    int type = Integer.parseInt(params.getParameter("mode"));
    // 只有第一次加载数据的时候才加载缓存
    if (id == 0) {
        // 根据id倒序
        String selection = String.format(" %s = ? ", FieldUtils.KEY);
        String[] selectionArgs = new String[] { String.valueOf(type) };
        List<JokeBean> beanList = SinaDB.getDB().select(JokeBean.class, selection, selectionArgs, null, null, " id desc ", null);
        if (beanList.size() > 0) {
            JokeBeans beans = new JokeBeans();
            JokeBeans.Data data = new JokeBeans.Data();
            data.setContents(beanList);
            beans.setData(data);
            beans.setFromCache(true);
            beans.setEndPaging(beanList.size() == 0);
            beans.setOutofdate(CacheTimeUtils.isOutofdate("Jokes" + type, null));
            return beans;
        }
    }
    return null;
}
Also used : JokeBeans(org.aisen.weibo.sina.support.bean.JokeBeans) JokeBean(org.aisen.weibo.sina.support.bean.JokeBean)

Aggregations

JokeBean (org.aisen.weibo.sina.support.bean.JokeBean)3 DialogInterface (android.content.DialogInterface)2 PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)2 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)2 JokeBeans (org.aisen.weibo.sina.support.bean.JokeBeans)1