AsyncLayoutInflater.java 6.77 KB
package android.support.v4.view;

import android.content.Context;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v4.util.Pools.SynchronizedPool;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.concurrent.ArrayBlockingQueue;

public final class AsyncLayoutInflater
{
  LayoutInflater a;
  Handler b;
  c c;
  private Handler.Callback d = new Handler.Callback()
  {
    public final boolean handleMessage(Message paramAnonymousMessage)
    {
      paramAnonymousMessage = (AsyncLayoutInflater.b)paramAnonymousMessage.obj;
      if (paramAnonymousMessage.d == null) {
        paramAnonymousMessage.d = AsyncLayoutInflater.this.a.inflate(paramAnonymousMessage.c, paramAnonymousMessage.b, false);
      }
      paramAnonymousMessage.e.onInflateFinished(paramAnonymousMessage.d, paramAnonymousMessage.c, paramAnonymousMessage.b);
      AsyncLayoutInflater.c localc = AsyncLayoutInflater.this.c;
      paramAnonymousMessage.e = null;
      paramAnonymousMessage.a = null;
      paramAnonymousMessage.b = null;
      paramAnonymousMessage.c = 0;
      paramAnonymousMessage.d = null;
      localc.b.release(paramAnonymousMessage);
      return true;
    }
  };
  
  public AsyncLayoutInflater(@NonNull Context paramContext)
  {
    this.a = new a(paramContext);
    this.b = new Handler(this.d);
    this.c = c.a();
  }
  
  @UiThread
  public final void inflate(@LayoutRes int paramInt, @Nullable ViewGroup paramViewGroup, @NonNull OnInflateFinishedListener paramOnInflateFinishedListener)
  {
    if (paramOnInflateFinishedListener == null) {
      throw new NullPointerException("callback argument may not be null!");
    }
    b localb2 = (b)this.c.b.acquire();
    b localb1 = localb2;
    if (localb2 == null) {
      localb1 = new b();
    }
    localb1.a = this;
    localb1.c = paramInt;
    localb1.b = paramViewGroup;
    localb1.e = paramOnInflateFinishedListener;
    paramViewGroup = this.c;
    try
    {
      paramViewGroup.a.put(localb1);
      return;
    }
    catch (InterruptedException paramViewGroup)
    {
      throw new RuntimeException("Failed to enqueue async inflate request", paramViewGroup);
    }
  }
  
  public static abstract interface OnInflateFinishedListener
  {
    public abstract void onInflateFinished(View paramView, int paramInt, ViewGroup paramViewGroup);
  }
  
  static final class a
    extends LayoutInflater
  {
    private static final String[] a = { "android.widget.", "android.webkit.", "android.app." };
    
    a(Context paramContext)
    {
      super();
    }
    
    public final LayoutInflater cloneInContext(Context paramContext)
    {
      return new a(paramContext);
    }
    
    protected final View onCreateView(String paramString, AttributeSet paramAttributeSet)
      throws ClassNotFoundException
    {
      String[] arrayOfString = a;
      int j = arrayOfString.length;
      int i = 0;
      while (i < j)
      {
        Object localObject = arrayOfString[i];
        try
        {
          localObject = createView(paramString, (String)localObject, paramAttributeSet);
          if (localObject != null) {
            return (View)localObject;
          }
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          i += 1;
        }
      }
      return super.onCreateView(paramString, paramAttributeSet);
    }
  }
  
  static final class b
  {
    AsyncLayoutInflater a;
    ViewGroup b;
    int c;
    View d;
    AsyncLayoutInflater.OnInflateFinishedListener e;
  }
  
  static final class c
    extends Thread
  {
    private static final c c;
    ArrayBlockingQueue<AsyncLayoutInflater.b> a = new ArrayBlockingQueue(10);
    Pools.SynchronizedPool<AsyncLayoutInflater.b> b = new Pools.SynchronizedPool(10);
    
    static
    {
      c localc = new c();
      c = localc;
      localc.start();
    }
    
    public static c a()
    {
      return c;
    }
    
    /* Error */
    public final void run()
    {
      // Byte code:
      //   0: aload_0
      //   1: getfield 33	android/support/v4/view/AsyncLayoutInflater$c:a	Ljava/util/concurrent/ArrayBlockingQueue;
      //   4: invokevirtual 48	java/util/concurrent/ArrayBlockingQueue:take	()Ljava/lang/Object;
      //   7: checkcast 50	android/support/v4/view/AsyncLayoutInflater$b
      //   10: astore_1
      //   11: aload_1
      //   12: aload_1
      //   13: getfield 53	android/support/v4/view/AsyncLayoutInflater$b:a	Landroid/support/v4/view/AsyncLayoutInflater;
      //   16: getfield 56	android/support/v4/view/AsyncLayoutInflater:a	Landroid/view/LayoutInflater;
      //   19: aload_1
      //   20: getfield 59	android/support/v4/view/AsyncLayoutInflater$b:c	I
      //   23: aload_1
      //   24: getfield 62	android/support/v4/view/AsyncLayoutInflater$b:b	Landroid/view/ViewGroup;
      //   27: iconst_0
      //   28: invokevirtual 68	android/view/LayoutInflater:inflate	(ILandroid/view/ViewGroup;Z)Landroid/view/View;
      //   31: putfield 72	android/support/v4/view/AsyncLayoutInflater$b:d	Landroid/view/View;
      //   34: aload_1
      //   35: getfield 53	android/support/v4/view/AsyncLayoutInflater$b:a	Landroid/support/v4/view/AsyncLayoutInflater;
      //   38: getfield 75	android/support/v4/view/AsyncLayoutInflater:b	Landroid/os/Handler;
      //   41: iconst_0
      //   42: aload_1
      //   43: invokestatic 81	android/os/Message:obtain	(Landroid/os/Handler;ILjava/lang/Object;)Landroid/os/Message;
      //   46: invokevirtual 84	android/os/Message:sendToTarget	()V
      //   49: goto -49 -> 0
      //   52: astore_1
      //   53: ldc 86
      //   55: aload_1
      //   56: invokestatic 92	android/util/Log:w	(Ljava/lang/String;Ljava/lang/Throwable;)I
      //   59: pop
      //   60: goto -60 -> 0
      //   63: astore_2
      //   64: ldc 86
      //   66: ldc 94
      //   68: aload_2
      //   69: invokestatic 97	android/util/Log:w	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
      //   72: pop
      //   73: goto -39 -> 34
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	76	0	this	c
      //   10	33	1	localb	AsyncLayoutInflater.b
      //   52	4	1	localInterruptedException	InterruptedException
      //   63	6	2	localRuntimeException	RuntimeException
      // Exception table:
      //   from	to	target	type
      //   0	11	52	java/lang/InterruptedException
      //   11	34	63	java/lang/RuntimeException
    }
  }
}


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