Search in sources :

Example 1 with PicUrls

use of org.aisen.weibo.sina.sinasdk.bean.PicUrls in project AisenWeiBo by wangdan.

the class SinaSDK method searchsResultStatuss.

/**
 * H5接口搜索微博
 *
 * @param q
 * @param page
 * @param cookies
 * @return
 * @throws TaskException
 */
public ArrayList<StatusContent> searchsResultStatuss(String q, int page, String cookies) throws TaskException {
    ArrayList<StatusContent> resultUsers = new ArrayList<>();
    Setting action = newSetting("searchsResultUsers", "page/pageJson", "获取用户");
    action.getExtras().put(BASE_URL, newSettingExtra(BASE_URL, "http://m.weibo.cn/", ""));
    Params params = new Params();
    params.addParameter("containerid", "100103type%3D2%26q%3D" + q + "&page=" + page);
    try {
        String response = doGet(getHttpConfig(), action, params, String.class);
        JSONObject responseJSON = JSONObject.parseObject(response);
        int ok = responseJSON.getInteger("ok");
        if (ok == 1) {
            JSONArray cardsArray = responseJSON.getJSONArray("cards");
            for (int i = 0; i < cardsArray.size(); i++) {
                JSONObject cardGroupsObject = cardsArray.getJSONObject(i);
                JSONArray cardGroupArray = cardGroupsObject.getJSONArray("card_group");
                for (int j = 0; j < cardGroupArray.size(); j++) {
                    JSONObject cardGroup = cardGroupArray.getJSONObject(j);
                    JSONObject mblogObject = cardGroup.getJSONObject("mblog");
                    StatusContent content = JSON.parseObject(mblogObject.toJSONString(), StatusContent.class);
                    // 图片
                    if (mblogObject.containsKey("pics")) {
                        JSONArray picsArray = mblogObject.getJSONArray("pics");
                        if (picsArray != null && picsArray.size() > 0) {
                            PicUrls picUrls = new PicUrls();
                            picUrls.setThumbnail_pic(picsArray.getJSONObject(0).getString("url"));
                            content.setPic_urls(new PicUrls[] { picUrls });
                        }
                    }
                    // 把Html5文本转换一下
                    content.setText(Html.fromHtml(content.getText()).toString());
                    if (content.getRetweeted_status() != null) {
                        content.getRetweeted_status().setText(Html.fromHtml(content.getRetweeted_status().getText()).toString());
                    }
                    // 把时间转换一下
                    try {
                        Calendar calendar = Calendar.getInstance();
                        int year = calendar.get(Calendar.YEAR);
                        SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
                        calendar.setTimeInMillis(format.parse(content.getCreated_at()).getTime());
                        calendar.set(Calendar.YEAR, year);
                        content.setCreated_at(calendar.getTimeInMillis() + "");
                    } catch (ParseException e) {
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                            content.setCreated_at(format.parse(content.getCreated_at()).getTime() + "");
                        } catch (ParseException ewe) {
                        }
                    }
                    resultUsers.add(content);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (e instanceof TaskException) {
            throw (TaskException) e;
        }
    }
    return resultUsers;
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) Setting(org.aisen.android.common.setting.Setting) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) JSONArray(com.alibaba.fastjson.JSONArray) Params(org.aisen.android.network.http.Params) ParseException(java.text.ParseException) TaskException(org.aisen.android.network.task.TaskException) JSONObject(com.alibaba.fastjson.JSONObject) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) TaskException(org.aisen.android.network.task.TaskException) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with PicUrls

use of org.aisen.weibo.sina.sinasdk.bean.PicUrls 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 3 with PicUrls

use of org.aisen.weibo.sina.sinasdk.bean.PicUrls 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 4 with PicUrls

use of org.aisen.weibo.sina.sinasdk.bean.PicUrls in project AisenWeiBo by wangdan.

the class TimelinePicActivity method loadPicture.

private void loadPicture(String pic) {
    PicUrls picUrls = new PicUrls();
    picUrls.setThumbnail_pic(pic.replace("large", "bmiddle").replace("small", "bmiddle"));
    ABaseFragment pictureFragment = PictureFragment.newInstance(picUrls);
    getFragmentManager().beginTransaction().replace(R.id.layContainer, pictureFragment, "PicFragment").commit();
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls)

Example 5 with PicUrls

use of org.aisen.weibo.sina.sinasdk.bean.PicUrls in project AisenWeiBo by wangdan.

the class PictureFragment method layoutInit.

@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceSate) {
    super.layoutInit(inflater, savedInstanceSate);
    mStatus = PictureStatus.wait;
    image = savedInstanceSate == null ? (PicUrls) getArguments().getSerializable("url") : (PicUrls) savedInstanceSate.getSerializable("url");
    Uri uri = Uri.parse(image.getThumbnail_pic());
    if ("file".equals(uri.getScheme().toLowerCase())) {
        origFile = new File(uri.getPath());
    } else {
        origFile = BitmapLoader.getInstance().getCacheFile(getOrigImage());
        setHasOptionsMenu(true);
    }
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float v, float v1) {
            getActivity().finish();
        }
    });
    mWebView.addJavascriptInterface(new PictureJavaScriptInterface(), "picturejs");
    layError.setPadding(0, 0, 0, SystemUtils.getNavigationBarHeight(getActivity()));
    loadPicture(viewFailure);
    findViewById(R.id.txtFailure).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadPicture(v);
        }
    });
}
Also used : PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) Uri(android.net.Uri) File(java.io.File) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) View(android.view.View) PictureProgressView(org.aisen.weibo.sina.ui.widget.PictureProgressView) WebView(android.webkit.WebView) PhotoView(uk.co.senab.photoview.PhotoView)

Aggregations

PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)6 StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)4 DialogInterface (android.content.DialogInterface)2 File (java.io.File)2 JokeBean (org.aisen.weibo.sina.support.bean.JokeBean)2 Uri (android.net.Uri)1 View (android.view.View)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Setting (org.aisen.android.common.setting.Setting)1 Params (org.aisen.android.network.http.Params)1 TaskException (org.aisen.android.network.task.TaskException)1 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)1 PictureProgressView (org.aisen.weibo.sina.ui.widget.PictureProgressView)1