Android Open Source - ShareSDK-for-Android Json Page






From Project

Back to project page ShareSDK-for-Android.

License

The source code is released under:

MIT License

If you think the Android project ShareSDK-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Offical Website:http://www.mob.com/*w  ww  . j  a v a2 s  .co m*/
 * Support QQ: 4006852216
 * Offical Wechat Account:ShareSDK   (We will inform you our updated news at the first time by Wechat, if we release a new version. If you get any problem, you can also contact us with Wechat, we will reply you within 24 hours.)
 *
 * Copyright (c) 2013 mob.com. All rights reserved.
 */

package cn.sharesdk.demo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import cn.sharesdk.framework.FakeActivity;
import cn.sharesdk.framework.TitleLayout;
import cn.sharesdk.framework.utils.UIHandler;
import android.os.Message;
import android.os.Handler.Callback;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

/** page to display json data */
public class JsonPage extends FakeActivity implements OnClickListener, Callback {
  private HashMap<String, Object> bigData;
  private String title;
  private TitleLayout llTitle;
  private TextView tvJson;

  public void setData(String title, HashMap<String, Object> data) {
    this.title = title;
    bigData = data;
  }

  public void onCreate() {
    activity.setContentView(R.layout.page_show_user_info);
    llTitle = (TitleLayout) activity.findViewById(R.id.llTitle);
    llTitle.getBtnBack().setOnClickListener(this);
    if (TextUtils.isEmpty(title)) {
      llTitle.getTvTitle().setText(R.string.app_name);
    } else {
      llTitle.getTvTitle().setText(title);
    }

    tvJson = (TextView) activity.findViewById(R.id.tvJson);
    new Thread() {
      public void run() {
        Message msg = new Message();
        msg.obj = format("", bigData);
        bigData = null;
        UIHandler.sendMessage(msg, JsonPage.this);
      }
    }.start();
  }

  public void onClick(View v) {
    if (v.equals(llTitle.getBtnBack())) {
      finish();
    }
  }

  public boolean handleMessage(Message msg) {
    tvJson.setText(msg.obj == null ? "" : (String) msg.obj);
    return false;
  }

  @SuppressWarnings("unchecked")
  private String format(String sepStr, HashMap<String, Object> map) {
    StringBuffer sb = new StringBuffer();
    sb.append("{\n");
    String mySepStr = sepStr + "\t";
    int i = 0;
    for (Entry<String, Object> entry : map.entrySet()) {
      if (i > 0) {
        sb.append(",\n");
      }
      sb.append(mySepStr).append('\"').append(entry.getKey()).append("\":");
      Object value = entry.getValue();
      if (value instanceof HashMap<?, ?>) {
        sb.append(format(mySepStr, (HashMap<String, Object>)value));
      }
      else if (value instanceof ArrayList<?>) {
        sb.append(format(mySepStr, (ArrayList<Object>)value));
      }
      else if (value instanceof String) {
        sb.append('\"').append(value).append('\"');
      }
      else {
        sb.append(value);
      }
      i++;
    }
    sb.append('\n').append(sepStr).append('}');
    return sb.toString();
  }

  @SuppressWarnings("unchecked")
  private String format(String sepStr, ArrayList<Object> list) {
    StringBuffer sb = new StringBuffer();
    sb.append("[\n");
    String mySepStr = sepStr + "\t";
    int i = 0;
    for (Object value : list) {
      if (i > 0) {
        sb.append(",\n");
      }
      sb.append(mySepStr);
      if (value instanceof HashMap<?, ?>) {
        sb.append(format(mySepStr, (HashMap<String, Object>)value));
      }
      else if (value instanceof ArrayList<?>) {
        sb.append(format(mySepStr, (ArrayList<Object>)value));
      }
      else if (value instanceof String) {
        sb.append('\"').append(value).append('\"');
      }
      else {
        sb.append(value);
      }
      i++;
    }
    sb.append('\n').append(sepStr).append(']');
    return sb.toString();
  }

}




Java Source Code List

cn.sharesdk.demo.AuthPage.java
cn.sharesdk.demo.CustomShareFieldsPage.java
cn.sharesdk.demo.CustomerPage.java
cn.sharesdk.demo.DemoPage.java
cn.sharesdk.demo.GetInforPage.java
cn.sharesdk.demo.GetTokenPage.java
cn.sharesdk.demo.JsonPage.java
cn.sharesdk.demo.Laiwang.java
cn.sharesdk.demo.MainActivity.java
cn.sharesdk.demo.MainAdapter.java
cn.sharesdk.demo.MyAdapter.java
cn.sharesdk.demo.MyQZoneWebShareAdapter.java
cn.sharesdk.demo.OneKeyShareCallback.java
cn.sharesdk.demo.ShareContentCustomizeDemo.java
cn.sharesdk.demo.SlidingMenuPage.java
cn.sharesdk.demo.WechatPage.java
cn.sharesdk.demo.YixinPage.java
cn.sharesdk.demo.wxapi.WXEntryActivity.java
cn.sharesdk.demo.yxapi.YXEntryActivity.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.EditPageFakeActivity.java
cn.sharesdk.onekeyshare.EditPageFakeActivity.java
cn.sharesdk.onekeyshare.FollowerListFakeActivity.java
cn.sharesdk.onekeyshare.FollowerListFakeActivity.java
cn.sharesdk.onekeyshare.OnekeyShareTheme.java
cn.sharesdk.onekeyshare.OnekeyShareTheme.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PlatformListFakeActivity.java
cn.sharesdk.onekeyshare.PlatformListFakeActivity.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareCore.java
cn.sharesdk.onekeyshare.ShareCore.java
cn.sharesdk.onekeyshare.ThemeShareCallback.java
cn.sharesdk.onekeyshare.ThemeShareCallback.java
cn.sharesdk.onekeyshare.theme.classic.EditPage.java
cn.sharesdk.onekeyshare.theme.classic.EditPage.java
cn.sharesdk.onekeyshare.theme.classic.FollowListPage.java
cn.sharesdk.onekeyshare.theme.classic.FollowListPage.java
cn.sharesdk.onekeyshare.theme.classic.PlatformGridView.java
cn.sharesdk.onekeyshare.theme.classic.PlatformGridView.java
cn.sharesdk.onekeyshare.theme.classic.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.classic.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.EditPage.java
cn.sharesdk.onekeyshare.theme.skyblue.EditPage.java
cn.sharesdk.onekeyshare.theme.skyblue.FollowListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.FollowListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformGridViewAdapter.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformGridViewAdapter.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage.java
cn.sharesdk.socialization.sample.MainActivity.java
cn.sharesdk.socialization.sample.MyPlatform.java
cn.sharesdk.socialization.sample.wxapi.WXEntryActivity.java
cn.sharesdk.socialization.sample.yxapi.YXEntryActivity.java