Esempio n. 1
0
  private void updateLastUpdateTime() {
    if (getView() != null) {
      TextView lastUpdated = (TextView) getView().findViewById(R.id.friends_last_updated);

      if (lastUpdated != null) {
        String lastUpdateText;
        mAccount.refresh(Preferences.get(getActivity()));

        if (mAccount.getLastFriendUpdate() < 1) {
          lastUpdateText = getString(R.string.not_yet_updated);
        } else {
          lastUpdateText =
              getString(
                  R.string.last_updated_f,
                  DateUtils.getRelativeDateTimeString(
                      getActivity(),
                      mAccount.getLastFriendUpdate(),
                      DateUtils.MINUTE_IN_MILLIS,
                      DateUtils.WEEK_IN_MILLIS,
                      0));
        }

        lastUpdated.setText(lastUpdateText);
      }
    }
  }
Esempio n. 2
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;

    XboxLiveFriendListItem item = (XboxLiveFriendListItem) acmi.targetView;
    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();
    menu.setHeaderTitle(vh.gamertag.getText());

    getActivity().getMenuInflater().inflate(R.menu.xbl_friend_list_context, menu);

    int statusCode = Friends.getStatusCode(getActivity(), item.mFriendId);

    if (statusCode == XboxLive.STATUS_INVITE_RCVD) {
      menu.setGroupVisible(R.id.menu_group_invite_rcvd, true);
      menu.setGroupVisible(R.id.menu_group_invite_sent, false);
      menu.setGroupVisible(R.id.menu_group_friend, false);
      menu.setGroupVisible(R.id.menu_group_gold, false);
    } else if (statusCode == XboxLive.STATUS_INVITE_SENT) {
      menu.setGroupVisible(R.id.menu_group_invite_rcvd, false);
      menu.setGroupVisible(R.id.menu_group_invite_sent, true);
      menu.setGroupVisible(R.id.menu_group_friend, false);
      menu.setGroupVisible(R.id.menu_group_gold, false);
    } else {
      menu.setGroupVisible(R.id.menu_group_invite_rcvd, false);
      menu.setGroupVisible(R.id.menu_group_invite_sent, false);
      menu.setGroupVisible(R.id.menu_group_friend, true);
      menu.setGroupVisible(R.id.menu_group_gold, mAccount.isGold());
    }
  }
Esempio n. 3
0
  @Override
  public void onCreate(Bundle state) {
    super.onCreate(state);

    if (mAccount == null) {
      Bundle args = getArguments();
      ContentResolver cr = getActivity().getContentResolver();

      mAccount = (XboxLiveAccount) args.getParcelable("account");
      mTitleId =
          getFirstTitleId(
              cr.query(
                  Friends.CONTENT_URI,
                  new String[] {
                    Friends._ID,
                  },
                  Friends.ACCOUNT_ID + "=" + mAccount.getId(),
                  null,
                  Friends.DEFAULT_SORT_ORDER));
    }

    if (state != null && state.containsKey("account")) {
      mAccount = (XboxLiveAccount) state.getParcelable("account");
      mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
  }
Esempio n. 4
0
  @Override
  public void onResume() {
    super.onResume();

    TaskController.getInstance().addListener(mListener);
    TaskController.getInstance().addListener(mRequestListener);

    updateLastUpdateTime();

    XboxLiveServiceClient.clearFriendNotifications(getActivity(), mAccount);
    XboxLiveServiceClient.clearBeaconNotifications(getActivity(), mAccount);

    ContentResolver cr = getActivity().getContentResolver();
    cr.registerContentObserver(Friends.CONTENT_URI, true, mObserver);

    if (System.currentTimeMillis() - mAccount.getLastFriendUpdate()
        > mAccount.getFriendRefreshInterval()) synchronizeWithServer();
  }
Esempio n. 5
0
  @Override
  protected Cursor getIconCursor() {
    if (getActivity() == null) return null;

    ContentResolver cr = getActivity().getContentResolver();
    return cr.query(
        Friends.CONTENT_URI,
        new String[] {Friends._ID, Friends.ICON_URL, Friends.TITLE_URL},
        Friends.ACCOUNT_ID + "=" + mAccount.getId(),
        null,
        Friends.DEFAULT_SORT_ORDER);
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();

    menu.setHeaderTitle(vh.gamertag.getText());

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.xbl_friends_of_friend_list_context, menu);

    menu.setGroupVisible(R.id.menu_group_gold, mAccount.isGold());
    menu.setGroupVisible(R.id.menu_group_friend, false);
    menu.setGroupVisible(R.id.menu_group_nonfriend, true);
  }
Esempio n. 7
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null) return null;

    View layout = inflater.inflate(R.layout.xbl_fragment_friend_list, container, false);

    String query = Friends.ACCOUNT_ID + "=" + mAccount.getId();
    SectionedAdapter adapter = new SectionedAdapter(getActivity(), R.layout.xbl_friend_list_header);

    adapter.addSection(
        getString(R.string.pending_count),
        new MyCursorAdapter(
            getActivity(),
            adapter,
            getActivity()
                .managedQuery(
                    Friends.CONTENT_URI,
                    PROJECTION,
                    query
                        + " AND ("
                        + Friends.STATUS_CODE
                        + "="
                        + XboxLive.STATUS_INVITE_RCVD
                        + " OR "
                        + Friends.STATUS_CODE
                        + "="
                        + XboxLive.STATUS_INVITE_SENT
                        + ")",
                    null,
                    Friends.DEFAULT_SORT_ORDER)));

    adapter.addSection(
        getString(R.string.online_count),
        new MyCursorAdapter(
            getActivity(),
            adapter,
            getActivity()
                .managedQuery(
                    Friends.CONTENT_URI,
                    PROJECTION,
                    query + " AND " + Friends.STATUS_CODE + "=" + XboxLive.STATUS_ONLINE,
                    null,
                    Friends.DEFAULT_SORT_ORDER)));

    adapter.addSection(
        getString(R.string.offline_count),
        new MyCursorAdapter(
            getActivity(),
            adapter,
            getActivity()
                .managedQuery(
                    Friends.CONTENT_URI,
                    PROJECTION,
                    query + " AND " + Friends.STATUS_CODE + "=" + XboxLive.STATUS_OFFLINE,
                    null,
                    Friends.DEFAULT_SORT_ORDER)));
    mAdapter = adapter; // new MyCursorAdapter(getActivity(), null);

    mMessage = (TextView) layout.findViewById(R.id.message);
    mMessage.setText(R.string.no_friends);

    mListView = (ListView) layout.findViewById(R.id.list);
    mListView.setOnItemClickListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setEmptyView(mMessage);

    registerForContextMenu(mListView);

    mProgress = layout.findViewById(R.id.loading);

    return layout;
  }