cn.sharesdk.onekeyshare.ShareCore Java Examples

The following examples show how to use cn.sharesdk.onekeyshare.ShareCore. 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: AuthPageAty.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
public AuthAdapter(Context context) {
	this.context = context;
	// 获取平台列表
	Platform[] tmp = ShareSDK.getPlatformList();
	platforms = new ArrayList<Platform>();
	if (tmp == null) {
		return;
	}

	for (Platform p : tmp) {
		String name = p.getName();
		if ((p instanceof CustomPlatform)
				|| !ShareCore.canAuthorize(p.getContext(), name)) {
			continue;
		}
		if (p.getName().equals(Wechat.NAME)){
			continue;
		}
		platforms.add(p);
	}
}
 
Example #2
Source File: PlatformGridViewAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View view) {
	ViewHolder viewHolder = (ViewHolder) view.getTag();
	Integer position = viewHolder.position;
	//直接分享平台选中后,其它的不可用
	if(directOnlyPosition != -1 && position != directOnlyPosition)
		return;

	Object item = getItem(position);
	boolean direct = false;
	//normal platform
	if(item instanceof Platform){
		direct = ShareCore.isDirectShare((Platform) item);
	}else{
		//自定义图标
		direct = true;
	}
	//EditPage Platforms only
	if(direct && directOnlyPosition == -1 && !checkedPositionList.isEmpty())
		return;

	if(checkedPositionList.contains(position)) {
		checkedPositionList.remove(position);
		if(direct)
			directOnlyPosition = -1;
	} else {
		checkedPositionList.add(position);
		if(direct)
			directOnlyPosition = position;
	}

	notifyDataSetChanged();
}
 
Example #3
Source File: PlatformGridViewAdapter.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View view) {
	ViewHolder viewHolder = (ViewHolder) view.getTag();
	Integer position = viewHolder.position;
	//直接分享平台选中后,其它的不可用
	if(directOnlyPosition != -1 && position != directOnlyPosition)
		return;

	Object item = getItem(position);
	boolean direct = false;
	//normal platform
	if(item instanceof Platform){
		direct = ShareCore.isDirectShare((Platform) item);
	}else{
		//自定义图标
		direct = true;
	}
	//EditPage Platforms only
	if(direct && directOnlyPosition == -1 && !checkedPositionList.isEmpty())
		return;

	if(checkedPositionList.contains(position)) {
		checkedPositionList.remove(position);
		if(direct)
			directOnlyPosition = -1;
	} else {
		checkedPositionList.add(position);
		if(direct)
			directOnlyPosition = position;
	}

	notifyDataSetChanged();
}
 
Example #4
Source File: PlatformGridViewAdapter.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example #5
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
public void onCreate() {
	if (shareParamMap == null || platforms == null || platforms.size() < 1) {
		finish();
		return;
	}

	genBackground();
	activity.setContentView(getPageView());
	onTextChanged(etContent.getText(), 0, etContent.length(), 0);
	showThumb();

	// requests platform list and remove platforms share in their clients
	new Thread(){
		public void run() {
			try {
				platformList = ShareSDK.getPlatformList();
				if (platformList == null) {
					return;
				}

				ArrayList<Platform> list = new ArrayList<Platform>();
				for (Platform plat : platformList) {
					String name = plat.getName();
					if ((plat instanceof CustomPlatform)
							|| ShareCore.isUseClientToShare(name)) {
						continue;
					}
					list.add(plat);
				}
				platformList = new Platform[list.size()];
				for (int i = 0; i < platformList.length; i++) {
					platformList[i] = list.get(i);
				}

				UIHandler.sendEmptyMessage(1, new Callback() {
					public boolean handleMessage(Message msg) {
						afterPlatformListGot();
						return false;
					}
				});
			} catch (Throwable t) {
				t.printStackTrace();
			}
		}
	}.start();
}
 
Example #6
Source File: PlatformGridViewAdapter.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example #7
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
public void onCreate() {
	if (shareParamMap == null || platforms == null || platforms.size() < 1) {
		finish();
		return;
	}

	genBackground();
	activity.setContentView(getPageView());
	onTextChanged(etContent.getText(), 0, etContent.length(), 0);
	showThumb();

	// requests platform list and remove platforms share in their clients
	new Thread(){
		public void run() {
			try {
				platformList = ShareSDK.getPlatformList();
				if (platformList == null) {
					return;
				}

				ArrayList<Platform> list = new ArrayList<Platform>();
				for (Platform plat : platformList) {
					String name = plat.getName();
					if ((plat instanceof CustomPlatform)
							|| ShareCore.isUseClientToShare(name)) {
						continue;
					}
					list.add(plat);
				}
				platformList = new Platform[list.size()];
				for (int i = 0; i < platformList.length; i++) {
					platformList[i] = list.get(i);
				}

				UIHandler.sendEmptyMessage(1, new Callback() {
					public boolean handleMessage(Message msg) {
						afterPlatformListGot();
						return false;
					}
				});
			} catch (Throwable t) {
				t.printStackTrace();
			}
		}
	}.start();
}