*/
@Override
public void onBuildHeaders(List<Header> headers) {
- loadHeadersFromResource(R.xml.settings_headers, headers);
- updateHeaderList(headers);
+ if (!onIsHidingHeaders()) {
+ loadHeadersFromResource(R.xml.settings_headers, headers);
+ updateHeaderList(headers);
+ }
}
private void updateHeaderList(List<Header> target) {
}
}
accountHeaders.add(accHeader);
+ mAuthenticatorHelper.preloadDrawableForType(this, accountType);
}
// Sort by label
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
import android.util.Log;
import java.util.ArrayList;
return mEnabledAccountTypes.toArray(new String[mEnabledAccountTypes.size()]);
}
+ public void preloadDrawableForType(final Context context, final String accountType) {
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... params) {
+ getDrawableForType(context, accountType);
+ return null;
+ }
+ }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
+ }
+
/**
* Gets an icon associated with a particular account type. If none found, return null.
* @param accountType the type of account
*/
public Drawable getDrawableForType(Context context, final String accountType) {
Drawable icon = null;
- if (mAccTypeIconCache.containsKey(accountType)) {
- return mAccTypeIconCache.get(accountType);
+ synchronized (mAccTypeIconCache) {
+ if (mAccTypeIconCache.containsKey(accountType)) {
+ return mAccTypeIconCache.get(accountType);
+ }
}
if (mTypeToAuthDescription.containsKey(accountType)) {
try {
AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
Context authContext = context.createPackageContext(desc.packageName, 0);
icon = authContext.getResources().getDrawable(desc.iconId);
- mAccTypeIconCache.put(accountType, icon);
+ synchronized (mAccTypeIconCache) {
+ mAccTypeIconCache.put(accountType, icon);
+ }
} catch (PackageManager.NameNotFoundException e) {
} catch (Resources.NotFoundException e) {
}