From 44d180199b36f1ff17edbc7c0c68c0a0298f78f4 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Thu, 23 Jan 2014 08:56:37 -0800 Subject: GEL Integration (2/2) Launch search from extra panel to mimic Google Launcher. Changed Trebuchet to build against CM instead of the AOSP SDK. Added support to swipe left from the home screen to enter Google Now, if it is installed. A right swipe will return the user to the home screen. Change-Id: Ia1a77fedea7e67bcd54a6b6d66099f8366d6b1dc --- WallpaperPicker/src/android/util/Pools.java | 165 ---------------------------- 1 file changed, 165 deletions(-) delete mode 100644 WallpaperPicker/src/android/util/Pools.java (limited to 'WallpaperPicker/src') diff --git a/WallpaperPicker/src/android/util/Pools.java b/WallpaperPicker/src/android/util/Pools.java deleted file mode 100644 index 40bab1eae..000000000 --- a/WallpaperPicker/src/android/util/Pools.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.util; - -/** - * Helper class for crating pools of objects. An example use looks like this: - *
- * public class MyPooledClass {
- *
- *     private static final SynchronizedPool sPool =
- *             new SynchronizedPool(10);
- *
- *     public static MyPooledClass obtain() {
- *         MyPooledClass instance = sPool.acquire();
- *         return (instance != null) ? instance : new MyPooledClass();
- *     }
- *
- *     public void recycle() {
- *          // Clear state if needed.
- *          sPool.release(this);
- *     }
- *
- *     . . .
- * }
- * 
- * - * @hide - */ -public final class Pools { - - /** - * Interface for managing a pool of objects. - * - * @param The pooled type. - */ - public static interface Pool { - - /** - * @return An instance from the pool if such, null otherwise. - */ - public T acquire(); - - /** - * Release an instance to the pool. - * - * @param instance The instance to release. - * @return Whether the instance was put in the pool. - * - * @throws IllegalStateException If the instance is already in the pool. - */ - public boolean release(T instance); - } - - private Pools() { - /* do nothing - hiding constructor */ - } - - /** - * Simple (non-synchronized) pool of objects. - * - * @param The pooled type. - */ - public static class SimplePool implements Pool { - private final Object[] mPool; - - private int mPoolSize; - - /** - * Creates a new instance. - * - * @param maxPoolSize The max pool size. - * - * @throws IllegalArgumentException If the max pool size is less than zero. - */ - public SimplePool(int maxPoolSize) { - if (maxPoolSize <= 0) { - throw new IllegalArgumentException("The max pool size must be > 0"); - } - mPool = new Object[maxPoolSize]; - } - - @Override - @SuppressWarnings("unchecked") - public T acquire() { - if (mPoolSize > 0) { - final int lastPooledIndex = mPoolSize - 1; - T instance = (T) mPool[lastPooledIndex]; - mPool[lastPooledIndex] = null; - mPoolSize--; - return instance; - } - return null; - } - - @Override - public boolean release(T instance) { - if (isInPool(instance)) { - throw new IllegalStateException("Already in the pool!"); - } - if (mPoolSize < mPool.length) { - mPool[mPoolSize] = instance; - mPoolSize++; - return true; - } - return false; - } - - private boolean isInPool(T instance) { - for (int i = 0; i < mPoolSize; i++) { - if (mPool[i] == instance) { - return true; - } - } - return false; - } - } - - /** - * Synchronized) pool of objects. - * - * @param The pooled type. - */ - public static class SynchronizedPool extends SimplePool { - private final Object mLock = new Object(); - - /** - * Creates a new instance. - * - * @param maxPoolSize The max pool size. - * - * @throws IllegalArgumentException If the max pool size is less than zero. - */ - public SynchronizedPool(int maxPoolSize) { - super(maxPoolSize); - } - - @Override - public T acquire() { - synchronized (mLock) { - return super.acquire(); - } - } - - @Override - public boolean release(T element) { - synchronized (mLock) { - return super.release(element); - } - } - } -} \ No newline at end of file -- cgit v1.2.3