Search in sources :

Example 6 with Platform

use of cn.sharesdk.framework.Platform in project nmid-headline by miao1007.

the class NavigationDrawerFragment method navigation_drawer_avatar.

@OnClick(R.id.navigation_drawer_avatar)
void navigation_drawer_avatar() {
    ShareSDK.initSDK(getActivity());
    Platform qzone = ShareSDK.getPlatform(getActivity().getApplicationContext(), QZone.NAME);
    qzone.SSOSetting(false);
    qzone.setPlatformActionListener(this);
    qzone.authorize();
    if (mDrawerLayout != null) {
        mDrawerLayout.closeDrawer(Gravity.START);
    }
}
Also used : Platform(cn.sharesdk.framework.Platform) OnClick(butterknife.OnClick)

Example 7 with Platform

use of cn.sharesdk.framework.Platform in project nmid-headline by miao1007.

the class ShareCore method isUseClientToShare.

/** 判断指定平台是否使用客户端分享 */
public static boolean isUseClientToShare(String platform) {
    if ("Wechat".equals(platform) || "WechatMoments".equals(platform) || "WechatFavorite".equals(platform) || "ShortMessage".equals(platform) || "Email".equals(platform) || "GooglePlus".equals(platform) || "QQ".equals(platform) || "Pinterest".equals(platform) || "Instagram".equals(platform) || "Yixin".equals(platform) || "YixinMoments".equals(platform) || "QZone".equals(platform) || "Mingdao".equals(platform) || "Line".equals(platform) || "KakaoStory".equals(platform) || "KakaoTalk".equals(platform) || "Bluetooth".equals(platform) || "WhatsApp".equals(platform) || "BaiduTieba".equals(platform) || "Laiwang".equals(platform) || "LaiwangMoments".equals(platform)) {
        return true;
    } else if ("Evernote".equals(platform)) {
        Platform plat = ShareSDK.getPlatform(platform);
        if ("true".equals(plat.getDevinfo("ShareByAppClient"))) {
            return true;
        }
    } else if ("SinaWeibo".equals(platform)) {
        Platform plat = ShareSDK.getPlatform(platform);
        if ("true".equals(plat.getDevinfo("ShareByAppClient"))) {
            Intent test = new Intent(Intent.ACTION_SEND);
            test.setPackage("com.sina.weibo");
            test.setType("image/*");
            ResolveInfo ri = plat.getContext().getPackageManager().resolveActivity(test, 0);
            return (ri != null);
        }
    }
    return false;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) Intent(android.content.Intent)

Example 8 with Platform

use of cn.sharesdk.framework.Platform in project nmid-headline by miao1007.

the class EditPage method onClick.

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);
    }
}
Also used : Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) FrameLayout(android.widget.FrameLayout)

Example 9 with Platform

use of cn.sharesdk.framework.Platform in project nmid-headline by miao1007.

the class EditPage method afterPlatformListGot.

/** display platform list */
public void afterPlatformListGot() {
    int size = platformList == null ? 0 : platformList.length;
    views = new View[size];
    final int dp_24 = dipToPx(getContext(), 24);
    LayoutParams lpItem = new 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 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);
        String platformName = platformList[i].getName();
        for (Platform plat : platforms) {
            if (platformName.equals(plat.getName())) {
                views[i].setVisibility(View.INVISIBLE);
                selection = 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;
        }
    });
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Callback(android.os.Handler.Callback) Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) Message(android.os.Message) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) BitmapHelper.captureView(com.mob.tools.utils.BitmapHelper.captureView) HorizontalScrollView(android.widget.HorizontalScrollView)

Example 10 with Platform

use of cn.sharesdk.framework.Platform in project nmid-headline by miao1007.

the class EditPageFakeActivity method setResultAndFinish.

protected void setResultAndFinish() {
    ArrayList<String> imageArray = new ArrayList<String>();
    if (shareImageList != null) {
        for (ImageInfo imageInfo : shareImageList) {
            if ("imagePath".equals(imageInfo.paramName) || "imageUrl".equals(imageInfo.paramName)) {
                shareParamMap.put(imageInfo.paramName, imageInfo.srcValue);
            } else if ("viewToShare".equals(imageInfo.paramName)) {
                shareParamMap.put(imageInfo.paramName, imageInfo.bitmap);
            } else if ("imageArray".equals(imageInfo.paramName)) {
                imageArray.add(imageInfo.srcValue);
            }
        }
        shareImageList.clear();
        if (imageArray.size() == 0) {
            shareParamMap.put("imageArray", null);
        } else {
            shareParamMap.put("imageArray", imageArray.toArray(new String[imageArray.size()]));
        }
    }
    HashMap<Platform, HashMap<String, Object>> editRes = new HashMap<Platform, HashMap<String, Object>>();
    for (Platform platform : platforms) {
        if ("FacebookMessenger".equals(platform.getName())) {
            HashMap<String, Object> param = new HashMap<String, Object>(shareParamMap);
            if (toFriendList != null && toFriendList.size() > 0) {
                param.put("address", toFriendList.get(toFriendList.size() - 1));
            }
            if (param.get("address") == null) {
                int resId = getStringRes(activity, "select_a_friend");
                if (resId > 0) {
                    Toast.makeText(getContext(), activity.getString(resId) + " - " + platform.getName(), Toast.LENGTH_SHORT).show();
                }
                return;
            }
            editRes.put(platform, param);
            // a statistics of Sharing
            ShareSDK.logDemoEvent(3, platform);
            continue;
        }
        // a statistics of Sharing
        ShareSDK.logDemoEvent(3, platform);
        editRes.put(platform, shareParamMap);
    }
    HashMap<String, Object> res = new HashMap<String, Object>();
    res.put("editRes", editRes);
    setResult(res);
    finish();
}
Also used : Platform(cn.sharesdk.framework.Platform) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

Platform (cn.sharesdk.framework.Platform)15 HashMap (java.util.HashMap)6 CustomPlatform (cn.sharesdk.framework.CustomPlatform)5 View (android.view.View)4 Message (android.os.Message)3 TextView (android.widget.TextView)3 ArrayList (java.util.ArrayList)3 Bitmap (android.graphics.Bitmap)2 FrameLayout (android.widget.FrameLayout)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 ImageView (android.widget.ImageView)2 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 Handler (android.os.Handler)1 Callback (android.os.Handler.Callback)1 OnClickListener (android.view.View.OnClickListener)1 GridView (android.widget.GridView)1 LinearLayout (android.widget.LinearLayout)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1