Esempio n. 1
0
  public void rescheduleFacebookUser(boolean force) {
    AlarmManager alarmMgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    long nexttime;

    long current_time = System.currentTimeMillis();
    long last_update_time = orm.getLastUpdateFriendTime();
    long donespan = (current_time - last_update_time);
    long left_time = getFriendsTimeout() * 1000L - donespan;
    if (donespan < 0 || left_time <= 0) {
      long waittime = 1;
      for (int i = 0; i < nErrorCount && i < 10; i++) {
        waittime = waittime * 2;
      }
      nexttime = System.currentTimeMillis() + 10 * 1000 * waittime;
    } else {
      nexttime = System.currentTimeMillis() + left_time;
    }

    if (force == true) {
      nexttime = System.currentTimeMillis() + 10 * 1000;
    }

    if (SNSService.TEST_LOOP) {
      nexttime = System.currentTimeMillis() + 90 * 1000;
    }

    Intent i = new Intent();
    i.setClassName("com.ast.free", "com.ast.free.service.SNSService");
    i.setAction("com.ast.free.intent.action.FACEBOOK_USER");
    PendingIntent userpi =
        PendingIntent.getService(
            mContext.getApplicationContext(), 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    alarmMgr.set(AlarmManager.RTC_WAKEUP, nexttime, userpi);
  }
Esempio n. 2
0
  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();
      }
    }
  }
Esempio n. 3
0
 private long getFriendsTimeout() {
   return orm.getFacebookFriendUpdatePeriod() * unit_period;
 }
Esempio n. 4
0
 public long getPhonebookTimeout() {
   return orm.getFacebookContactUpdatePeriod() * unit_period;
 }
Esempio n. 5
0
 // should move this to sql query
 public boolean isFriend(Context context) {
   SocialORM orm = SocialORM.instance(context);
   isfriend = orm.isFriends(uid);
   return isfriend;
 }