完善我的信息-修改密码接口

0515
panqihua 5 years ago
parent e8ac59ea84
commit e235e1d91d
  1. 7
      app/src/main/java/com/community/pocket/data/main/info/InfoRequest.java
  2. 9
      app/src/main/java/com/community/pocket/ui/login/LoginActivity.java
  3. 9
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostContent.java
  4. 17
      app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
  5. 4
      app/src/main/java/com/community/pocket/ui/main/ui/info/InfoResponse.java
  6. 3
      app/src/main/java/com/community/pocket/ui/register/RegisterActivity.java
  7. 1
      app/src/main/res/values-en-rUS/strings.xml
  8. 1
      app/src/main/res/values-zh-rCN/strings.xml
  9. 1
      app/src/main/res/values/strings.xml

@ -36,6 +36,7 @@ public class InfoRequest {
.add("oldPassword", oldPassword)
.add("newPassword", newPassword)
.add("token", LocalToken.getToken())
.add("username", LocalToken.getUsername())
.build());
}
@ -43,6 +44,10 @@ public class InfoRequest {
@HttpRequest("/my/info")
public void loadInfo(MutableLiveData<InfoResponse> liveData) {
HttpUtil.getRequest(HttpUtil.Method.GET,
new SimpleHttpParse<InfoResponse>(liveData).getInterface(InfoResponse.class));
new SimpleHttpParse<InfoResponse>(liveData).getInterface(InfoResponse.class),
new FormBody.Builder()
.add("token", LocalToken.getToken())
.add("username", LocalToken.getUsername())
.build());
}
}

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
@ -94,7 +95,11 @@ public class LoginActivity extends BaseActivity {
Token token = response.getToken();
LocalToken.getInstance(token);
startActivity(new Intent(getBaseContext(), MainMenu.class));
response.toast(getBaseContext());
if (Looper.myLooper() == null) {
Looper.prepare();
response.toast(getBaseContext());
Looper.loop();
}
//Complete and destroy login activity once successful
finish();
}
@ -149,6 +154,8 @@ public class LoginActivity extends BaseActivity {
if (loginResponse.getResult() == Response.Result.OK) {
saveTokenToDB(loginResponse);
} else {
loginResponse.toast(getApplicationContext());
}
}
});

@ -1,6 +1,5 @@
package com.community.pocket.ui.main.ui.forum.post;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -14,9 +13,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.Observer;
import com.community.pocket.R;
import com.community.pocket.data.model.LocalToken;
import com.community.pocket.ui.BaseFragment;
import com.community.pocket.ui.login.LoginActivity;
import com.community.pocket.ui.main.ui.forum.main.ForumFragment;
import com.community.pocket.ui.main.ui.share.Response;
import com.community.pocket.ui.main.ui.share.ShowWordCount;
@ -78,12 +75,6 @@ abstract class ForumPostContent extends BaseFragment {
return;
}
if (invalidToken(forumPostResponse)) {
LocalToken.logout();
startActivity(new Intent(getContext(), LoginActivity.class));
return;
}
forumPostResponse.toast(getContext());
if (forumPostResponse.getResult() == Response.Result.OK) {
ForumFragment forumFragment = getParentFragment(4);

@ -199,7 +199,9 @@ public class InfoFragment extends BaseFragment {
mobie.setText(myInfo.getMobie());
email.setText(myInfo.getEmail());
loadChart(myInfo.getScoreHistory());
if (myInfo.getScoreHistory() != null) {
loadChart(myInfo.getScoreHistory());
}
}
/**
@ -260,10 +262,15 @@ public class InfoFragment extends BaseFragment {
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Event(value = R.id.logout)
private void logout(View view) {
AppDatabase.getInstance(getContext()).tokenDao().delete(LocalToken.getTokenInstance());
LocalToken.logout();
startActivity(new Intent(view.getContext(), LoginActivity.class));
private void logout(final View view) {
new Thread(new Runnable() {
@Override
public void run() {
AppDatabase.getInstance(getContext()).tokenDao().delete(LocalToken.getTokenInstance());
LocalToken.logout();
startActivity(new Intent(view.getContext(), LoginActivity.class));
}
}).start();
}
//加载图表数据

@ -30,7 +30,9 @@ public class InfoResponse extends ToastResponse<InfoResponse.Msg> {
ok(R.string.load_info_ok),
fail(R.string.load_info_fail),
modify_pwd_ok(R.string.modify_pwd_ok),
modify_pwd_fail(R.string.modify_pwd_fail);
modify_pwd_fail(R.string.modify_pwd_fail),
modify_oldpwd_fail(R.string.modify_oldpwd_fail),
token(R.string.invalid_token);
private Integer msg;

@ -17,6 +17,7 @@ import com.community.pocket.R;
import com.community.pocket.ui.BaseActivity;
import com.community.pocket.ui.listener.MyTextChange;
import com.community.pocket.ui.login.LoginActivity;
import com.community.pocket.ui.main.ui.share.Response;
import com.community.pocket.util.PropertiesUtil;
import org.xutils.view.annotation.ContentView;
@ -114,7 +115,7 @@ public class RegisterActivity extends BaseActivity {
}
registerResponse.toast(getBaseContext());
if (registerResponse.getBody() == RegisterResponse.Msg.ok) {
if (registerResponse.getResult() == Response.Result.OK) {
startActivity(new Intent(getApplicationContext(), LoginActivity.class));
//Complete and destroy login activity once successful
finish();

@ -169,4 +169,5 @@
<string name="invalid_date_before">start date must be before end date</string>
<string name="invalid_token">token error,please login</string>
<string name="no_more_forum">no more forum</string>
<string name="modify_oldpwd_fail">modify error</string>
</resources>

@ -169,4 +169,5 @@
<string name="invalid_date_before">开始日期必须小于结束日期</string>
<string name="invalid_token">身份有效期已过,请重新登录</string>
<string name="no_more_forum">没有更多帖子</string>
<string name="modify_oldpwd_fail">修改密码失败,原密码不正确</string>
</resources>

@ -170,6 +170,7 @@
<string name="invalid_date_before">start date must be before end date</string>
<string name="invalid_token">token error,please login</string>
<string name="no_more_forum">no more forum</string>
<string name="modify_oldpwd_fail">modify error</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

Loading…
Cancel
Save