Cache Paints in drag buttons

This commit is contained in:
Sergey Solovyev
2017-06-07 21:06:15 +02:00
parent 1ec5714174
commit 2c8e169363
9 changed files with 495 additions and 320 deletions

View File

@@ -96,7 +96,7 @@ public abstract class BaseActivity extends AppCompatActivity implements SharedPr
if (view instanceof TextView) {
final TextView textView = (TextView) view;
final Typeface oldTypeface = textView.getTypeface();
if (oldTypeface == newTypeface) {
if (oldTypeface != null && oldTypeface.equals(newTypeface)) {
return;
}
final int style = oldTypeface != null ? oldTypeface.getStyle() : Typeface.NORMAL;

View File

@@ -1,5 +1,12 @@
package org.solovyev.android.calculator.keyboard;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING;
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
import static android.view.HapticFeedbackConstants.KEYBOARD_TAP;
import static org.solovyev.android.calculator.App.cast;
import static org.solovyev.android.calculator.Preferences.Gui.Mode.simple;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
@@ -40,13 +47,6 @@ import javax.inject.Inject;
import dagger.Lazy;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING;
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
import static android.view.HapticFeedbackConstants.KEYBOARD_TAP;
import static org.solovyev.android.calculator.App.cast;
import static org.solovyev.android.calculator.Preferences.Gui.Mode.simple;
public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, View.OnClickListener {
public static float getTextScale(@NonNull Context context) {
@@ -212,7 +212,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
private static class AdjusterHelper implements Adjuster.Helper<DirectionDragImageButton> {
public static AdjusterHelper instance = new AdjusterHelper();
public static final AdjusterHelper instance = new AdjusterHelper();
@Override
public void apply(@NonNull DirectionDragImageButton view, float textSize) {

View File

@@ -1,5 +1,7 @@
package org.solovyev.android.views;
import static android.graphics.Matrix.MSCALE_Y;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -11,13 +13,11 @@ import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.TextView;
import static android.graphics.Matrix.MSCALE_Y;
public class Adjuster {
private static final float[] MATRIX = new float[9];
@NonNull
private static Helper<TextView> textViewHelper = new Helper<TextView>() {
private static final Helper<TextView> textViewHelper = new Helper<TextView>() {
@Override
public void apply(@NonNull TextView view, float textSize) {
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);