diff options
author | Brian Attwell <brianattwell@google.com> | 2014-07-21 14:55:10 -0700 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2014-07-22 12:05:21 -0700 |
commit | 7437058d4c9fd10fdeb4e78166591e68629cd03c (patch) | |
tree | 730819071403f42d11b09b56fe68de759334b0e8 /src/com/android/dialer/list/ViewPagerTabStrip.java | |
parent | 80c81b1170c692cccdfe76f695fee74525e04a75 (diff) |
Move ViewPagerTabs out of Dialer repo
Bug: 16158921
Bug: 15616182
Change-Id: Ie648d78dd4df402936c4665eca7c6998e463ca2b
Diffstat (limited to 'src/com/android/dialer/list/ViewPagerTabStrip.java')
-rw-r--r-- | src/com/android/dialer/list/ViewPagerTabStrip.java | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/com/android/dialer/list/ViewPagerTabStrip.java b/src/com/android/dialer/list/ViewPagerTabStrip.java deleted file mode 100644 index ac16694b3..000000000 --- a/src/com/android/dialer/list/ViewPagerTabStrip.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2014 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.dialer.list; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.util.AttributeSet; -import android.view.View; -import android.widget.LinearLayout; - -import com.android.dialer.R; - -public class ViewPagerTabStrip extends LinearLayout { - private int mSelectedUnderlineThickness; - private final Paint mSelectedUnderlinePaint; - - private int mIndexForSelection; - private float mSelectionOffset; - - public ViewPagerTabStrip(Context context) { - this(context, null); - } - - public ViewPagerTabStrip(Context context, AttributeSet attrs) { - super(context, attrs); - - final Resources res = context.getResources(); - - mSelectedUnderlineThickness = - res.getDimensionPixelSize(R.dimen.tab_selected_underline_height); - int underlineColor = res.getColor(R.color.tab_selected_underline_color); - int backgroundColor = res.getColor(R.color.actionbar_background_color); - - mSelectedUnderlinePaint = new Paint(); - mSelectedUnderlinePaint.setColor(underlineColor); - - setBackgroundColor(backgroundColor); - setWillNotDraw(false); - } - - /** - * Notifies this view that view pager has been scrolled. We save the tab index - * and selection offset for interpolating the position and width of selection - * underline. - */ - void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - mIndexForSelection = position; - mSelectionOffset = positionOffset; - invalidate(); - } - - /** - * Notifies this view that a new page has been selected in the view pager. We save the tab - * index and reset the selection offset to 0. - */ - void onPageSelected(int position) { - mIndexForSelection = position; - mSelectionOffset = 0; - invalidate(); - } - - @Override - protected void onDraw(Canvas canvas) { - int childCount = getChildCount(); - - // Thick colored underline below the current selection - if (childCount > 0) { - View selectedTitle = getChildAt(mIndexForSelection); - int selectedLeft = selectedTitle.getLeft(); - int selectedRight = selectedTitle.getRight(); - if ((mSelectionOffset > 0.0f) && - (mIndexForSelection < (getChildCount() - 1))) { - // Draw the selection partway between the tabs - View nextTitle = getChildAt(mIndexForSelection + 1); - int nextLeft = nextTitle.getLeft(); - int nextRight = nextTitle.getRight(); - - selectedLeft = (int) (mSelectionOffset * nextLeft + - (1.0f - mSelectionOffset) * selectedLeft); - selectedRight = (int) (mSelectionOffset * nextRight + - (1.0f - mSelectionOffset) * selectedRight); - } - - int height = getHeight(); - canvas.drawRect(selectedLeft, height - mSelectedUnderlineThickness, - selectedRight, height, mSelectedUnderlinePaint); - } - } -}
\ No newline at end of file |