Java Code Examples for cn.sharesdk.framework.Platform#isValid()

The following examples show how to use cn.sharesdk.framework.Platform#isValid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LevelTop.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
private void authorize(Platform plat) {
    try {
        // 先清除缓存账户
        // plat.getDb().removeAccount();

        if (plat.isValid()) {
            String userId = plat.getDb().getUserId();
            if (!TextUtils.isEmpty(userId)) {
                login(plat);
                return;
            }
        }
        plat.setPlatformActionListener(this);
        plat.SSOSetting(true);
        plat.showUser(null);
    } catch (Exception ex) {
        Log.d("LevelTop-authorize", ex.getMessage());
    }
}
 
Example 2
Source File: LoginActivity.java    From xmpp with Apache License 2.0 5 votes vote down vote up
/**
 * 新浪微博登录
 */
private void weibo_login() {
    Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
    if (weibo.isValid()) {
        weibo.removeAccount();
    }

    weibo.setPlatformActionListener(this); // 设置分享事件回调
    weibo.SSOSetting(true); // 设置false表示使用SSO授权方式
    // weibo.authorize();
    weibo.showUser(null);

}
 
Example 3
Source File: LoginActivity.java    From xmpp with Apache License 2.0 5 votes vote down vote up
/**
 * QQ登录
 */
private void qq_login() {
    Platform weibo = ShareSDK.getPlatform(QQ.NAME);
    if (weibo.isValid()) {
        weibo.removeAccount();//删除前一次的授权信息
    }

    weibo.setPlatformActionListener(this); // 设置分享事件回调

    // 设置false表示使用SSO授权方式,意思就是如果有QQ就直接跳到QQ授权,如果没有就跳到网页
    weibo.SSOSetting(false);


    weibo.showUser(null);
}
 
Example 4
Source File: DoLogin.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 第三方登录 发起
 *
 * @param context
 * @param platStr
 * @param callback
 */
public static void authorize(final FragmentActivity context, String platStr, Handler.Callback callback, InjectDo injectDo) {
    Platform plat = ShareSDK.getPlatform(context, platStr);
    ZogUtils.printError(LoginActivity.class, "authorize plat.getName():" + plat.getName());
    ZogUtils.printError(LoginActivity.class, "authorize plat.isValid():" + plat.isValid());

    if (plat.isValid()) {
        platformLogin(context, platStr, callback, injectDo);
    } else {
        LoginPlatformActionListener loginPlatformActionListener = new LoginPlatformActionListener(context, callback);
        plat.setPlatformActionListener(loginPlatformActionListener);
        plat.SSOSetting(true);
        plat.showUser(null);
    }
}
 
Example 5
Source File: AuthPageAty.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = View.inflate(context, R.layout.auth_page_item, null);
	}

	int count = getCount();
	View llItem = convertView.findViewById(R.id.llItem);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
	if (count == 1) {
		llItem.setBackgroundResource(R.drawable.list_item_single_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, dp_10);
	}
	else if (position == 0) {
		llItem.setBackgroundResource(R.drawable.list_item_first_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, 0);
	}
	else if (position == count - 1) {
		llItem.setBackgroundResource(R.drawable.list_item_last_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, dp_10);
	}
	else {
		llItem.setBackgroundResource(R.drawable.list_item_middle_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, 0);
	}

	Platform plat = getItem(position);
	ImageView ivLogo = (ImageView) convertView.findViewById(R.id.ivLogo);
	Bitmap logo = getIcon(plat);
	if (logo != null && !logo.isRecycled()) {
		ivLogo.setImageBitmap(logo);
	}
	CheckedTextView ctvName = (CheckedTextView) convertView.findViewById(R.id.ctvName);
	ctvName.setChecked(plat.isValid());
	if (plat.isValid()) {
		String userName = plat.getDb().get("nickname");
		if (userName == null || userName.length() <= 0 || "null".equals(userName)) {
			userName = getName(plat);
		}
		ctvName.setText(userName);
	} else {
		ctvName.setText(R.string.not_yet_authorized);
	}
	return convertView;
}