-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
6 changed files
with
283 additions
and
0 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
87 changes: 87 additions & 0 deletions
87
app/src/main/java/com/github/jsbxyyx/xbook/ForgetpwdActivity.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,87 @@ | ||
package com.github.jsbxyyx.xbook; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.jsbxyyx.xbook.common.Common; | ||
import com.github.jsbxyyx.xbook.common.DataCallback; | ||
import com.github.jsbxyyx.xbook.common.SPUtils; | ||
import com.github.jsbxyyx.xbook.common.SessionManager; | ||
import com.github.jsbxyyx.xbook.data.BookNetHelper; | ||
|
||
public class ForgetpwdActivity extends AppCompatActivity { | ||
|
||
private BookNetHelper bookNetHelper; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_forgetpwd); | ||
|
||
bookNetHelper = new BookNetHelper(); | ||
|
||
EditText et_login_user = findViewById(R.id.et_login_user); | ||
EditText et_login_password = findViewById(R.id.et_login_password); | ||
EditText et_login_code = findViewById(R.id.et_login_code); | ||
Button btn_send_code = findViewById(R.id.btn_send_code); | ||
Button btn_resetpwd = findViewById(R.id.btn_resetpwd); | ||
TextView tv_login = findViewById(R.id.tv_login); | ||
|
||
btn_send_code.setOnClickListener((v) -> { | ||
String user = et_login_user.getText().toString(); | ||
String password = et_login_password.getText().toString(); | ||
bookNetHelper.sendCodePasswordRecovery(user, new DataCallback<JsonNode>() { | ||
@Override | ||
public void call(JsonNode dataObject, Throwable err) { | ||
runOnUiThread(() -> { | ||
if (err != null) { | ||
Toast.makeText(getBaseContext(), "err:" + err.getMessage(), Toast.LENGTH_LONG).show(); | ||
return; | ||
} | ||
int success = dataObject.get("success").asInt(); | ||
if (success == 1) { | ||
Toast.makeText(getBaseContext(), "发送成功", Toast.LENGTH_LONG).show(); | ||
} else { | ||
Toast.makeText(getBaseContext(), dataObject.get("err").asText(), Toast.LENGTH_LONG).show(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
btn_resetpwd.setOnClickListener((v) -> { | ||
String user = et_login_user.getText().toString(); | ||
String password = et_login_password.getText().toString(); | ||
String code = et_login_code.getText().toString(); | ||
bookNetHelper.resetpwd(user, password, code, new DataCallback<JsonNode>() { | ||
@Override | ||
public void call(JsonNode respData, Throwable err) { | ||
runOnUiThread(() -> { | ||
if (err != null) { | ||
Toast.makeText(getBaseContext(), err.getMessage(), Toast.LENGTH_LONG).show(); | ||
return; | ||
} | ||
if (respData.get("success").asInt() == 1) { | ||
Toast.makeText(getBaseContext(), "重置成功", Toast.LENGTH_LONG).show(); | ||
} else { | ||
Toast.makeText(getBaseContext(), respData.get("message").asText(""), Toast.LENGTH_LONG).show(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
tv_login.setOnClickListener((v) -> { | ||
Intent intent = new Intent(getBaseContext(), LoginActivity.class); | ||
startActivity(intent); | ||
}); | ||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout 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" | ||
android:orientation="vertical" | ||
android:padding="5dp" | ||
tools:context=".ForgetpwdActivity"> | ||
|
||
<EditText | ||
android:id="@+id/et_login_user" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:maxLines="1" | ||
android:singleLine="true" | ||
android:hint="请输入邮箱" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<EditText | ||
android:id="@+id/et_login_code" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="0.6" | ||
android:inputType="text" | ||
android:maxLines="1" | ||
android:singleLine="true" | ||
android:hint="请输入验证码" /> | ||
|
||
<Button | ||
android:id="@+id/btn_send_code" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="发送" /> | ||
|
||
</LinearLayout> | ||
|
||
<EditText | ||
android:id="@+id/et_login_password" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="textPassword" | ||
android:maxLines="1" | ||
android:singleLine="true" | ||
android:hint="请输入密码" /> | ||
|
||
<Button | ||
android:id="@+id/btn_resetpwd" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="重置密码" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_login" | ||
android:layout_width="match_parent" | ||
android:layout_height="30dp" | ||
android:layout_gravity="center" | ||
android:gravity="center" | ||
android:text="登录" /> | ||
|
||
</LinearLayout> |
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