diff options
Diffstat (limited to 'src/com/android/tv/util/ViewCache.java')
-rw-r--r-- | src/com/android/tv/util/ViewCache.java | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/com/android/tv/util/ViewCache.java b/src/com/android/tv/util/ViewCache.java index ed9a8ff6..b8bdb6b8 100644 --- a/src/com/android/tv/util/ViewCache.java +++ b/src/com/android/tv/util/ViewCache.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2017 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 com.android.tv.util; import android.content.Context; @@ -5,22 +20,17 @@ import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import java.util.ArrayList; -/** - * A cache for the views. - */ +/** A cache for the views. */ public class ViewCache { - private final static SparseArray<ArrayList<View>> mViews = new SparseArray(); + private static final SparseArray<ArrayList<View>> mViews = new SparseArray(); private static ViewCache sViewCache; - private ViewCache() { } + private ViewCache() {} - /** - * Returns an instance of the view cache. - */ + /** Returns an instance of the view cache. */ public static ViewCache getInstance() { if (sViewCache == null) { sViewCache = new ViewCache(); @@ -28,16 +38,12 @@ public class ViewCache { return sViewCache; } - /** - * Returns if the view cache is empty. - */ + /** Returns if the view cache is empty. */ public boolean isEmpty() { return mViews.size() == 0; } - /** - * Stores a view into this view cache. - */ + /** Stores a view into this view cache. */ public void putView(int resId, View view) { ArrayList<View> views = mViews.get(resId); if (views == null) { @@ -47,9 +53,7 @@ public class ViewCache { views.add(view); } - /** - * Stores multi specific views into the view cache. - */ + /** Stores multi specific views into the view cache. */ public void putView(Context context, int resId, ViewGroup fakeParent, int num) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -64,9 +68,7 @@ public class ViewCache { } } - /** - * Returns the view for specific resource id. - */ + /** Returns the view for specific resource id. */ public View getView(int resId) { ArrayList<View> views = mViews.get(resId); if (views != null && !views.isEmpty()) { @@ -80,9 +82,7 @@ public class ViewCache { } } - /** - * Returns the view if exists, or create a new view for the specific resource id. - */ + /** Returns the view if exists, or create a new view for the specific resource id. */ public View getOrCreateView(LayoutInflater inflater, int resId, ViewGroup container) { View view = getView(resId); if (view == null) { @@ -91,9 +91,7 @@ public class ViewCache { return view; } - /** - * Clears the view cache. - */ + /** Clears the view cache. */ public void clear() { mViews.clear(); } |