TintContextWrapper.java 3.55 KB
package android.support.v7.widget;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.os.Build.VERSION;
import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import hb;
import java.lang.ref.WeakReference;
import java.util.ArrayList;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class TintContextWrapper
  extends ContextWrapper
{
  private static final Object a = new Object();
  private static ArrayList<WeakReference<TintContextWrapper>> b;
  private final Resources c;
  private final Resources.Theme d;
  
  private TintContextWrapper(@NonNull Context paramContext)
  {
    super(paramContext);
    if (VectorEnabledTintResources.shouldBeUsed())
    {
      this.c = new VectorEnabledTintResources(this, paramContext.getResources());
      this.d = this.c.newTheme();
      this.d.setTo(paramContext.getTheme());
      return;
    }
    this.c = new hb(this, paramContext.getResources());
    this.d = null;
  }
  
  public static Context wrap(@NonNull Context paramContext)
  {
    int j = 0;
    int i = j;
    if (!(paramContext instanceof TintContextWrapper))
    {
      i = j;
      if (!(paramContext.getResources() instanceof hb))
      {
        if (!(paramContext.getResources() instanceof VectorEnabledTintResources)) {
          break label94;
        }
        i = j;
      }
    }
    Object localObject1 = paramContext;
    if (i != 0) {}
    for (;;)
    {
      synchronized (a)
      {
        if (b == null)
        {
          b = new ArrayList();
          localObject1 = new TintContextWrapper(paramContext);
          b.add(new WeakReference(localObject1));
          return (Context)localObject1;
          label94:
          if (Build.VERSION.SDK_INT >= 21)
          {
            i = j;
            if (!VectorEnabledTintResources.shouldBeUsed()) {
              break;
            }
          }
          i = 1;
          break;
        }
        i = b.size() - 1;
        if (i >= 0)
        {
          localObject1 = (WeakReference)b.get(i);
          if ((localObject1 == null) || (((WeakReference)localObject1).get() == null)) {
            b.remove(i);
          }
        }
        else
        {
          i = b.size() - 1;
          if (i < 0) {
            continue;
          }
          localObject1 = (WeakReference)b.get(i);
          if (localObject1 == null) {
            break label227;
          }
          localObject1 = (TintContextWrapper)((WeakReference)localObject1).get();
          if ((localObject1 == null) || (((TintContextWrapper)localObject1).getBaseContext() != paramContext)) {
            break label232;
          }
          return (Context)localObject1;
        }
      }
      i -= 1;
      continue;
      label227:
      localObject1 = null;
      continue;
      label232:
      i -= 1;
    }
  }
  
  public AssetManager getAssets()
  {
    return this.c.getAssets();
  }
  
  public Resources getResources()
  {
    return this.c;
  }
  
  public Resources.Theme getTheme()
  {
    if (this.d == null) {
      return super.getTheme();
    }
    return this.d;
  }
  
  public void setTheme(int paramInt)
  {
    if (this.d == null)
    {
      super.setTheme(paramInt);
      return;
    }
    this.d.applyStyle(paramInt, true);
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/TintContextWrapper.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */