fr.java 9.41 KB
import android.os.Handler;
import android.os.Looper;
import android.support.v4.content.ParallelExecutorCompat;
import android.support.v7.util.ThreadUtil;
import android.support.v7.util.ThreadUtil.BackgroundCallback;
import android.support.v7.util.ThreadUtil.MainThreadCallback;
import android.support.v7.util.TileList.Tile;
import android.util.Log;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

public final class fr<T>
  implements ThreadUtil<T>
{
  public final ThreadUtil.BackgroundCallback<T> a(final ThreadUtil.BackgroundCallback<T> paramBackgroundCallback)
  {
    new ThreadUtil.BackgroundCallback()
    {
      final fr.a a = new fr.a();
      AtomicBoolean b = new AtomicBoolean(false);
      private final Executor e = ParallelExecutorCompat.getParallelExecutor();
      private Runnable f = new Runnable()
      {
        public final void run()
        {
          for (;;)
          {
            fr.b localb = fr.2.this.a.a();
            if (localb == null) {
              break;
            }
            switch (localb.a)
            {
            default: 
              Log.e("ThreadUtil", "Unsupported message, what=" + localb.a);
              break;
            case 1: 
              fr.2.this.a.a(1);
              fr.2.this.c.refresh(localb.b);
              break;
            case 2: 
              fr.2.this.a.a(2);
              fr.2.this.a.a(3);
              fr.2.this.c.updateRange(localb.b, localb.c, localb.d, localb.e, localb.f);
              break;
            case 3: 
              fr.2.this.c.loadTile(localb.b, localb.c);
              break;
            case 4: 
              fr.2.this.c.recycleTile((TileList.Tile)localb.g);
            }
          }
          fr.2.this.b.set(false);
        }
      };
      
      private void a()
      {
        if (this.b.compareAndSet(false, true)) {
          this.e.execute(this.f);
        }
      }
      
      private void a(fr.b paramAnonymousb)
      {
        this.a.b(paramAnonymousb);
        a();
      }
      
      private void b(fr.b paramAnonymousb)
      {
        this.a.a(paramAnonymousb);
        a();
      }
      
      public final void loadTile(int paramAnonymousInt1, int paramAnonymousInt2)
      {
        a(fr.b.a(3, paramAnonymousInt1, paramAnonymousInt2));
      }
      
      public final void recycleTile(TileList.Tile<T> paramAnonymousTile)
      {
        a(fr.b.a(4, 0, paramAnonymousTile));
      }
      
      public final void refresh(int paramAnonymousInt)
      {
        b(fr.b.a(1, paramAnonymousInt, null));
      }
      
      public final void updateRange(int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3, int paramAnonymousInt4, int paramAnonymousInt5)
      {
        b(fr.b.a(2, paramAnonymousInt1, paramAnonymousInt2, paramAnonymousInt3, paramAnonymousInt4, paramAnonymousInt5, null));
      }
    };
  }
  
  public final ThreadUtil.MainThreadCallback<T> a(final ThreadUtil.MainThreadCallback<T> paramMainThreadCallback)
  {
    new ThreadUtil.MainThreadCallback()
    {
      final fr.a a = new fr.a();
      private final Handler d = new Handler(Looper.getMainLooper());
      private Runnable e = new Runnable()
      {
        public final void run()
        {
          fr.b localb = fr.1.this.a.a();
          if (localb != null)
          {
            switch (localb.a)
            {
            default: 
              Log.e("ThreadUtil", "Unsupported message, what=" + localb.a);
            }
            for (;;)
            {
              localb = fr.1.this.a.a();
              break;
              fr.1.this.b.updateItemCount(localb.b, localb.c);
              continue;
              fr.1.this.b.addTile(localb.b, (TileList.Tile)localb.g);
              continue;
              fr.1.this.b.removeTile(localb.b, localb.c);
            }
          }
        }
      };
      
      private void a(fr.b paramAnonymousb)
      {
        this.a.b(paramAnonymousb);
        this.d.post(this.e);
      }
      
      public final void addTile(int paramAnonymousInt, TileList.Tile<T> paramAnonymousTile)
      {
        a(fr.b.a(2, paramAnonymousInt, paramAnonymousTile));
      }
      
      public final void removeTile(int paramAnonymousInt1, int paramAnonymousInt2)
      {
        a(fr.b.a(3, paramAnonymousInt1, paramAnonymousInt2));
      }
      
      public final void updateItemCount(int paramAnonymousInt1, int paramAnonymousInt2)
      {
        a(fr.b.a(1, paramAnonymousInt1, paramAnonymousInt2));
      }
    };
  }
  
  static final class a
  {
    private fr.b a;
    
    /* Error */
    final fr.b a()
    {
      // Byte code:
      //   0: aload_0
      //   1: monitorenter
      //   2: aload_0
      //   3: getfield 16	fr$a:a	Lfr$b;
      //   6: astore_1
      //   7: aload_1
      //   8: ifnonnull +9 -> 17
      //   11: aconst_null
      //   12: astore_1
      //   13: aload_0
      //   14: monitorexit
      //   15: aload_1
      //   16: areturn
      //   17: aload_0
      //   18: getfield 16	fr$a:a	Lfr$b;
      //   21: astore_1
      //   22: aload_0
      //   23: aload_0
      //   24: getfield 16	fr$a:a	Lfr$b;
      //   27: invokestatic 21	fr$b:a	(Lfr$b;)Lfr$b;
      //   30: putfield 16	fr$a:a	Lfr$b;
      //   33: goto -20 -> 13
      //   36: astore_1
      //   37: aload_0
      //   38: monitorexit
      //   39: aload_1
      //   40: athrow
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	41	0	this	a
      //   6	16	1	localb	fr.b
      //   36	4	1	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   2	7	36	finally
      //   17	33	36	finally
    }
    
    final void a(int paramInt)
    {
      try
      {
        while ((this.a != null) && (this.a.a == paramInt))
        {
          fr.b localb1 = this.a;
          this.a = fr.b.a(this.a);
          localb1.a();
        }
        if (this.a == null) {
          break label105;
        }
      }
      finally {}
      Object localObject3 = this.a;
      Object localObject2 = fr.b.a((fr.b)localObject3);
      if (localObject2 != null)
      {
        fr.b localb2 = fr.b.a((fr.b)localObject2);
        if (((fr.b)localObject2).a == paramInt)
        {
          fr.b.a((fr.b)localObject3, localb2);
          ((fr.b)localObject2).a();
        }
        for (;;)
        {
          localObject2 = localb2;
          break;
          localObject3 = localObject2;
        }
      }
      label105:
    }
    
    final void a(fr.b paramb)
    {
      try
      {
        fr.b.a(paramb, this.a);
        this.a = paramb;
        return;
      }
      finally
      {
        paramb = finally;
        throw paramb;
      }
    }
    
    /* Error */
    final void b(fr.b paramb)
    {
      // Byte code:
      //   0: aload_0
      //   1: monitorenter
      //   2: aload_0
      //   3: getfield 16	fr$a:a	Lfr$b;
      //   6: ifnonnull +11 -> 17
      //   9: aload_0
      //   10: aload_1
      //   11: putfield 16	fr$a:a	Lfr$b;
      //   14: aload_0
      //   15: monitorexit
      //   16: return
      //   17: aload_0
      //   18: getfield 16	fr$a:a	Lfr$b;
      //   21: astore_2
      //   22: aload_2
      //   23: invokestatic 21	fr$b:a	(Lfr$b;)Lfr$b;
      //   26: ifnull +11 -> 37
      //   29: aload_2
      //   30: invokestatic 21	fr$b:a	(Lfr$b;)Lfr$b;
      //   33: astore_2
      //   34: goto -12 -> 22
      //   37: aload_2
      //   38: aload_1
      //   39: invokestatic 30	fr$b:a	(Lfr$b;Lfr$b;)Lfr$b;
      //   42: pop
      //   43: goto -29 -> 14
      //   46: astore_1
      //   47: aload_0
      //   48: monitorexit
      //   49: aload_1
      //   50: athrow
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	51	0	this	a
      //   0	51	1	paramb	fr.b
      //   21	17	2	localb	fr.b
      // Exception table:
      //   from	to	target	type
      //   2	14	46	finally
      //   17	22	46	finally
      //   22	34	46	finally
      //   37	43	46	finally
    }
  }
  
  static final class b
  {
    private static b h;
    private static final Object i = new Object();
    public int a;
    public int b;
    public int c;
    public int d;
    public int e;
    public int f;
    public Object g;
    private b j;
    
    static b a(int paramInt1, int paramInt2, int paramInt3)
    {
      return a(paramInt1, paramInt2, paramInt3, 0, 0, 0, null);
    }
    
    static b a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, Object paramObject)
    {
      synchronized (i)
      {
        if (h == null)
        {
          localb = new b();
          localb.a = paramInt1;
          localb.b = paramInt2;
          localb.c = paramInt3;
          localb.d = paramInt4;
          localb.e = paramInt5;
          localb.f = paramInt6;
          localb.g = paramObject;
          return localb;
        }
        b localb = h;
        h = h.j;
        localb.j = null;
      }
    }
    
    static b a(int paramInt1, int paramInt2, Object paramObject)
    {
      return a(paramInt1, paramInt2, 0, 0, 0, 0, paramObject);
    }
    
    final void a()
    {
      this.j = null;
      this.f = 0;
      this.e = 0;
      this.d = 0;
      this.c = 0;
      this.b = 0;
      this.a = 0;
      this.g = null;
      synchronized (i)
      {
        if (h != null) {
          this.j = h;
        }
        h = this;
        return;
      }
    }
  }
}


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