Search in sources :

Example 11 with Platform

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

the class OnekeyShare method show.

public void show(Context context) {
    ShareSDK.initSDK(context);
    this.context = context;
    // 打开分享菜单的统计
    ShareSDK.logDemoEvent(1, null);
    // 若为“使用客户端分享”的平台,则直接分享,否则进入编辑页面
    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);
}
Also used : Platform(cn.sharesdk.framework.Platform) CustomPlatform(cn.sharesdk.framework.CustomPlatform) HashMap(java.util.HashMap) CustomPlatform(cn.sharesdk.framework.CustomPlatform)

Example 12 with Platform

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

the class PlatformGridViewAdapter method setData.

public void setData(Platform[] platforms, HashMap<String, String> hiddenPlatforms) {
    if (platforms == null)
        return;
    if (hiddenPlatforms != null && hiddenPlatforms.size() > 0) {
        ArrayList<Platform> ps = new ArrayList<Platform>();
        for (Platform p : platforms) {
            if (hiddenPlatforms.containsKey(p.getName())) {
                continue;
            }
            ps.add(p);
        }
        logos.addAll(ps);
    } else {
        logos.addAll(Arrays.asList(platforms));
    }
    checkedPositionList.clear();
    notifyDataSetChanged();
}
Also used : Platform(cn.sharesdk.framework.Platform) ArrayList(java.util.ArrayList)

Example 13 with Platform

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

the class PlatformGridViewAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (view == null) {
        view = LayoutInflater.from(context).inflate(getLayoutRes(context, "skyblue_share_platform_list_item"), null);
        viewHolder = new ViewHolder();
        viewHolder.checkedImageView = (ImageView) view.findViewById(getIdRes(context, "checkedImageView"));
        viewHolder.logoImageView = (ImageView) view.findViewById(getIdRes(context, "logoImageView"));
        viewHolder.nameTextView = (TextView) view.findViewById(getIdRes(context, "nameTextView"));
        view.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) view.getTag();
    }
    Bitmap logo;
    String label;
    Object item = getItem(position);
    boolean disabled;
    boolean isDirectShare = item instanceof Platform ? ShareCore.isDirectShare((Platform) item) : true;
    if (directOnlyPosition == -1) {
        disabled = !checkedPositionList.isEmpty() && isDirectShare;
    } else {
        disabled = position != directOnlyPosition;
    }
    if (item instanceof Platform) {
        logo = getIcon((Platform) item, disabled ? "" : "_checked");
        label = getName((Platform) item);
        view.setOnClickListener(this);
    } else {
        CustomerLogo customerLogo = (CustomerLogo) item;
        logo = disabled ? customerLogo.disableLogo : customerLogo.enableLogo;
        label = customerLogo.label;
        view.setOnClickListener(this);
    //TODO 需要整理
    //	view.setOnClickListener(((CustomerLogo) item).listener);
    }
    String checkedResName = directOnlyPosition != -1 && directOnlyPosition != position ? "skyblue_platform_checked_disabled" : "skyblue_platform_checked";
    viewHolder.position = position;
    viewHolder.checkedImageView.setImageBitmap(BitmapFactory.decodeResource(context.getResources(), getBitmapRes(context, checkedResName)));
    viewHolder.checkedImageView.setVisibility(checkedPositionList.contains(viewHolder.position) ? View.VISIBLE : View.GONE);
    viewHolder.nameTextView.setText(label);
    viewHolder.logoImageView.setImageBitmap(logo);
    return view;
}
Also used : Bitmap(android.graphics.Bitmap) Platform(cn.sharesdk.framework.Platform) CustomerLogo(cn.sharesdk.onekeyshare.CustomerLogo)

Example 14 with Platform

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

the class PlatformListPage method initView.

private void initView() {
    View backImageView = findViewByResName("backImageView");
    backImageView.setTag(android.R.string.cancel);
    backImageView.setOnClickListener(this);
    View okImageView = findViewByResName("okImageView");
    okImageView.setTag(android.R.string.ok);
    okImageView.setOnClickListener(this);
    gridViewAdapter = new PlatformGridViewAdapter(activity);
    gridViewAdapter.setCustomerLogos(customerLogos);
    GridView gridView = (GridView) findViewByResName("gridView");
    gridView.setAdapter(gridViewAdapter);
    new AsyncTask<Void, Void, Platform[]>() {

        @Override
        protected Platform[] doInBackground(Void... params) {
            return ShareSDK.getPlatformList();
        }

        @Override
        protected void onPostExecute(Platform[] platforms) {
            gridViewAdapter.setData(platforms, hiddenPlatforms);
        }
    }.execute();
}
Also used : Platform(cn.sharesdk.framework.Platform) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View)

Example 15 with Platform

use of cn.sharesdk.framework.Platform in project AnimeTaste by daimajia.

the class ShareHelper method showUp.

public static void showUp(final Context context, final Animation animation) {
    View v = LayoutInflater.from(context).inflate(R.layout.layout_share, null, false);
    final MaterialDialog dialog = new MaterialDialog.Builder(context).customView(v, false).build();
    dialog.show();
    ShareSDK.initSDK(context);
    ShareButton weibo = (ShareButton) v.findViewById(R.id.action_share_weibo);
    ShareButton wechat = (ShareButton) v.findViewById(R.id.action_share_wechat);
    ShareButton wechatTimeline = (ShareButton) v.findViewById(R.id.action_share_wechat_timeline);
    ShareButton qq = (ShareButton) v.findViewById(R.id.action_share_qq);
    ShareButton link = (ShareButton) v.findViewById(R.id.action_share_link);
    ShareButton qzone = (ShareButton) v.findViewById(R.id.action_share_qzone);
    TextView cancel = (TextView) v.findViewById(R.id.cancel);
    final Handler showMsg = new Handler(new Handler.Callback() {

        @Override
        public boolean handleMessage(Message msg) {
            Toast.makeText(context, msg.obj.toString(), Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    final PlatformActionListener platformActionListener = new PlatformActionListener() {

        @Override
        public void onComplete(Platform platform, int i, HashMap<String, Object> stringObjectHashMap) {
            Message msg = Message.obtain(showMsg);
            msg.obj = "(๑•̀ㅂ•́)و分享成功!Ye";
            msg.sendToTarget();
        }

        @Override
        public void onError(Platform platform, int i, Throwable throwable) {
            Log.e("Error", throwable.getMessage());
            Message msg = Message.obtain(showMsg);
            msg.obj = "(⊙﹏⊙) 好像出了错误";
            msg.sendToTarget();
        }

        @Override
        public void onCancel(Platform platform, int i) {
            Message msg = Message.obtain(showMsg);
            msg.obj = "o(TヘTo) 取消了耶...";
            msg.sendToTarget();
        }
    };
    weibo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SinaWeibo.ShareParams sp = new SinaWeibo.ShareParams();
            Platform pf = ShareSDK.getPlatform(context, SinaWeibo.NAME);
            String toSend = "「" + animation.Name + "」 " + animation.OriginVideoUrl + " " + animation.Brief;
            toSend = toSend.substring(0, 140);
            sp.setText(toSend);
            sp.setUrl(animation.OriginVideoUrl);
            sp.setImageUrl(animation.DetailPic);
            pf.setPlatformActionListener(platformActionListener);
            pf.share(sp);
            shareAction(context, dialog);
        }
    });
    wechat.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Platform plat = ShareSDK.getPlatform(context, Wechat.NAME);
            Wechat.ShareParams sp = new Wechat.ShareParams();
            sp.setTitle(animation.Name);
            sp.setText(animation.Brief);
            sp.setImageUrl(animation.HomePic);
            sp.setUrl(animation.getShareUrl());
            sp.setShareType(Platform.SHARE_WEBPAGE);
            plat.setPlatformActionListener(platformActionListener);
            plat.share(sp);
            shareAction(context, dialog);
        }
    });
    wechatTimeline.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Platform plat = ShareSDK.getPlatform(context, WechatMoments.NAME);
            WechatMoments.ShareParams sp = new WechatMoments.ShareParams();
            sp.title = animation.Name;
            sp.text = animation.Brief;
            sp.imageUrl = animation.HomePic;
            sp.url = animation.getShareUrl();
            sp.shareType = Platform.SHARE_WEBPAGE;
            plat.setPlatformActionListener(platformActionListener);
            plat.share(sp);
            shareAction(context, dialog);
        }
    });
    qq.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Platform plat = ShareSDK.getPlatform(context, QQ.NAME);
            QQ.ShareParams sp = new QQ.ShareParams();
            sp.setTitle(animation.Name);
            sp.setText(animation.Brief);
            sp.setImageUrl(animation.HomePic);
            sp.setTitleUrl(animation.getShareUrl());
            sp.setShareType(QQ.SHARE_WEBPAGE);
            plat.setPlatformActionListener(platformActionListener);
            plat.share(sp);
            shareAction(context, dialog);
        }
    });
    qzone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Platform plat = ShareSDK.getPlatform(context, QZone.NAME);
            QZone.ShareParams sp = new QZone.ShareParams();
            sp.setTitle(animation.Name);
            sp.setText(animation.Brief);
            sp.setImageUrl(animation.HomePic);
            sp.setTitleUrl(animation.getShareUrl());
            sp.setShareType(QZone.SHARE_WEBPAGE);
            plat.setPlatformActionListener(platformActionListener);
            plat.share(sp);
            shareAction(context, dialog);
        }
    });
    link.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int sdk = android.os.Build.VERSION.SDK_INT;
            if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
                android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
                clipboard.setText(animation.getShareUrl());
            } else {
                android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
                android.content.ClipData clip = android.content.ClipData.newPlainText("data", animation.getShareUrl());
                clipboard.setPrimaryClip(clip);
            }
            dialog.dismiss();
            Toast.makeText(context, "复制完成,快快分享给你的好朋友们!", Toast.LENGTH_LONG).show();
        }
    });
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}
Also used : Message(android.os.Message) Platform(cn.sharesdk.framework.Platform) HashMap(java.util.HashMap) SinaWeibo(cn.sharesdk.sina.weibo.SinaWeibo) TextView(android.widget.TextView) Context(android.content.Context) ShareButton(com.zhan_dui.utils.ShareButton) QQ(cn.sharesdk.tencent.qq.QQ) PlatformActionListener(cn.sharesdk.framework.PlatformActionListener) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Handler(android.os.Handler) TextView(android.widget.TextView) View(android.view.View) Wechat(cn.sharesdk.wechat.friends.Wechat) WechatMoments(cn.sharesdk.wechat.moments.WechatMoments) QZone(cn.sharesdk.tencent.qzone.QZone)

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