diff --git a/app/src/main/java/be/digitalia/fosdem/fragments/LiveFragment.java b/app/src/main/java/be/digitalia/fosdem/fragments/LiveFragment.java index 203ac72..2353723 100644 --- a/app/src/main/java/be/digitalia/fosdem/fragments/LiveFragment.java +++ b/app/src/main/java/be/digitalia/fosdem/fragments/LiveFragment.java @@ -10,7 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.example.android.common.view.SlidingTabLayout; +import be.digitalia.fosdem.widgets.SlidingTabLayout; import be.digitalia.fosdem.R; diff --git a/app/src/main/java/be/digitalia/fosdem/fragments/TracksFragment.java b/app/src/main/java/be/digitalia/fosdem/fragments/TracksFragment.java index 0a8375e..2772bc9 100644 --- a/app/src/main/java/be/digitalia/fosdem/fragments/TracksFragment.java +++ b/app/src/main/java/be/digitalia/fosdem/fragments/TracksFragment.java @@ -17,7 +17,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.example.android.common.view.SlidingTabLayout; +import be.digitalia.fosdem.widgets.SlidingTabLayout; import java.util.List; diff --git a/app/src/main/java/com/example/android/common/view/SlidingTabLayout.java b/app/src/main/java/be/digitalia/fosdem/widgets/SlidingTabLayout.java similarity index 85% rename from app/src/main/java/com/example/android/common/view/SlidingTabLayout.java rename to app/src/main/java/be/digitalia/fosdem/widgets/SlidingTabLayout.java index a76c10a..9493c5e 100644 --- a/app/src/main/java/com/example/android/common/view/SlidingTabLayout.java +++ b/app/src/main/java/be/digitalia/fosdem/widgets/SlidingTabLayout.java @@ -15,12 +15,14 @@ * limitations under the License. */ -package com.example.android.common.view; +package be.digitalia.fosdem.widgets; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.database.DataSetObserver; +import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.Typeface; import android.os.Build; import android.support.annotation.ColorInt; @@ -327,4 +329,61 @@ public class SlidingTabLayout extends HorizontalScrollView { } } } + + + class SlidingTabStrip extends LinearLayout { + + private int mSelectedIndicatorHeight; + private final Paint mSelectedIndicatorPaint; + + private int mSelectedPosition; + private float mSelectionOffset; + + SlidingTabStrip(Context context) { + super(context); + setWillNotDraw(false); + mSelectedIndicatorPaint = new Paint(); + } + + void setSelectedIndicatorColor(@ColorInt int color) { + mSelectedIndicatorPaint.setColor(color); + invalidate(); + } + + void setSelectedIndicatorHeight(int height) { + mSelectedIndicatorHeight = height; + invalidate(); + } + + void onViewPagerPageChanged(int position, float positionOffset) { + mSelectedPosition = position; + mSelectionOffset = positionOffset; + invalidate(); + } + + @Override + protected void onDraw(Canvas canvas) { + final int height = getHeight(); + final int childCount = getChildCount(); + + // Thick colored underline below the current selection + if (childCount > 0) { + View selectedTitle = getChildAt(mSelectedPosition); + int left = selectedTitle.getLeft(); + int right = selectedTitle.getRight(); + + if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) { + // Draw the selection partway between the tabs + View nextTitle = getChildAt(mSelectedPosition + 1); + left = (int) (mSelectionOffset * nextTitle.getLeft() + + (1.0f - mSelectionOffset) * left); + right = (int) (mSelectionOffset * nextTitle.getRight() + + (1.0f - mSelectionOffset) * right); + } + + canvas.drawRect(left, height - mSelectedIndicatorHeight, right, + height, mSelectedIndicatorPaint); + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/android/common/view/SlidingTabStrip.java b/app/src/main/java/com/example/android/common/view/SlidingTabStrip.java deleted file mode 100644 index cf3f771..0000000 --- a/app/src/main/java/com/example/android/common/view/SlidingTabStrip.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2014 Chris Banes - * - * 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.example.android.common.view; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.support.annotation.ColorInt; -import android.util.AttributeSet; -import android.view.View; -import android.widget.LinearLayout; - -class SlidingTabStrip extends LinearLayout { - - private int mSelectedIndicatorHeight; - private final Paint mSelectedIndicatorPaint; - - private int mSelectedPosition; - private float mSelectionOffset; - - SlidingTabStrip(Context context) { - this(context, null); - } - - SlidingTabStrip(Context context, AttributeSet attrs) { - super(context, attrs); - setWillNotDraw(false); - mSelectedIndicatorPaint = new Paint(); - } - - void setSelectedIndicatorColor(@ColorInt int color) { - mSelectedIndicatorPaint.setColor(color); - invalidate(); - } - - void setSelectedIndicatorHeight(int height) { - mSelectedIndicatorHeight = height; - invalidate(); - } - - void onViewPagerPageChanged(int position, float positionOffset) { - mSelectedPosition = position; - mSelectionOffset = positionOffset; - invalidate(); - } - - @Override - protected void onDraw(Canvas canvas) { - final int height = getHeight(); - final int childCount = getChildCount(); - - // Thick colored underline below the current selection - if (childCount > 0) { - View selectedTitle = getChildAt(mSelectedPosition); - int left = selectedTitle.getLeft(); - int right = selectedTitle.getRight(); - - if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) { - // Draw the selection partway between the tabs - View nextTitle = getChildAt(mSelectedPosition + 1); - left = (int) (mSelectionOffset * nextTitle.getLeft() + - (1.0f - mSelectionOffset) * left); - right = (int) (mSelectionOffset * nextTitle.getRight() + - (1.0f - mSelectionOffset) * right); - } - - canvas.drawRect(left, height - mSelectedIndicatorHeight, right, - height, mSelectedIndicatorPaint); - } - } - -} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_live.xml b/app/src/main/res/layout/fragment_live.xml index 01e0530..4a09196 100644 --- a/app/src/main/res/layout/fragment_live.xml +++ b/app/src/main/res/layout/fragment_live.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - - + + diff --git a/app/src/main/res/values/defaults.xml b/app/src/main/res/values/defaults.xml deleted file mode 100644 index f569fa9..0000000 --- a/app/src/main/res/values/defaults.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file