This file contains hidden or 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 TextWatcherAdapter(private var field: (String) -> Unit) : TextWatcher { | |
| private var isInEditMode = false | |
| var tmp = "" | |
| override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { | |
| } | |
| override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { | |
| } |
This file contains hidden or 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 LoginArch2WaysBindingViewModel : ViewModel() { | |
| var email: ObservableField<String>? = ObservableField("") | |
| var password: ObservableField<String>? = ObservableField("") | |
| var emailOnChange = TextWatcherAdapter({s -> | |
| email.set(s) | |
| readyToLogin?.set(isCanLogin()) | |
| }) | |
| var passwordOnChange = TextWatcherAdapter({s -> |
This file contains hidden or 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
| <AutoCompleteTextView | |
| android:id="@+id/email" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:hint="@string/prompt_email" | |
| android:inputType="textEmailAddress" | |
| android:text="@={viewModel.email}" | |
| android:addTextChangedListener="@{viewModel.emailOnChange}" | |
| android:maxLines="1" /> |
This file contains hidden or 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
| override fun onInit() { | |
| viewModel?.readyToLogin?.set(false) | |
| viewModel?.onClickLogin?.set(View.OnClickListener { _ -> | |
| view.performLogin(viewModel?.email?.get() + " " + viewModel?.password?.get()) | |
| viewModel!!.email.set("") | |
| viewModel!!.password.set("") | |
| }) | |
| } |
This file contains hidden or 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
| var binding: ActivityLoginArch2WaysBindingBinding? = null | |
| var viewModel: LoginArch2WaysBindingViewModel? = null | |
| var presenter: LoginArch2WaysBindingInf.PresenterInf? = null | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| initView() | |
| initViewModel() | |
| initPresenter() | |
| } |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <resources> | |
| <attr name="imageRatio" format="enum"> | |
| <enum name="square" value="0" /> | |
| <enum name="W2L1" value="1" /> | |
| </attr> | |
| <attr name="imageOrientation" format="enum"> | |
| <enum name="landscape" value="0"/> | |
| <enum name="portrait" value="1"/> | |
| </attr> |
This file contains hidden or 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 ImageRatioView : AppCompatImageView { | |
| var imageOrientation: Int? = 0 | |
| var imageRatio: Int? = 0 | |
| val LANDSCAPE = 0 | |
| val PORTRAIT = 1 | |
| val SQUARE = 0 | |
| val RATIO_2_1 = 1 | |
| val RATIO_2_1_DIVISION = 0.5 | |
| val PIXEL_PERFECT = 1 |
This file contains hidden or 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
| <ta.com.workshop2.ImageRatioView | |
| android:id="@+id/banner" | |
| android:src="@drawable/meet" | |
| android:background="@color/colorAccent" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:scaleType="fitXY" | |
| app:imageOrientation="landscape" | |
| app:imageRatio="W2L1" /> |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.v4.widget.NestedScrollView | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent"> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" |
This file contains hidden or 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
| private fun initCardViewWithNormalWay() { | |
| val cardView = findViewById(R.id.card_view) as CardView | |
| cardView.setOnTouchListener { v, event -> | |
| Log.d("ANIMATE", event.toString()) | |
| when (event.action) { | |
| MotionEvent.ACTION_DOWN -> { | |
| v.animate().cancel() | |
| v.animate().scaleY(0.96f).scaleX(0.96f).setDuration(200).start() | |
| val img = v.findViewById(R.id.imageBackground) |