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); } } }
@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(); }