private void getFacebookFriends(Message callback) { SocialORM.Account account = orm.getFacebookAccount(); if (mContext.checkFacebookAccount(mContext, account)) { // perm = null; if (perm == null) { perm = loginHelper.getPermanentSesstion(); } if (perm != null) { if (facebookA == null) { facebookA = new AsyncFacebook(perm); } facebookA.setSession(perm); final Message callMsg = callback; long hisuid = -1; if (callMsg != null) { hisuid = callMsg.getData().getLong("hisuid", -1); } if (hisuid == -1) { hisuid = perm.getLogerInUserID(); } else { Log.d(TAG, "begin to get who's friends list=" + hisuid); } facebookA.getMyFriendsAsync( hisuid, limit, offset, userHander, new FacebookAdapter() { @Override public void getMyFriends(int size) { Log.d(TAG, "friend size=" + size); orm.checkNoneFriends(); Message msd = handler.obtainMessage(FACEBOOK_FRIENDS_GET_END); msd.getData().putBoolean("RESULT", true); msd.getData().putInt("size", size); msd.getData().putParcelable(CALLBACK, callMsg); handler.sendMessage(msd); } @Override public void onException(FacebookException e, int method) { Log.d(TAG, "fail to get basic friends information"); Message msd = handler.obtainMessage(FACEBOOK_FRIENDS_GET_END); msd.getData().putBoolean("RESULT", false); msd.getData().putParcelable(CALLBACK, callMsg); handler.sendMessage(msd); } }); } else { mContext.needLogin(); } } }
// contact should be get at the first time public void Start() { Log.d(TAG, "start contact service"); // this is not right, if reboot again, it will do it again, // we need record the last time, then calculate the next time to to. // perm = loginHelper.getPermanentSesstion(); // don't show the dialog for emulator if ( /*SNSService.TEST_LOOP ||*/ perm != null) { rescheduleFacebookUser(false); } }
public void onLogin() { perm = null; perm = loginHelper.getPermanentSesstion(); if (perm != null) { if (facebookA == null) { facebookA = new AsyncFacebook(perm); } facebookA.setSession(perm); nErrorCount = 0; // after login rescheduleFacebookUser(true); } }
// notification should be get at the first time public void Start() { Log.d(TAG, "start NotificationService"); try { String ca = orm.getSettingValue("lastNotificationID"); if (ca != null && ca.length() > 0) lastNotificationID = Long.valueOf(ca); } catch (NumberFormatException ne) { } // this is not right, if reboot again, it will do it again, // we need record the last time, then calculate the next time to to. // perm = loginHelper.getPermanentSesstion(); if ( /*SNSService.TEST_LOOP || */ perm != null) { if (facebookA == null) { facebookA = new AsyncFacebook(perm); } facebookA.setSession(perm); rescheduleNotificationSync(true); } }