Search in sources :

Example 1 with Platform

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

the class PlatformGridView method init.

private void init(final Context context) {
    calPageSize();
    setOrientation(VERTICAL);
    pager = new ViewPagerClassic(context);
    disableOverScrollMode(pager);
    pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    addView(pager);
    // in order to have a better UI effect, opening a thread request the list of platforms
    new Thread() {

        public void run() {
            try {
                platformList = ShareSDK.getPlatformList();
                if (platformList == null) {
                    platformList = new Platform[0];
                }
                UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }.start();
}
Also used : Platform(cn.sharesdk.framework.Platform) ViewPagerClassic(com.mob.tools.gui.ViewPagerClassic)

Example 2 with Platform

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

the class EditPage method initAtUserView.

private void initAtUserView() {
    LinearLayout atLayout = (LinearLayout) findViewByResName("atLayout");
    for (Platform platform : platforms) {
        String platformName = platform.getName();
        if (isShowAtUserLayout(platformName)) {
            View view = LayoutInflater.from(activity).inflate(getLayoutRes(activity, "skyblue_editpage_at_layout"), null);
            TextView atDescTextView = (TextView) view.findViewById(getIdRes(activity, "atDescTextView"));
            TextView atTextView = (TextView) view.findViewById(getIdRes(activity, "atTextView"));
            OnClickListener atBtnClickListener = new OnClickListener() {

                public void onClick(View v) {
                    FollowListPage subPage = new FollowListPage();
                    subPage.setPlatform((Platform) v.getTag());
                    subPage.showForResult(activity, null, EditPage.this);
                }
            };
            atTextView.setTag(platform);
            atTextView.setOnClickListener(atBtnClickListener);
            atDescTextView.setTag(platform);
            atDescTextView.setOnClickListener(atBtnClickListener);
            atTextView.setText(getAtUserButtonText(platformName));
            atDescTextView.setText(getContext().getString(getStringRes(activity, "list_friends"), getLogoName(platformName)));
            atLayout.addView(view);
        }
    }
}
Also used : Platform(cn.sharesdk.framework.Platform) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 3 with Platform

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

the class OnekeyShare method share.

/** 循环执行分享 */
public void share(HashMap<Platform, HashMap<String, Object>> shareData) {
    boolean started = false;
    for (Entry<Platform, HashMap<String, Object>> ent : shareData.entrySet()) {
        Platform plat = ent.getKey();
        plat.SSOSetting(disableSSO);
        String name = plat.getName();
        //			boolean isGooglePlus = "GooglePlus".equals(name);
        //			if (isGooglePlus && !plat.isValid()) {
        //				Message msg = new Message();
        //				msg.what = MSG_TOAST;
        //				int resId = getStringRes(context, "google_plus_client_inavailable");
        //				msg.obj = context.getString(resId);
        //				UIHandler.sendMessage(msg, this);
        //				continue;
        //			}
        boolean isKakaoTalk = "KakaoTalk".equals(name);
        if (isKakaoTalk && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "kakaotalk_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        boolean isKakaoStory = "KakaoStory".equals(name);
        if (isKakaoStory && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "kakaostory_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        boolean isLine = "Line".equals(name);
        if (isLine && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "line_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        boolean isWhatsApp = "WhatsApp".equals(name);
        if (isWhatsApp && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "whatsapp_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        boolean isPinterest = "Pinterest".equals(name);
        if (isPinterest && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "pinterest_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        if ("Instagram".equals(name) && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "instagram_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        boolean isLaiwang = "Laiwang".equals(name);
        boolean isLaiwangMoments = "LaiwangMoments".equals(name);
        if (isLaiwang || isLaiwangMoments) {
            if (!plat.isClientValid()) {
                Message msg = new Message();
                msg.what = MSG_TOAST;
                int resId = getStringRes(context, "laiwang_client_inavailable");
                msg.obj = context.getString(resId);
                UIHandler.sendMessage(msg, this);
                continue;
            }
        }
        boolean isYixin = "YixinMoments".equals(name) || "Yixin".equals(name);
        if (isYixin && !plat.isClientValid()) {
            Message msg = new Message();
            msg.what = MSG_TOAST;
            int resId = getStringRes(context, "yixin_client_inavailable");
            msg.obj = context.getString(resId);
            UIHandler.sendMessage(msg, this);
            continue;
        }
        HashMap<String, Object> data = ent.getValue();
        int shareType = Platform.SHARE_TEXT;
        String imagePath = String.valueOf(data.get("imagePath"));
        if (imagePath != null && (new File(imagePath)).exists()) {
            shareType = Platform.SHARE_IMAGE;
            if (imagePath.endsWith(".gif")) {
                shareType = Platform.SHARE_EMOJI;
            } else if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
                shareType = Platform.SHARE_WEBPAGE;
                if (data.containsKey("musicUrl") && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
                    shareType = Platform.SHARE_MUSIC;
                }
            }
        } else {
            Bitmap viewToShare = (Bitmap) data.get("viewToShare");
            if (viewToShare != null && !viewToShare.isRecycled()) {
                shareType = Platform.SHARE_IMAGE;
                if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
                    shareType = Platform.SHARE_WEBPAGE;
                    if (data.containsKey("musicUrl") && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
                        shareType = Platform.SHARE_MUSIC;
                    }
                }
            } else {
                Object imageUrl = data.get("imageUrl");
                if (imageUrl != null && !TextUtils.isEmpty(String.valueOf(imageUrl))) {
                    shareType = Platform.SHARE_IMAGE;
                    if (String.valueOf(imageUrl).endsWith(".gif")) {
                        shareType = Platform.SHARE_EMOJI;
                    } else if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
                        shareType = Platform.SHARE_WEBPAGE;
                        if (data.containsKey("musicUrl") && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
                            shareType = Platform.SHARE_MUSIC;
                        }
                    }
                }
            }
        }
        data.put("shareType", shareType);
        if (!started) {
            started = true;
            //				if (this == callback) {
            int resId = getStringRes(context, "sharing");
            if (resId > 0) {
                showNotification(context.getString(resId));
            }
        //				}
        }
        plat.setPlatformActionListener(callback);
        ShareCore shareCore = new ShareCore();
        shareCore.setShareContentCustomizeCallback(customizeCallback);
        shareCore.share(plat, data);
    }
}
Also used : Bitmap(android.graphics.Bitmap) Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) Message(android.os.Message) HashMap(java.util.HashMap) File(java.io.File)

Example 4 with Platform

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

the class PlatformListFakeActivity method onShareButtonClick.

protected void onShareButtonClick(View v, List<Object> checkedPlatforms) {
    if (onShareButtonClickListener != null) {
        onShareButtonClickListener.onClick(v, checkedPlatforms);
    }
    HashMap<Platform, HashMap<String, Object>> silentShareData = new HashMap<Platform, HashMap<String, Object>>();
    final List<Platform> supportEditPagePlatforms = new ArrayList<Platform>();
    Platform plat;
    HashMap<String, Object> shareParam;
    for (Object item : checkedPlatforms) {
        if (item instanceof CustomerLogo) {
            CustomerLogo customerLogo = (CustomerLogo) item;
            customerLogo.listener.onClick(v);
            continue;
        }
        plat = (Platform) item;
        String name = plat.getName();
        // EditPage不支持微信平台、Google+、QQ分享、Pinterest、信息和邮件,总是执行直接分享
        if (silent || ShareCore.isDirectShare(plat)) {
            shareParam = new HashMap<String, Object>(shareParamsMap);
            shareParam.put("platform", name);
            silentShareData.put(plat, shareParam);
        } else {
            supportEditPagePlatforms.add(plat);
        }
    }
    if (silentShareData.size() > 0) {
        themeShareCallback.doShare(silentShareData);
    }
    // 跳转EditPage分享
    if (supportEditPagePlatforms.size() > 0) {
        showEditPage(supportEditPagePlatforms);
    }
    finish();
}
Also used : Platform(cn.sharesdk.framework.Platform) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 5 with Platform

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

the class PlatformListFakeActivity method showEditPage.

protected void showEditPage(Context context, List<Platform> platforms) {
    EditPageFakeActivity editPageFakeActivity;
    String editPageClass = ((Object) this).getClass().getPackage().getName() + ".EditPage";
    try {
        editPageFakeActivity = (EditPageFakeActivity) Class.forName(editPageClass).newInstance();
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    editPageFakeActivity.setBackgroundView(backgroundView);
    editPageFakeActivity.setShareData(shareParamsMap);
    editPageFakeActivity.setPlatforms(platforms);
    if (dialogMode) {
        editPageFakeActivity.setDialogMode();
    }
    editPageFakeActivity.showForResult(context, null, new FakeActivity() {

        public void onResult(HashMap<String, Object> data) {
            if (data == null)
                return;
            if (data.containsKey("editRes")) {
                @SuppressWarnings("unchecked") HashMap<Platform, HashMap<String, Object>> editRes = (HashMap<Platform, HashMap<String, Object>>) data.get("editRes");
                themeShareCallback.doShare(editRes);
            }
        }
    });
}
Also used : Platform(cn.sharesdk.framework.Platform) HashMap(java.util.HashMap) FakeActivity(com.mob.tools.FakeActivity)

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