mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
CheckmarkButtonView: avoid layout inflation
This commit is contained in:
@@ -25,21 +25,16 @@ import android.view.*;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.models.*;
|
|
||||||
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
import org.isoron.uhabits.activities.habits.list.controllers.*;
|
||||||
|
import org.isoron.uhabits.models.*;
|
||||||
import org.isoron.uhabits.utils.*;
|
import org.isoron.uhabits.utils.*;
|
||||||
|
|
||||||
import butterknife.*;
|
public class CheckmarkButtonView extends TextView
|
||||||
|
|
||||||
public class CheckmarkButtonView extends FrameLayout
|
|
||||||
{
|
{
|
||||||
private int color;
|
private int color;
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@BindView(R.id.tvCheck)
|
|
||||||
TextView tvCheck;
|
|
||||||
|
|
||||||
private StyledResources res;
|
private StyledResources res;
|
||||||
|
|
||||||
public CheckmarkButtonView(Context context)
|
public CheckmarkButtonView(Context context)
|
||||||
@@ -82,20 +77,20 @@ public class CheckmarkButtonView extends FrameLayout
|
|||||||
|
|
||||||
if (value == Checkmark.CHECKED_EXPLICITLY)
|
if (value == Checkmark.CHECKED_EXPLICITLY)
|
||||||
{
|
{
|
||||||
tvCheck.setText(R.string.fa_check);
|
setText(R.string.fa_check);
|
||||||
tvCheck.setTextColor(color);
|
setTextColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == Checkmark.CHECKED_IMPLICITLY)
|
if (value == Checkmark.CHECKED_IMPLICITLY)
|
||||||
{
|
{
|
||||||
tvCheck.setText(R.string.fa_check);
|
setText(R.string.fa_check);
|
||||||
tvCheck.setTextColor(lowContrastColor);
|
setTextColor(lowContrastColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == Checkmark.UNCHECKED)
|
if (value == Checkmark.UNCHECKED)
|
||||||
{
|
{
|
||||||
tvCheck.setText(R.string.fa_times);
|
setText(R.string.fa_times);
|
||||||
tvCheck.setTextColor(lowContrastColor);
|
setTextColor(lowContrastColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
@@ -103,15 +98,16 @@ public class CheckmarkButtonView extends FrameLayout
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
addView(
|
|
||||||
inflate(getContext(), R.layout.list_habits_card_checkmark, null));
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
res = new StyledResources(getContext());
|
res = new StyledResources(getContext());
|
||||||
|
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
setHapticFeedbackEnabled(false);
|
setHapticFeedbackEnabled(false);
|
||||||
|
|
||||||
tvCheck.setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
setMinHeight(getResources().getDimensionPixelSize(R.dimen.checkmarkHeight));
|
||||||
|
setMinWidth(getResources().getDimensionPixelSize(R.dimen.checkmarkWidth));
|
||||||
|
|
||||||
|
setFocusable(false);
|
||||||
|
setGravity(Gravity.CENTER);
|
||||||
|
setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
~
|
|
||||||
~ This file is part of Loop Habit Tracker.
|
|
||||||
~
|
|
||||||
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by the
|
|
||||||
~ Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
~ option) any later version.
|
|
||||||
~
|
|
||||||
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
|
|
||||||
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
~ more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License along
|
|
||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/tvCheck"
|
|
||||||
style="@style/ListHabits.Checkmark" />
|
|
||||||
Reference in New Issue
Block a user