Java Code Examples for org.chromium.chrome.browser.profiles.ProfileDownloader#addObserver()

The following examples show how to use org.chromium.chrome.browser.profiles.ProfileDownloader#addObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountManagementFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Prefetch the primary account image and name.
 *
 * @param context A context to use.
 * @param profile A profile to use.
 */
public static void prefetchUserNamePicture(Context context, Profile profile) {
    final String accountName = ChromeSigninController.get(context).getSignedInAccountName();
    if (TextUtils.isEmpty(accountName)) return;
    if (sToNamePicture.get(accountName) != null) return;

    ProfileDownloader.addObserver(new ProfileDownloader.Observer() {
        @Override
        public void onProfileDownloaded(String accountId, String fullName, String givenName,
                Bitmap bitmap) {
            if (TextUtils.equals(accountName, accountId)) {
                updateUserNamePictureCache(accountId, fullName, bitmap);
                ProfileDownloader.removeObserver(this);
            }
        }
    });
    startFetchingAccountInformation(context, profile, accountName);
}
 
Example 2
Source File: ProfileDataCache.java    From delion with Apache License 2.0 6 votes vote down vote up
public ProfileDataCache(Context context, Profile profile) {
    ProfileDownloader.addObserver(this);

    mContext = context;
    mProfile = profile;

    final DeviceDisplayInfo info = DeviceDisplayInfo.create(context);
    mImageSizePx = (int) Math.ceil(PROFILE_IMAGE_SIZE_DP * info.getDIPScale());
    mImageStrokePx = (int) Math.ceil(PROFILE_IMAGE_STROKE_DP * info.getDIPScale());
    mImageStrokeColor = Color.WHITE;

    Bitmap placeHolder = BitmapFactory.decodeResource(mContext.getResources(),
            R.drawable.fre_placeholder);
    mPlaceholderImage = getCroppedBitmap(placeHolder);

    update();
}
 
Example 3
Source File: AccountManagementFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Prefetch the primary account image and name.
 *
 * @param context A context to use.
 * @param profile A profile to use.
 */
public static void prefetchUserNamePicture(Context context, Profile profile) {
    final String accountName = ChromeSigninController.get(context).getSignedInAccountName();
    if (TextUtils.isEmpty(accountName)) return;
    if (sToNamePicture.get(accountName) != null) return;

    ProfileDownloader.addObserver(new ProfileDownloader.Observer() {
        @Override
        public void onProfileDownloaded(String accountId, String fullName, String givenName,
                Bitmap bitmap) {
            if (TextUtils.equals(accountName, accountId)) {
                updateUserNamePictureCache(accountId, fullName, bitmap);
                ProfileDownloader.removeObserver(this);
            }
        }
    });
    startFetchingAccountInformation(context, profile, accountName);
}
 
Example 4
Source File: ProfileDataCache.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
public ProfileDataCache(Context context, Profile profile) {
    ProfileDownloader.addObserver(this);

    mContext = context;
    mProfile = profile;

    // There's no WindowAndroid present at this time, so get the default display.
    final DisplayAndroid displayAndroid = DisplayAndroid.getNonMultiDisplay(context);
    mImageSizePx = (int) Math.ceil(PROFILE_IMAGE_SIZE_DP * displayAndroid.getDipScale());
    mImageStrokePx = (int) Math.ceil(PROFILE_IMAGE_STROKE_DP * displayAndroid.getDipScale());
    mImageStrokeColor = Color.WHITE;

    Bitmap placeHolder = BitmapFactory.decodeResource(mContext.getResources(),
            R.drawable.fre_placeholder);
    mPlaceholderImage = getCroppedBitmap(placeHolder);

    update();
}
 
Example 5
Source File: ProfileDataCache.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public ProfileDataCache(Context context, Profile profile) {
    mContext = context;
    mProfile = profile;

    // There's no WindowAndroid present at this time, so get the default display.
    final DisplayAndroid displayAndroid = DisplayAndroid.getNonMultiDisplay(context);
    mImageSizePx = (int) Math.ceil(PROFILE_IMAGE_SIZE_DP * displayAndroid.getDipScale());
    mImageStrokePx = (int) Math.ceil(PROFILE_IMAGE_STROKE_DP * displayAndroid.getDipScale());
    mImageStrokeColor = Color.WHITE;

    Bitmap placeHolder = BitmapFactory.decodeResource(mContext.getResources(),
            R.drawable.fre_placeholder);
    mPlaceholderImage = getCroppedBitmap(placeHolder);

    ProfileDownloader.addObserver(this);
}
 
Example 6
Source File: AccountManagementFragment.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SigninManager.get(getActivity()).addSignInStateObserver(this);
    ProfileDownloader.addObserver(this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }

    update();
}
 
Example 7
Source File: SignInPreference.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Starts listening for updates to the sign-in and sync state.
 */
public void registerForUpdates() {
    SigninManager manager = SigninManager.get(getContext());
    manager.addSignInAllowedObserver(this);
    ProfileDownloader.addObserver(this);
    FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone(getContext());
    AndroidSyncSettings.registerObserver(getContext(), this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }
}
 
Example 8
Source File: AccountManagementFragment.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SigninManager.get(getActivity()).addSignInStateObserver(this);
    ProfileDownloader.addObserver(this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }

    update();
}
 
Example 9
Source File: SignInPreference.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Starts listening for updates to the sign-in and sync state.
 */
public void registerForUpdates() {
    SigninManager manager = SigninManager.get(getContext());
    manager.addSignInAllowedObserver(this);
    ProfileDownloader.addObserver(this);
    FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone(getContext());
    AndroidSyncSettings.registerObserver(getContext(), this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }
}
 
Example 10
Source File: AccountManagementFragment.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SigninManager.get(getActivity()).addSignInStateObserver(this);
    ProfileDownloader.addObserver(this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }

    update();
}
 
Example 11
Source File: SignInPreference.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Starts listening for updates to the sign-in and sync state.
 */
public void registerForUpdates() {
    SigninManager manager = SigninManager.get(getContext());
    manager.addSignInAllowedObserver(this);
    ProfileDownloader.addObserver(this);
    FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone(getContext());
    AndroidSyncSettings.registerObserver(getContext(), this);
    ProfileSyncService syncService = ProfileSyncService.get();
    if (syncService != null) {
        syncService.addSyncStateChangedListener(this);
    }
}