Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.sharyfire.widgetthemespower.TextTextView
android:id="@+id/textTextView"
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textTextView.setText1("Primary text")
textTextView.setText2("Secondary text")
}
}
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="TextTextView">
<attr name="textTextViewText1Style" format="reference"/>
<attr name="textTextViewText2Style" format="reference"/>
</declare-styleable>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:theme="@style/TextTextViewTheme"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text1TextView"
class TextTextView: LinearLayout {
constructor(context: Context?) : super(context) {
init()
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init()
}
data class PractitionersModel(val data: Any)
object Network {
fun requestPracticioners(onSuccess: (PractitionersModel) -> Unit, onError: (Throwable) -> Unit)
{
// типа сетевой запрос
}
}
interface Activity {
public class AppBase extends MultiDexApplication {
private static AppBase inst;
@Override
public void onCreate() {
super.onCreate();
inst = this;
}
public static AppBase getInst(){
package com.sharyfire.countryphonedetector
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import io.michaelrocks.libphonenumber.android.NumberParseException
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil
import io.michaelrocks.libphonenumber.android.Phonenumber.PhoneNumber
override fun afterTextChanged(editable: Editable?) {
val number = editable.toString()
val countryIsoCode = getCountryIsoCode(number)
countryTextView.text = countryIsoCode ?: "Can't detect a country"
}