Java Code Examples for cn.sharesdk.framework.utils.UIHandler

The following examples show how to use cn.sharesdk.framework.utils.UIHandler. These examples are extracted from open source projects. 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 Project: Huochexing12306   Source File: OnekeyShare.java    License: 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 2
Source Project: Huochexing12306   Source File: PlatformGridView.java    License: 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 3
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 4
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 5
Source Project: ShareSDKShareDifMsgDemo-Android   Source File: OnekeyShare.java    License: 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 6
Source Project: ShareSDKShareDifMsgDemo-Android   Source File: PlatformGridView.java    License: 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 7
Source Project: AndroidLinkup   Source File: OnekeyShare.java    License: 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 8
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 9
Source Project: -Android_ShareSDK_Example_Wechat   Source File: MainActivity.java    License: 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 10
Source Project: -Android_ShareSDK_Example_Wechat   Source File: OnekeyShare.java    License: 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 11
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 12
Source Project: Huochexing12306   Source File: FollowList.java    License: 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 13
Source Project: Huochexing12306   Source File: OnekeyShare.java    License: Apache License 2.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 14
Source Project: Huochexing12306   Source File: OnekeyShare.java    License: 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 15
Source Project: Huochexing12306   Source File: OnekeyShare.java    License: Apache License 2.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 16
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 17
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 18
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 19
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 20
Source Project: ShareSDKShareDifMsgDemo-Android   Source File: FollowList.java    License: 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 Project: ShareSDKShareDifMsgDemo-Android   Source File: OnekeyShare.java    License: 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 Project: ShareSDKShareDifMsgDemo-Android   Source File: OnekeyShare.java    License: 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);

	// 分享失败的统计
	ShareSDK.logDemoEvent(4, platform);
}
 
Example 23
Source Project: ShareSDKShareDifMsgDemo-Android   Source File: OnekeyShare.java    License: 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 Project: AndroidLinkup   Source File: FollowList.java    License: 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 25
Source Project: AndroidLinkup   Source File: OnekeyShare.java    License: 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 26
Source Project: AndroidLinkup   Source File: OnekeyShare.java    License: 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 27
Source Project: AndroidLinkup   Source File: OnekeyShare.java    License: 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 28
Source Project: -Android_ShareSDK_Example_Wechat   Source File: MainActivity.java    License: 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 29
Source Project: -Android_ShareSDK_Example_Wechat   Source File: MainActivity.java    License: 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 30
Source Project: -Android_ShareSDK_Example_Wechat   Source File: MainActivity.java    License: 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);		
}