Last active
July 15, 2020 18:43
-
-
Save lawloretienne/0b7625e7f4d0fd9157c5298275c92db6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomTextView : AppCompatTextView { | |
constructor(context: Context) : super(context) { | |
init(context) | |
} | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { | |
init(context, attrs) | |
} | |
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super( | |
context, | |
attrs, | |
defStyle | |
) { | |
init(context, attrs) | |
} | |
private fun init(context: Context, attrs: AttributeSet? = null) { | |
if (!isInEditMode) { | |
@Suppress("Recycle") | |
context.obtainStyledAttributes(attrs, R.styleable.CustomTextView).use { | |
setUpCharacterSpacing( | |
it.getFloat(R.styleable.CustomTextView_characterSpacing, 0.0f) | |
) | |
setUpLineSpacing( | |
it.getDimension(R.styleable.CustomTextView_lineSpacing, 0f) | |
) | |
} | |
paintFlags = paintFlags or Paint.SUBPIXEL_TEXT_FLAG | |
} | |
} | |
private fun setUpLineSpacing(lineSpacing: Float) { | |
if (lineSpacing != 0f) { | |
setLineSpacing(lineSpacing - textSize, 1f) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.constraintlayout.widget.ConstraintLayout | |
android:id="@+id/constraintLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/grey_100"> | |
<com.sample.android.common.widget.CustomTextView | |
android:id="@+id/header" | |
style="@style/Body_S_Text_Style" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="24dp" | |
android:gravity="center" | |
android:maxLines="3" | |
android:paddingStart="24dp" | |
android:paddingEnd="24dp" | |
android:text="@string/group_meditation_title" | |
android:textColor="@{viewModel.state.eventState instanceof EventState.Live ? @color/grey_100 : @color/grey_900}" | |
android:visibility="invisible" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
tools:text="LIVE" /> | |
<ImageView | |
android:id="@+id/closeIcon" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:background="@drawable/ripple_circle" | |
android:contentDescription="@string/close_accessibility" | |
android:onClick="@{(view) -> viewModel.onCloseClick()}" | |
android:padding="@dimen/spacing_medium" | |
android:src="@{viewModel.state.eventState instanceof EventState.Live ? @drawable/ic_close_24dp_pale : @drawable/ic_close_24dp_purple}" | |
app:layout_constraintBottom_toBottomOf="@id/header" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="@id/header" | |
tools:src="@drawable/ic_close_24dp_purple" /> | |
<com.airbnb.lottie.LottieAnimationView | |
android:id="@+id/popcornAnimation" | |
android:layout_width="0dp" | |
android:layout_height="0dp" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent" | |
android:background="@color/red_500" | |
android:visibility="visible" | |
app:layout_constraintDimensionRatio="750:1080" | |
app:lottie_autoPlay="true" | |
app:lottie_fileName="GroupMeditation_05-Popcorn_final.json" | |
app:lottie_loop="true" /> | |
<com.sample.android.common.widget.CustomTextView | |
android:id="@+id/userCounter" | |
style="@style/Title_XL_Text_Style" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="24dp" | |
android:layout_marginTop="42dp" | |
android:layout_marginEnd="24dp" | |
android:maxLines="1" | |
android:elevation="1dp" | |
android:text="@{viewModel.state.userCountText}" | |
android:visibility="visible" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@id/closeIcon" | |
tools:text="4,929" /> | |
<com.sample.android.common.widget.CustomTextView | |
android:id="@+id/userCountTitle" | |
style="@style/Title_S_Text_Style" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginStart="24dp" | |
android:layout_marginTop="8dp" | |
android:layout_marginEnd="24dp" | |
android:gravity="center" | |
android:elevation="1dp" | |
android:maxLines="3" | |
android:text="@string/group_meditation_end_screen_title" | |
android:visibility="visible" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@id/userCounter" /> | |
</androidx.constraintlayout.widget.ConstraintLayout> |
Author
lawloretienne
commented
Jul 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment