Use AppCompat classes as base classes in custom views

This commit is contained in:
serso 2017-07-11 12:26:41 +02:00
parent aa1960b2bf
commit 64d82423fe
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,6 @@
package org.solovyev.android.views; /** package org.solovyev.android.views;
/*
* DO WHAT YOU WANT TO PUBLIC LICENSE * DO WHAT YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004 * Version 2, December 2004
* <p/> * <p/>
@ -14,8 +16,12 @@ package org.solovyev.android.views; /**
* 0. You just DO WHAT YOU WANT TO. * 0. You just DO WHAT YOU WANT TO.
*/ */
import static android.util.TypedValue.COMPLEX_UNIT_SP;
import static android.util.TypedValue.applyDimension;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.text.Layout.Alignment; import android.text.Layout.Alignment;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
@ -24,9 +30,6 @@ import android.util.TimingLogger;
import android.util.TypedValue; import android.util.TypedValue;
import android.widget.TextView; import android.widget.TextView;
import static android.util.TypedValue.COMPLEX_UNIT_SP;
import static android.util.TypedValue.applyDimension;
/** /**
* Text view that auto adjusts text size to fit within the view. * Text view that auto adjusts text size to fit within the view.
* If the text size equals the minimum text size and still does not * If the text size equals the minimum text size and still does not
@ -36,7 +39,7 @@ import static android.util.TypedValue.applyDimension;
* @since Apr 4, 2011 * @since Apr 4, 2011
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class AutoResizeTextView extends TextView { public class AutoResizeTextView extends AppCompatTextView {
// Minimum text size for this text view // Minimum text size for this text view
public static final float MIN_TEXT_SIZE = 20; public static final float MIN_TEXT_SIZE = 20;

View File

@ -9,6 +9,7 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Build; import android.os.Build;
import android.support.v7.widget.AppCompatSeekBar;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.SeekBar; import android.widget.SeekBar;
@ -19,7 +20,7 @@ import org.solovyev.android.calculator.R;
/** /**
* SeekBar for discrete values with a label displayed underneath the active tick * SeekBar for discrete values with a label displayed underneath the active tick
*/ */
public class DiscreteSeekBar extends SeekBar { public class DiscreteSeekBar extends AppCompatSeekBar {
// Duration of how quick the SeekBar thumb should snap to its destination value // Duration of how quick the SeekBar thumb should snap to its destination value
private static final int THUMB_SNAP_DURATION_TIME = 100; private static final int THUMB_SNAP_DURATION_TIME = 100;
private final Paint mPaint = new Paint(); private final Paint mPaint = new Paint();