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;
}
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);
}
}
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);
}
}
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();
}
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);
}
});
}
Aggregations