private void initPageView() {
    flPage = new FrameLayout(getContext());
    flPage.setOnClickListener(this);

    // 宫格列表的容器,为了“下对齐”,在外部包含了一个FrameLayout
    LinearLayout llPage =
        new LinearLayout(getContext()) {
          public boolean onTouchEvent(MotionEvent event) {
            return true;
          }
        };
    llPage.setOrientation(LinearLayout.VERTICAL);
    int resId = getBitmapRes(getContext(), "share_vp_back");
    if (resId > 0) {
      llPage.setBackgroundResource(resId);
    }
    FrameLayout.LayoutParams lpLl =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpLl.gravity = Gravity.BOTTOM;
    llPage.setLayoutParams(lpLl);
    flPage.addView(llPage);

    // 宫格列表
    grid = new PlatformGridView(getContext());
    grid.setEditPageBackground(bgView);
    LinearLayout.LayoutParams lpWg =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    grid.setLayoutParams(lpWg);
    llPage.addView(grid);

    // 取消按钮
    btnCancel = new Button(getContext());
    btnCancel.setTextColor(0xffffffff);
    btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    resId = getStringRes(getContext(), "cancel");
    if (resId > 0) {
      btnCancel.setText(resId);
    }
    btnCancel.setPadding(0, 0, 0, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 5));
    resId = getBitmapRes(getContext(), "btn_cancel_back");
    if (resId > 0) {
      btnCancel.setBackgroundResource(resId);
    }
    LinearLayout.LayoutParams lpBtn =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, cn.sharesdk.framework.utils.R.dipToPx(getContext(), 45));
    int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10);
    lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
    btnCancel.setLayoutParams(lpBtn);
    llPage.addView(btnCancel);
  }
 public void onConfigurationChanged(Configuration newConfig) {
   if (grid != null) {
     grid.onConfigurationChanged();
   }
 }
  public void onCreate() {
    // 显示方式是由platform和silent两个字段控制的
    // 如果platform设置了,则无须显示九宫格,否则都会显示;
    // 如果silent为true,表示不进入编辑页面,否则会进入。
    // 本类只判断platform,因为九宫格显示以后,事件交给PlatformGridView控制
    // 当platform和silent都为true,则直接进入分享;
    // 当platform设置了,但是silent为false,则判断是否是“使用客户端分享”的平台,
    // 若为“使用客户端分享”的平台,则直接分享,否则进入编辑页面
    HashMap<String, Object> copy = new HashMap<String, Object>();
    copy.putAll(reqMap);
    if (copy.containsKey("platform")) {
      String name = String.valueOf(copy.get("platform"));
      if (silent) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(ShareSDK.getPlatform(name), copy);
        share(shareData);
      } else if (ShareCore.isUseClientToShare(name)) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(ShareSDK.getPlatform(name), copy);
        share(shareData);
      } else {
        Platform pp = ShareSDK.getPlatform(name);
        if (pp instanceof CustomPlatform) {
          HashMap<Platform, HashMap<String, Object>> shareData =
              new HashMap<Platform, HashMap<String, Object>>();
          shareData.put(ShareSDK.getPlatform(name), copy);
          share(shareData);
        } else {
          EditPage page = new EditPage();
          page.setBackGround(bgView);
          bgView = null;
          page.setShareData(copy);
          if (dialogMode) {
            page.setDialogMode();
          }
          page.showForResult(
              activity,
              null,
              new FakeActivity() {
                public void onResult(HashMap<String, Object> data) {
                  if (data != null && data.containsKey("editRes")) {
                    @SuppressWarnings("unchecked")
                    HashMap<Platform, HashMap<String, Object>> editRes =
                        (HashMap<Platform, HashMap<String, Object>>) data.get("editRes");
                    share(editRes);
                  }
                }
              });
        }
      }
      finish();
      return;
    }

    finishing = false;
    canceled = false;
    initPageView();
    initAnim();
    activity.setContentView(flPage);

    // 设置宫格列表数据
    grid.setData(copy, silent);
    grid.setHiddenPlatforms(hiddenPlatforms);
    grid.setCustomerLogos(customers);
    grid.setParent(this);
    btnCancel.setOnClickListener(this);

    // 显示列表
    flPage.clearAnimation();
    flPage.startAnimation(animShow);

    // 打开分享菜单的统计
    ShareSDK.logDemoEvent(1, null);
  }