示例#1
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();
      }
    }
  }
示例#2
0
  public void loadAlbumPhotoInfo() {
    if (facebookA != null) {
      facebookA.batch_run_getFacebookAlbumAndPhotoAsync(
          perm.getLogerInUserID(),
          new FacebookAdapter() {
            @Override
            public void getFacebookAlbumAndPhoto(HashMap<Integer, Object> albumAndPhotos) {
              Log.d("ALBUM PHOTO", " get Album and Photo information successfylly ");
              if (albumAndPhotos.size() > 2) {
                List<PhotoAlbum> albums = (List<PhotoAlbum>) albumAndPhotos.get(0);
                List<Photo> photos = (List<Photo>) albumAndPhotos.get(1);
                List<StreamFilter> filters = (List<StreamFilter>) albumAndPhotos.get(2);

                orm.addAlbum(albums);
                orm.addPhoto(photos, true);
                orm.addStreamFilter(filters);
              }
            }

            @Override
            public void onException(FacebookException e, int method) {
              Log.d(TAG, "fail to get album and photo information exception " + e.getMessage());
            }
          });
    }
  }
示例#3
0
  private void getNotification() {
    if (facebookA == null) {
      Log.d(TAG, "no facebookA ");
      return;
    }
    facebookA.getNotificationListAsync(
        -1L,
        false,
        new FacebookAdapter() {
          @Override
          public void getNotificationList(Notifications notifications) {
            orm.setLastNotificationSyncTime(System.currentTimeMillis());
            nErrorCount = 0;
            Log.d(TAG, "after get notification =" + notifications.notificationlist.size());
            processNotify(notifications.notificationlist);

            Message msd = handler.obtainMessage(FACEBOOK_NOTIFY_SYNC_END);
            handler.sendMessage(msd);
          }

          @Override
          public void onException(FacebookException e, int method, Object[] args) {
            Log.d(TAG, "fail to get get notifcation=" + e.getMessage());

            nErrorCount++;
            Message msd = handler.obtainMessage(FACEBOOK_NOTIFY_SYNC_END);
            handler.sendMessage(msd);
          }
        });
  }
示例#4
0
  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);
    }
  }
示例#5
0
  // 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);
    }
  }