public boolean onFinish() { if (finishing) { return super.onFinish(); } if (animHide == null) { finishing = true; super.finish(); return super.onFinish(); } // 取消分享菜单的统计 if (canceled) { ShareSDK.logDemoEvent(2, null); } finishing = true; animHide.setAnimationListener( new AnimationListener() { public void onAnimationStart(Animation animation) {} public void onAnimationRepeat(Animation animation) {} public void onAnimationEnd(Animation animation) { flPage.setVisibility(View.GONE); OnekeyShare.super.finish(); } }); flPage.clearAnimation(); flPage.startAnimation(animHide); return super.onFinish(); }
/** 显示平台列表 */ public void afterPlatformListGot() { String name = String.valueOf(reqData.get("platform")); int size = platformList == null ? 0 : platformList.length; views = new View[size]; final int dp_24 = dipToPx(getContext(), 24); LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_24, dp_24); final int dp_9 = dipToPx(getContext(), 9); lpItem.setMargins(0, 0, dp_9, 0); FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lpMask.gravity = Gravity.LEFT | Gravity.TOP; int selection = 0; for (int i = 0; i < size; i++) { FrameLayout fl = new FrameLayout(getContext()); fl.setLayoutParams(lpItem); if (i >= size - 1) { fl.setLayoutParams(new LinearLayout.LayoutParams(dp_24, dp_24)); } llPlat.addView(fl); fl.setOnClickListener(this); ImageView iv = new ImageView(getContext()); iv.setScaleType(ScaleType.CENTER_INSIDE); iv.setImageBitmap(getPlatLogo(platformList[i])); iv.setLayoutParams( new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); fl.addView(iv); views[i] = new View(getContext()); views[i].setBackgroundColor(0xcfffffff); views[i].setOnClickListener(this); if (name != null && name.equals(platformList[i].getName())) { views[i].setVisibility(View.INVISIBLE); selection = i; // 编辑分享内容的统计 ShareSDK.logDemoEvent(3, platformList[i]); } views[i].setLayoutParams(lpMask); fl.addView(views[i]); } final int postSel = selection; UIHandler.sendEmptyMessageDelayed( 0, 333, new Callback() { public boolean handleMessage(Message msg) { HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent(); hsv.scrollTo(postSel * (dp_24 + dp_9), 0); return false; } }); }
public void onError(Platform platform, int action, Throwable t) { t.printStackTrace(); Message msg = new Message(); msg.what = MSG_ACTION_CCALLBACK; msg.arg1 = 2; msg.arg2 = action; msg.obj = t; UIHandler.sendMessage(msg, this); // 分享失败的统计 ShareSDK.logDemoEvent(4, platform); }
public void onClick(View v) { if (v.equals(llTitle.getBtnBack())) { Platform plat = null; for (int i = 0; i < views.length; i++) { if (views[i].getVisibility() == View.INVISIBLE) { plat = platformList[i]; break; } } // a statistics of Cancel-sharing if (plat != null) { ShareSDK.logDemoEvent(5, plat); } finish(); return; } if (v.equals(llTitle.getBtnRight())) { String text = etContent.getText().toString(); shareParamMap.put("text", text); platforms.clear(); for (int i = 0; i < views.length; i++) { if (views[i].getVisibility() != View.VISIBLE) { platforms.add(platformList[i]); } } if (platforms.size() > 0) { setResultAndFinish(); } else { int resId = getStringRes(activity, "select_one_plat_at_least"); if (resId > 0) { Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show(); } } return; } if (v instanceof FrameLayout) { ((FrameLayout) v).getChildAt(1).performClick(); return; } if (v.getVisibility() == View.INVISIBLE) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.INVISIBLE); } }
public void onClick(View v) { if (v.getTag() == null) return; String tag = (String) v.getTag(); if (tag.equals("close")) { // 取消分享的统计 for (Platform plat : platforms) { ShareSDK.logDemoEvent(5, plat); } finish(); return; } if (tag.equals("ok")) { onShareButtonClick(v); return; } }
public void onError(Platform platform, int action, Throwable t) { t.printStackTrace(); Message msg = new Message(); msg.what = MSG_ACTION_CCALLBACK; msg.arg1 = 2; msg.arg2 = action; msg.obj = t; try { UIHandler.sendMessage(msg, this); } catch (NullPointerException e) { // TODO: handle exception } // 分享失败的统计 ShareSDK.logDemoEvent(4, platform); }
public void show(Context context) { ShareSDK.initSDK(context); this.context = context; // 打开分享菜单的统计 ShareSDK.logDemoEvent(1, null); // 显示方式是由platform和silent两个字段控制的 // 如果platform设置了,则无须显示九宫格,否则都会显示; // 如果silent为true,表示不进入编辑页面,否则会进入。 // 本类只判断platform,因为九宫格显示以后,事件交给PlatformGridView控制 // 当platform和silent都为true,则直接进入分享; // 当platform设置了,但是silent为false,则判断是否是“使用客户端分享”的平台, // 若为“使用客户端分享”的平台,则直接分享,否则进入编辑页面 if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); if (silent || ShareCore.isUseClientToShare(name) || platform instanceof CustomPlatform) { HashMap<Platform, HashMap<String, Object>> shareData = new HashMap<Platform, HashMap<String, Object>>(); shareData.put(ShareSDK.getPlatform(name), shareParamsMap); share(shareData); return; } } PlatformListFakeActivity platformListFakeActivity; try { if (OnekeyShareTheme.SKYBLUE == theme) { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage") .newInstance(); } else { platformListFakeActivity = (PlatformListFakeActivity) Class.forName("cn.sharesdk.onekeyshare.theme.classic.PlatformListPage") .newInstance(); } } catch (Exception e) { e.printStackTrace(); return; } platformListFakeActivity.setDialogMode(dialogMode); platformListFakeActivity.setShareParamsMap(shareParamsMap); platformListFakeActivity.setSilent(silent); platformListFakeActivity.setCustomerLogos(customers); platformListFakeActivity.setBackgroundView(bgView); platformListFakeActivity.setHiddenPlatforms(hiddenPlatforms); platformListFakeActivity.setOnShareButtonClickListener(onShareButtonClickListener); platformListFakeActivity.setThemeShareCallback( new ThemeShareCallback() { @Override public void doShare(HashMap<Platform, HashMap<String, Object>> shareData) { share(shareData); } }); if (shareParamsMap.containsKey("platform")) { String name = String.valueOf(shareParamsMap.get("platform")); Platform platform = ShareSDK.getPlatform(name); platformListFakeActivity.showEditPage(context, platform); return; } platformListFakeActivity.show(context, null); }
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); }
public void onClick(View v) { if (v.equals(llTitle.getBtnBack())) { Platform plat = null; for (int i = 0; i < views.length; i++) { if (views[i].getVisibility() == View.INVISIBLE) { plat = platformList[i]; break; } } // 取消分享的统计 if (plat != null) { ShareSDK.logDemoEvent(5, plat); } finish(); return; } // 取消分享的统计 if (v.equals(llTitle.getBtnRight())) { String text = etContent.getText().toString(); reqData.put("text", text); if (!shareImage) { if (reqData.get("imagePath") == null) { reqData.put("viewToShare", null); reqData.put("imageUrl", null); } else if (reqData.get("imageUrl") == null) { reqData.put("imagePath", null); reqData.put("viewToShare", null); } else { reqData.put("imageUrl", null); reqData.put("imagePath", null); } } HashMap<Platform, HashMap<String, Object>> editRes = new HashMap<Platform, HashMap<String, Object>>(); boolean selected = false; for (int i = 0; i < views.length; i++) { if (views[i].getVisibility() != View.VISIBLE) { editRes.put(platformList[i], reqData); selected = true; } } if (selected) { HashMap<String, Object> res = new HashMap<String, Object>(); res.put("editRes", editRes); setResult(res); finish(); } else { int resId = getStringRes(activity, "select_one_plat_at_least"); if (resId > 0) { Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show(); } } return; } if (v instanceof FrameLayout) { ((FrameLayout) v).getChildAt(1).performClick(); return; } if (v.getVisibility() == View.INVISIBLE) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.INVISIBLE); } }