Java Code Examples for cn.bmob.v3.Bmob#getServerTime()

The following examples show how to use cn.bmob.v3.Bmob#getServerTime() . 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: TimeUtil.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public static void getServerTime() {
    Bmob.getServerTime(new QueryListener<Long>() {
        @Override
        public void done(Long aLong, BmobException e) {
            if (e == null) {
                long deltaTime = System.currentTimeMillis() - aLong * 1000L;
                LogUtil.e("客户端与服务器端的时间差值 :" + deltaTime);
                BaseApplication.getAppComponent().getSharedPreferences()
                        .edit().putLong(ConstantUtil.DELTA_TIME, deltaTime).apply();
            } else {
                LogUtil.e("获取服务器上的时间失败" + e.toString());
            }
        }
    });
}
 
Example 2
Source File: TimeUtil.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public static void getServerTime() {
        Bmob.getServerTime(CustomApplication.getInstance(), new GetServerTimeListener() {
                @Override
                public void onSuccess(long l) {
                        long deltaTime = System.currentTimeMillis() - l * 1000L;
                        LogUtil.e("客户端与服务器端的时间差值 :" + deltaTime);
                        CustomApplication.getInstance().getSharedPreferencesUtil().setDeltaTime(deltaTime);
                }

                @Override
                public void onFailure(int i, String s) {
                        LogUtil.e("获取服务器上的时间失败" + s + i);
                }
        });
}
 
Example 3
Source File: AnimatedEditText.java    From stynico with MIT License 4 votes vote down vote up
/**
     * 监视UI变更事件
     *
     * @param event AccessibilityEvent
     */
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event)
    {
	Bmob.getServerTime(this, new GetServerTimeListener() {

		@Override
		public void onSuccess(long time) {
		    // TODO Auto-generated method stub
		    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		    String times = formatter.format(new Date(time * 1000L));
		    //toast("当前服务器时间为:" + times);
		}

		@Override
		public void onFailure(int code, String msg) {
		}
	    });
	SharedPreferences sharedPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE); 
	boolean isFirstRun = sharedPreferences.getBoolean("ok_c", true); 
	//Editor editor = sharedPreferences.edit(); 
	if (isFirstRun) 
	{ 
	    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
	    builder.setSmallIcon(R.mipmap.ic_launcher);
	    builder.setContentTitle("妮媌");
	    builder.setContentText("微信抢红包正在运行");
	    builder.setOngoing(true);
	    Notification notification = builder.build();
	    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
	    manager.notify(NOTIFICATION_ID, notification);
	}
	else 
	{ 

	}
	
	if (mutex)
	{
	    //Log.w("onAccessibilityEvent", "MUTEX!");
	    return;
	}
	mutex = true;

	try
	{
//			Log.i("getPackageName", event.getPackageName().toString());
//			Log.i("getRecord", (event.getRecordCount()>0)?event.getRecord(0).toString():"null");
//			Log.i("getSource", (event.getSource() != null)?event.getSource().toString():"null");
//			Log.i("getText[]", (!event.getText().isEmpty()) ? event.getText().toString() : "[]");
	    process(event); // 测试表明source和record有参考价值
	}
	finally
	{
	    mutex = false;
	}

    }