-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
金良善
authored and
金良善
committed
Sep 12, 2017
1 parent
258255d
commit 90e3209
Showing
16 changed files
with
317 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
app/src/main/kotlin/com/fashare/mvvm_juejin/view/profile/login/LoginActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.fashare.mvvm_juejin.view.profile.login | ||
|
||
import android.databinding.DataBindingUtil | ||
import android.os.Bundle | ||
import com.fashare.base_ui.BaseActivity | ||
import com.fashare.mvvm_juejin.R | ||
import com.fashare.mvvm_juejin.databinding.ActivityLoginBinding | ||
import com.fashare.mvvm_juejin.viewmodel.LoginVM | ||
|
||
class LoginActivity : BaseActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
DataBindingUtil.setContentView<ActivityLoginBinding>(this, R.layout.activity_login).apply{ | ||
this.loginVM = LoginVM() | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/kotlin/com/fashare/mvvm_juejin/viewmodel/LoginVM.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.fashare.mvvm_juejin.viewmodel | ||
|
||
import android.app.Activity | ||
import android.databinding.ObservableField | ||
import android.view.View | ||
import com.fashare.mvvm_juejin.repo.Composers | ||
import com.fashare.mvvm_juejin.repo.JueJinApis | ||
import com.fashare.net.ApiFactory | ||
|
||
/** | ||
* <pre> | ||
* author : jinliangshan | ||
* e-mail : [email protected] | ||
* desc : | ||
* </pre> | ||
*/ | ||
class LoginVM(){ | ||
var userName = ObservableField<String>("18818276018") | ||
var passWord = ObservableField<String>("qwe13579") | ||
|
||
val doLogin = View.OnClickListener{ view: View -> | ||
ApiFactory.getApi(JueJinApis.User::class.java) | ||
.login(JueJinApis.User.LoginParam().apply{ | ||
this.user = userName.get() | ||
this.psd = passWord.get() | ||
}.toMap()) | ||
.compose(Composers.compose()) | ||
.subscribe({ | ||
(view.context as Activity).finish() | ||
}, {}) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/kotlin/com/fashare/mvvm_juejin/viewmodel/ProfileVM.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.fashare.mvvm_juejin.viewmodel | ||
|
||
import android.content.Intent | ||
import android.view.View | ||
import com.fashare.mvvm_juejin.view.profile.login.LoginActivity | ||
|
||
/** | ||
* <pre> | ||
* author : jinliangshan | ||
* e-mail : [email protected] | ||
* desc : | ||
* </pre> | ||
*/ | ||
class ProfileVM(){ | ||
val toLogin = View.OnClickListener{ | ||
it.context.startActivity(Intent(it.context, LoginActivity:: class.java)) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<layout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:bind="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
<variable name="loginVM" type="com.fashare.mvvm_juejin.viewmodel.LoginVM"/> | ||
</data> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:gravity="center_horizontal" | ||
android:padding="@dimen/login_margin" | ||
android:background="@color/colorPrimary"> | ||
|
||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/login_margin" | ||
android:src="@mipmap/login_logo"/> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:layout_marginTop="@dimen/login_margin" | ||
android:background="@color/login_form_bg"> | ||
|
||
<EditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/login_edit_padding" | ||
android:hint="手机号/邮箱" | ||
android:text="@{loginVM.userName}" | ||
android:textSize="16sp"/> | ||
|
||
<EditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/login_edit_padding" | ||
android:inputType="textPassword" | ||
android:hint="密码" | ||
android:text="@{loginVM.passWord}" | ||
android:textSize="16sp"/> | ||
|
||
</LinearLayout> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
android:padding="@dimen/login_btn_padding" | ||
android:gravity="center" | ||
android:background="@android:color/holo_blue_dark" | ||
android:text="登录" | ||
android:textColor="@color/login_text_default" | ||
android:textSize="16sp" | ||
android:onClick="@{loginVM.doLogin}"/> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="忘记密码?" | ||
android:textColor="@color/login_text_light" | ||
android:textSize="13sp"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentRight="true" | ||
android:text="注册账号" | ||
android:textColor="@color/login_text_default" | ||
android:textSize="13sp"/> | ||
|
||
</RelativeLayout> | ||
|
||
</LinearLayout> | ||
|
||
</layout> | ||
|
Oops, something went wrong.