Home | History | Annotate | Download | only in notification
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.systemui.statusbar.notification;
     18 
     19 import android.text.Layout;
     20 import android.text.TextUtils;
     21 import android.util.Pools;
     22 import android.view.View;
     23 import android.widget.TextView;
     24 
     25 /**
     26  * A transform state of the action list
     27 */
     28 public class ActionListTransformState extends TransformState {
     29 
     30     private static Pools.SimplePool<ActionListTransformState> sInstancePool
     31             = new Pools.SimplePool<>(40);
     32 
     33     @Override
     34     protected boolean sameAs(TransformState otherState) {
     35         return otherState instanceof ActionListTransformState;
     36     }
     37 
     38     public static ActionListTransformState obtain() {
     39         ActionListTransformState instance = sInstancePool.acquire();
     40         if (instance != null) {
     41             return instance;
     42         }
     43         return new ActionListTransformState();
     44     }
     45 
     46     @Override
     47     public void transformViewFullyFrom(TransformState otherState, float transformationAmount) {
     48         // Don't do Y transform - let the wrapper handle this based on the content height
     49     }
     50 
     51     @Override
     52     public void transformViewFullyTo(TransformState otherState, float transformationAmount) {
     53         // Don't do Y transform - let the wrapper handle this based on the content height
     54     }
     55 
     56     @Override
     57     protected void resetTransformedView() {
     58         // We need to keep the Y transformation, because this is used to keep the action list
     59         // aligned at the bottom, unrelated to transforms.
     60         float y = getTransformedView().getTranslationY();
     61         super.resetTransformedView();
     62         getTransformedView().setTranslationY(y);
     63     }
     64 
     65     @Override
     66     public void recycle() {
     67         super.recycle();
     68         sInstancePool.release(this);
     69     }
     70 }
     71