cn.sharesdk.framework.utils.UIHandler Java Examples

The following examples show how to use cn.sharesdk.framework.utils.UIHandler. 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: PlatformGridView.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
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);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #2
Source File: OnekeyShare.java    From ShareSDKShareDifMsgDemo-Android with MIT License 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
	try {
		Context app = getContext().getApplicationContext();
		NotificationManager nm = (NotificationManager) app
				.getSystemService(Context.NOTIFICATION_SERVICE);
		final int id = Integer.MAX_VALUE / 13 + 1;
		nm.cancel(id);

		long when = System.currentTimeMillis();
		Notification notification = new Notification(notifyIcon, text, when);
		PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
		notification.setLatestEventInfo(app, notifyTitle, text, pi);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
		nm.notify(id, notification);

		if (cancelTime > 0) {
			Message msg = new Message();
			msg.what = MSG_CANCEL_NOTIFY;
			msg.obj = nm;
			msg.arg1 = id;
			UIHandler.sendMessageDelayed(msg, cancelTime, this);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #3
Source File: PlatformGridView.java    From -Android_ShareSDK_Example_Wechat with MIT License 6 votes vote down vote up
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() {
			platformList = ShareSDK.getPlatformList(context);
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #4
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
	try {
		Context app = getContext().getApplicationContext();
		NotificationManager nm = (NotificationManager) app
				.getSystemService(Context.NOTIFICATION_SERVICE);
		final int id = Integer.MAX_VALUE / 13 + 1;
		nm.cancel(id);

		long when = System.currentTimeMillis();
		Notification notification = new Notification(notifyIcon, text, when);
		PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
		notification.setLatestEventInfo(app, notifyTitle, text, pi);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
		nm.notify(id, notification);

		if (cancelTime > 0) {
			Message msg = new Message();
			msg.what = MSG_CANCEL_NOTIFY;
			msg.obj = nm;
			msg.arg1 = id;
			UIHandler.sendMessageDelayed(msg, cancelTime, this);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #5
Source File: OnekeyShare.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
	try {
		Context app = getContext().getApplicationContext();
		NotificationManager nm = (NotificationManager) app
				.getSystemService(Context.NOTIFICATION_SERVICE);
		final int id = Integer.MAX_VALUE / 13 + 1;
		nm.cancel(id);

		long when = System.currentTimeMillis();
		Notification notification = new Notification(notifyIcon, text, when);
		PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
		notification.setLatestEventInfo(app, notifyTitle, text, pi);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
		nm.notify(id, notification);

		if (cancelTime > 0) {
			Message msg = new Message();
			msg.what = MSG_CANCEL_NOTIFY;
			msg.obj = nm;
			msg.arg1 = id;
			UIHandler.sendMessageDelayed(msg, cancelTime, this);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #6
Source File: PlatformGridView.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
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);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #7
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
	try {
		Context app = getApplicationContext();
		NotificationManager nm = (NotificationManager) app
				.getSystemService(Context.NOTIFICATION_SERVICE);
		final int id = Integer.MAX_VALUE / 13 + 1;
		nm.cancel(id);

		long when = System.currentTimeMillis();
		Notification notification = new Notification(R.drawable.ic_launcher, text, when);
		PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
		notification.setLatestEventInfo(app, "sharesdk test", text, pi);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
		nm.notify(id, notification);

		if (cancelTime > 0) {
			Message msg = new Message();
			msg.what = MSG_CANCEL_NOTIFY;
			msg.obj = nm;
			msg.arg1 = id;
			UIHandler.sendMessageDelayed(msg, cancelTime, this);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #8
Source File: OnekeyShare.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
    try {
        Context app = getContext().getApplicationContext();
        NotificationManager nm = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
        final int id = Integer.MAX_VALUE / 13 + 1;
        nm.cancel(id);

        long when = System.currentTimeMillis();
        Notification notification = new Notification(notifyIcon, text, when);
        PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
        notification.setLatestEventInfo(app, notifyTitle, text, pi);
        notification.flags = Notification.FLAG_AUTO_CANCEL;
        nm.notify(id, notification);

        if (cancelTime > 0) {
            Message msg = new Message();
            msg.what = MSG_CANCEL_NOTIFY;
            msg.obj = nm;
            msg.arg1 = id;
            UIHandler.sendMessageDelayed(msg, cancelTime, this);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #9
Source File: PlatformGridView.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
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);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #10
Source File: OnekeyShare.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
private void showNotification(long cancelTime, String text) {
	try {
		Context app = getContext().getApplicationContext();
		NotificationManager nm = (NotificationManager) app
				.getSystemService(Context.NOTIFICATION_SERVICE);
		final int id = Integer.MAX_VALUE / 13 + 1;
		nm.cancel(id);

		long when = System.currentTimeMillis();
		Notification notification = new Notification(notifyIcon, text, when);
		PendingIntent pi = PendingIntent.getActivity(app, 0, new Intent(), 0);
		notification.setLatestEventInfo(app, notifyTitle, text, pi);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
		nm.notify(id, notification);

		if (cancelTime > 0) {
			Message msg = new Message();
			msg.what = MSG_CANCEL_NOTIFY;
			msg.obj = nm;
			msg.arg1 = id;
			UIHandler.sendMessageDelayed(msg, cancelTime, this);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #11
Source File: PlatformGridView.java    From WeCenterMobile-Android with GNU General Public License v2.0 6 votes vote down vote up
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);

	// 为了更好的ui效果,开启子线程获取平台列表
	new Thread() {
		public void run() {
			platformList = ShareSDK.getPlatformList();
			if (platformList == null) {
				platformList = new Platform[0];
			}
			UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
		}
	}.start();
}
 
Example #12
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
@Override
public void onError(Platform platform, int action, Throwable t) {
	//打印错误信息,print the error msg
	t.printStackTrace();
	//错误监听,handle the error msg
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);		
}
 
Example #13
Source File: FollowList.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
	ArrayList<Following> data = parseList(res);
	if (data != null && data.size() > 0) {
		curPage++;
		Message msg = new Message();
		msg.what = 1;
		msg.obj = data;
		UIHandler.sendMessage(msg, this);
	}
}
 
Example #14
Source File: OnekeyShare.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
    Message msg = new Message();
    msg.what = MSG_ACTION_CCALLBACK;
    msg.arg1 = 1;
    msg.arg2 = action;
    msg.obj = platform;
    UIHandler.sendMessage(msg, this);
}
 
Example #15
Source File: OnekeyShare.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public void onError(Platform platform, int action, Throwable t) {
    t.printStackTrace();

    Message msg = new Message();
    msg.what = MSG_ACTION_CCALLBACK;
    msg.arg1 = 2;
    msg.arg2 = action;
    msg.obj = t;
    UIHandler.sendMessage(msg, this);

    // 分享失败的统计
    ShareSDK.logDemoEvent(4, platform);
}
 
Example #16
Source File: OnekeyShare.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
public void onCancel(Platform platform, int action) {
    Message msg = new Message();
    msg.what = MSG_ACTION_CCALLBACK;
    msg.arg1 = 3;
    msg.arg2 = action;
    msg.obj = platform;
    UIHandler.sendMessage(msg, this);
}
 
Example #17
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
@Override
public void onCancel(Platform platform, int action) {
	//取消监听,handle the cancel msg
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #18
Source File: MainActivity.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
@Override
public void onComplete(Platform platform, int action, HashMap<String, Object> arg2) {
	//成功监听,handle the successful msg
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 1;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #19
Source File: FollowList.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
	ArrayList<Following> data = parseList(res);
	if (data != null && data.size() > 0) {
		curPage++;
		Message msg = new Message();
		msg.what = 1;
		msg.obj = data;
		UIHandler.sendMessage(msg, this);
	}
}
 
Example #20
Source File: FollowList.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
	ArrayList<Following> data = parseList(res);
	if (data != null && data.size() > 0) {
		curPage++;
		Message msg = new Message();
		msg.what = 1;
		msg.obj = data;
		UIHandler.sendMessage(msg, this);
	}
}
 
Example #21
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void onComplete(Platform platform, int action,
		HashMap<String, Object> res) {
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 1;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #22
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// a statistics of cancel sharing
	ShareSDK.logDemoEvent(4, platform);
}
 
Example #23
Source File: OnekeyShare.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void onCancel(Platform platform, int action) {
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #24
Source File: EditPage.java    From -Android_ShareSDK_Example_Wechat with MIT License 5 votes vote down vote up
public void onCreate() {
	if (reqData == null) {
		finish();
		return;
	}

	initPageView();
	activity.setContentView(llPage);
	onTextChanged(etContent.getText(), 0, etContent.length(), 0);

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

			ArrayList<Platform> list = new ArrayList<Platform>();
			for (Platform plat : platformList) {
				String name = plat.getName();
				if (ShareCore.isUseClientToShare(activity, 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(MSG_PLATFORM_LIST_GOT, EditPage.this);
		}
	}.start();
}
 
Example #25
Source File: SignupPage.java    From ThirdPartyLoginDemo with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
	switch (v.getId()) {
	case R.id.ll_back:
		this.finish();
		break;
	case R.id.tv_ensure:
		UIHandler.sendEmptyMessage(MSG_SHOW_TOAST, SignupPage.this);
		break;
	case R.id.rl_icon:
		//showChangeIconDialog();
		getPicture();
		break;
	case R.id.rl_name:
		showChangeInfo(ChangeUserType.USER_NAME);
		break;
	case R.id.rl_gender:
		showGerderDialog();
		break;
	case R.id.rl_note:
		showChangeInfo(ChangeUserType.USER_NOTE);
		break;
	case R.id.iv_user_icon:
		PicViewer pv = new PicViewer();
		pv.setImagePath(userInfo.getUserIcon());
		pv.show(activity, null);
		break;
	default:
		break;
	}		
}
 
Example #26
Source File: OnekeyShare.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
public void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}
 
Example #27
Source File: FollowList.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
	ArrayList<Following> data = parseList(res);
	if (data != null && data.size() > 0) {
		curPage++;
		Message msg = new Message();
		msg.what = 1;
		msg.obj = data;
		UIHandler.sendMessage(msg, this);
	}
}
 
Example #28
Source File: OnekeyShare.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
public void onComplete(Platform platform, int action,
		HashMap<String, Object> res) {
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 1;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}
 
Example #29
Source File: OnekeyShare.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
public void onError(Platform platform, int action, Throwable t) {
	t.printStackTrace();

	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 2;
	msg.arg2 = action;
	msg.obj = t;
	UIHandler.sendMessage(msg, this);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}
 
Example #30
Source File: OnekeyShare.java    From WeCenterMobile-Android with GNU General Public License v2.0 5 votes vote down vote up
public void onCancel(Platform platform, int action) {
	Message msg = new Message();
	msg.what = MSG_ACTION_CCALLBACK;
	msg.arg1 = 3;
	msg.arg2 = action;
	msg.obj = platform;
	UIHandler.sendMessage(msg, this);
}