Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
EBike-Administer-Tool
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
倪力烽
EBike-Administer-Tool
Commits
194b9fcb
Commit
194b9fcb
authored
Jun 09, 2017
by
倪力烽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 已完成个人信息获取
2. 已完成密码修改
parent
9db19690
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
664 additions
and
65 deletions
+664
-65
app/src/main/AndroidManifest.xml
+5
-1
app/src/main/java/com/senthink/ebike_administrer_tool/BaseActivity.java
+1
-2
app/src/main/java/com/senthink/ebike_administrer_tool/LoginActivity.java
+39
-8
app/src/main/java/com/senthink/ebike_administrer_tool/MainActivity.java
+7
-0
app/src/main/java/com/senthink/ebike_administrer_tool/api/ApiManager.java
+30
-0
app/src/main/java/com/senthink/ebike_administrer_tool/api/UserApi.java
+12
-2
app/src/main/java/com/senthink/ebike_administrer_tool/asynchttp/AsyncClient.java
+13
-0
app/src/main/java/com/senthink/ebike_administrer_tool/asynchttp/AsyncHttp.java
+59
-0
app/src/main/java/com/senthink/ebike_administrer_tool/bean/login/LoginBean.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/bean/login/LoginBody.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/bean/login/LoginUser.java
+16
-1
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/GetUserByName.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/GetUserInfoById.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/ModifyPswBean.java
+47
-0
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/ModifyResponseBody.java
+43
-0
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/UserByName.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/common/Common.java
+8
-2
app/src/main/java/com/senthink/ebike_administrer_tool/common/CommonUrl.java
+14
-0
app/src/main/java/com/senthink/ebike_administrer_tool/fragment/MyInformationFragment.java
+104
-6
app/src/main/java/com/senthink/ebike_administrer_tool/model/UserInfoModel.java
+3
-0
app/src/main/java/com/senthink/ebike_administrer_tool/model/callback/LoginCallback.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/model/callback/UserInfoCallback.java
+1
-1
app/src/main/java/com/senthink/ebike_administrer_tool/model/impl/LoginModelImpl.java
+12
-7
app/src/main/java/com/senthink/ebike_administrer_tool/model/impl/UserInfoModelImpl.java
+97
-12
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/MyInforPresenter.java
+2
-2
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/impl/LoginPresenterImpl.java
+1
-2
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/impl/MyInforPresenterImpl.java
+24
-4
app/src/main/java/com/senthink/ebike_administrer_tool/view/IMyInformationFragment.java
+2
-2
app/src/main/java/com/senthink/ebike_administrer_tool/view/LoginView.java
+1
-1
app/src/main/res/layout/dialog_modify_pawssword.xml
+78
-0
app/src/main/res/layout/layout_login.xml
+2
-4
app/src/main/res/layout/layout_main.xml
+1
-2
app/src/main/res/values-v21/styles.xml
+11
-0
app/src/main/res/values/dimens.xml
+2
-0
app/src/main/res/values/strings.xml
+8
-0
app/src/main/res/values/styles.xml
+15
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
194b9fcb
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<application
<application
android:name=
".MyApplication"
android:allowBackup=
"true"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
...
@@ -19,7 +20,9 @@
...
@@ -19,7 +20,9 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".MainActivity"
/>
<activity
android:name=
".MainActivity"
android:launchMode=
"singleTop"
android:windowSoftInputMode=
"adjustResize"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/senthink/ebike_administrer_tool/BaseActivity.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
;
package
com
.
senthink
.
ebike_administrer_tool
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.PersistableBundle
;
import
android.os.PersistableBundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
...
@@ -21,12 +22,10 @@ public class BaseActivity extends AppCompatActivity {
...
@@ -21,12 +22,10 @@ public class BaseActivity extends AppCompatActivity {
@Override
@Override
public
void
onCreate
(
Bundle
savedInstanceState
,
PersistableBundle
persistentState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
,
PersistableBundle
persistentState
)
{
super
.
onCreate
(
savedInstanceState
,
persistentState
);
super
.
onCreate
(
savedInstanceState
,
persistentState
);
// TODO: 16/9/1 add the third service. eg.umeng ...
activity
=
this
;
activity
=
this
;
((
MyApplication
)
UIUtils
.
getContext
()).
addActivity
(
this
);
((
MyApplication
)
UIUtils
.
getContext
()).
addActivity
(
this
);
init
();
init
();
}
}
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/LoginActivity.java
View file @
194b9fcb
...
@@ -4,14 +4,17 @@ import android.content.Context;
...
@@ -4,14 +4,17 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.CheckBox
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.login.LoginUser
;
import
com.senthink.ebike_administrer_tool.common.Common
;
import
com.senthink.ebike_administrer_tool.presenter.impl.LoginPresenterImpl
;
import
com.senthink.ebike_administrer_tool.presenter.impl.LoginPresenterImpl
;
import
com.senthink.ebike_administrer_tool.utils.UIUtils
;
import
com.senthink.ebike_administrer_tool.view.LoginView
;
import
com.senthink.ebike_administrer_tool.view.LoginView
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -36,7 +39,7 @@ public class LoginActivity extends BaseActivity implements LoginView{
...
@@ -36,7 +39,7 @@ public class LoginActivity extends BaseActivity implements LoginView{
private
LoginPresenterImpl
mLoginPresenter
;
private
LoginPresenterImpl
mLoginPresenter
;
@Override
@Override
p
rotected
void
onCreate
(
Bundle
savedInstanceState
)
{
p
ublic
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
layout_login
);
setContentView
(
R
.
layout
.
layout_login
);
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
...
@@ -51,6 +54,13 @@ public class LoginActivity extends BaseActivity implements LoginView{
...
@@ -51,6 +54,13 @@ public class LoginActivity extends BaseActivity implements LoginView{
mLoginPresenter
.
login
();
mLoginPresenter
.
login
();
}
}
});
});
SharedPreferences
sp
=
getSharedPreferences
(
Common
.
LOGIN_USER_SHAREDPREFERENCE
,
MODE_PRIVATE
);
boolean
isChecked
=
sp
.
getBoolean
(
Common
.
USER_CHECKBOX_SELECTED_SHAREDPREFERENCE
,
false
);
if
(
isChecked
)
{
userNameEt
.
setText
(
sp
.
getString
(
Common
.
USER_NAME_SHAREDPREFERENCE
,
""
));
pswEt
.
setText
(
sp
.
getString
(
Common
.
USER_PASSWORD_SHAREDPREFERENCE
,
""
));
rememberCb
.
setChecked
(
true
);
}
}
}
@Override
@Override
public
String
getUserName
()
{
public
String
getUserName
()
{
...
@@ -74,10 +84,15 @@ public class LoginActivity extends BaseActivity implements LoginView{
...
@@ -74,10 +84,15 @@ public class LoginActivity extends BaseActivity implements LoginView{
public
void
toLoginActivity
(
LoginUser
loginUser
)
{
public
void
toLoginActivity
(
LoginUser
loginUser
)
{
Toast
.
makeText
(
this
,
loginUser
.
getUserName
()
+
Toast
.
makeText
(
this
,
loginUser
.
getUserName
()
+
" login success , to MainActivity"
,
Toast
.
LENGTH_SHORT
).
show
();
" login success , to MainActivity"
,
Toast
.
LENGTH_SHORT
).
show
();
saveInfo
(
loginUser
);
if
(
rememberCb
.
isChecked
())
{
saveInfo
(
loginUser
,
true
);
}
else
{
saveInfo
(
loginUser
,
false
);
}
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
intent
.
setClass
(
LoginActivity
.
this
,
MainActivity
.
class
);
intent
.
setClass
(
LoginActivity
.
this
,
MainActivity
.
class
);
startActivity
(
intent
);
startActivity
ForResult
(
intent
,
0
);
}
}
@Override
@Override
...
@@ -89,11 +104,27 @@ public class LoginActivity extends BaseActivity implements LoginView{
...
@@ -89,11 +104,27 @@ public class LoginActivity extends BaseActivity implements LoginView{
* @Description: 保存信息
* @Description: 保存信息
* @param loginUser
* @param loginUser
* */
* */
private
void
saveInfo
(
LoginUser
loginUser
)
{
private
void
saveInfo
(
LoginUser
loginUser
,
boolean
isChecked
)
{
SharedPreferences
preference
=
getSharedPreferences
(
"loginUser"
,
Context
.
MODE_PRIVATE
);
SharedPreferences
preference
=
getSharedPreferences
(
Common
.
LOGIN_USER_SHAREDPREFERENCE
,
Context
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
preference
.
edit
();
SharedPreferences
.
Editor
editor
=
preference
.
edit
();
editor
.
putString
(
"username"
,
loginUser
.
getUserName
());
editor
.
putString
(
Common
.
USER_NAME_SHAREDPREFERENCE
,
loginUser
.
getUserName
());
editor
.
putString
(
"password"
,
loginUser
.
getPassWord
());
editor
.
putString
(
Common
.
USER_PASSWORD_SHAREDPREFERENCE
,
loginUser
.
getPassWord
());
editor
.
putString
(
Common
.
USER_TOKEN_SHAREDPREFERENCE
,
loginUser
.
getToken
());
editor
.
putBoolean
(
Common
.
USER_CHECKBOX_SELECTED_SHAREDPREFERENCE
,
isChecked
);
editor
.
commit
();
editor
.
commit
();
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
Common
.
RE_LOGIN
)
{
Log
.
i
(
TAG
,
"onActivityResult: "
);
}
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
((
MyApplication
)
UIUtils
.
getContext
()).
removeActivity
(
this
);
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/MainActivity.java
View file @
194b9fcb
...
@@ -16,6 +16,7 @@ import com.senthink.ebike_administrer_tool.fragment.HandleIssueFragment;
...
@@ -16,6 +16,7 @@ import com.senthink.ebike_administrer_tool.fragment.HandleIssueFragment;
import
com.senthink.ebike_administrer_tool.fragment.MyInformationFragment
;
import
com.senthink.ebike_administrer_tool.fragment.MyInformationFragment
;
import
com.senthink.ebike_administrer_tool.fragment.ReplaceBatteryFragment
;
import
com.senthink.ebike_administrer_tool.fragment.ReplaceBatteryFragment
;
import
com.senthink.ebike_administrer_tool.fragment.SafeGuardFragment
;
import
com.senthink.ebike_administrer_tool.fragment.SafeGuardFragment
;
import
com.senthink.ebike_administrer_tool.utils.UIUtils
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -101,4 +102,10 @@ public class MainActivity extends BaseActivity {
...
@@ -101,4 +102,10 @@ public class MainActivity extends BaseActivity {
return
COUNT
;
return
COUNT
;
}
}
}
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
((
MyApplication
)
UIUtils
.
getContext
()).
removeActivity
(
this
);
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/api/ApiManager.java
View file @
194b9fcb
...
@@ -63,10 +63,25 @@ public class ApiManager {
...
@@ -63,10 +63,25 @@ public class ApiManager {
}
}
}
}
private
static
final
class
PostInterceptor
implements
Interceptor
{
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
Request
.
Builder
builder
=
chain
.
request
().
newBuilder
();
Request
requst
=
builder
.
addHeader
(
"Content-type"
,
"application/json"
)
.
addHeader
(
"Accept"
,
"application/json"
).
build
();
return
chain
.
proceed
(
requst
);
}
}
private
static
OkHttpClient
client
=
new
OkHttpClient
.
Builder
()
// client 中添加了以下属性
private
static
OkHttpClient
client
=
new
OkHttpClient
.
Builder
()
// client 中添加了以下属性
// .addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR)
// .addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR)
// .addInterceptor(new LoginInterceptor())
// .addInterceptor(new LoginInterceptor())
.
build
();
.
build
();
private
static
OkHttpClient
addTokenClient
=
new
OkHttpClient
.
Builder
()
.
addNetworkInterceptor
(
REWRITE_CACHE_CONTROL_INTERCEPTOR
)
.
addInterceptor
(
new
PostInterceptor
())
.
build
();
public
static
ApiManager
getInstance
()
{
public
static
ApiManager
getInstance
()
{
if
(
apiManage
==
null
)
{
if
(
apiManage
==
null
)
{
synchronized
(
ApiManager
.
class
)
{
synchronized
(
ApiManager
.
class
)
{
...
@@ -114,4 +129,19 @@ public class ApiManager {
...
@@ -114,4 +129,19 @@ public class ApiManager {
return
userApi
;
return
userApi
;
}
}
public
UserApi
modifyPsw
()
{
if
(
userApi
==
null
)
{
synchronized
(
monitor
)
{
if
(
userApi
==
null
)
{
userApi
=
new
Retrofit
.
Builder
()
.
baseUrl
(
"http://10.200.2.109:9011/"
)
.
client
(
client
)
.
addCallAdapterFactory
(
RxJavaCallAdapterFactory
.
create
())
.
addConverterFactory
(
GsonConverterFactory
.
create
())
.
build
().
create
(
UserApi
.
class
);
}
}
}
return
userApi
;
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/api/UserApi.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
api
;
package
com
.
senthink
.
ebike_administrer_tool
.
api
;
import
com.senthink.ebike_administrer_tool.bean.GetUserByName
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.GetUserByName
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.ModifyResponseBody
;
import
com.squareup.okhttp.RequestBody
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.GET
;
import
retrofit2.http.GET
;
import
retrofit2.http.Header
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
import
retrofit2.http.Path
;
import
rx.Observable
;
import
rx.Observable
;
...
@@ -21,4 +27,8 @@ public interface UserApi {
...
@@ -21,4 +27,8 @@ public interface UserApi {
@GET
(
"app/user/me/{userId}"
)
@GET
(
"app/user/me/{userId}"
)
Observable
<
GetUserInfoById
>
getUserInfo
(
@Path
(
"userId"
)
int
userId
);
Observable
<
GetUserInfoById
>
getUserInfo
(
@Path
(
"userId"
)
int
userId
);
@POST
(
"challenger/app/user/updatePass"
)
Call
<
ModifyResponseBody
>
postPsw
(
@Header
(
"Authorization"
)
String
authorization
,
@Body
RequestBody
body
);
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/asynchttp/AsyncClient.java
View file @
194b9fcb
...
@@ -50,6 +50,13 @@ public class AsyncClient {
...
@@ -50,6 +50,13 @@ public class AsyncClient {
}
}
public
void
post
(
Context
context
,
String
token
,
String
url
,
HttpEntity
entity
,
String
contentType
,
AsyncHttpResponseHandler
responseHandler
)
{
SetHttpHeader
(
token
);
MCLIENT
.
post
(
context
,
url
,
entity
,
contentType
,
responseHandler
);
}
public
void
put
(
String
url
,
RequestParams
params
,
public
void
put
(
String
url
,
RequestParams
params
,
AsyncHttpResponseHandler
responseHandler
)
{
AsyncHttpResponseHandler
responseHandler
)
{
...
@@ -69,6 +76,12 @@ public class AsyncClient {
...
@@ -69,6 +76,12 @@ public class AsyncClient {
MCLIENT
.
addHeader
(
"Accept"
,
"application/json"
);
MCLIENT
.
addHeader
(
"Accept"
,
"application/json"
);
}
}
public
void
SetHttpHeader
(
String
token
)
{
MCLIENT
.
addHeader
(
"Content-Type"
,
"application/json"
);
MCLIENT
.
addHeader
(
"Accept"
,
"application/json"
);
MCLIENT
.
addHeader
(
"Authorization"
,
token
);
}
public
void
RemoveHttpHeader
()
{
public
void
RemoveHttpHeader
()
{
MCLIENT
.
removeAllHeaders
();
MCLIENT
.
removeAllHeaders
();
}
}
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/asynchttp/AsyncHttp.java
View file @
194b9fcb
...
@@ -233,6 +233,65 @@ public class AsyncHttp {
...
@@ -233,6 +233,65 @@ public class AsyncHttp {
}
}
/**
* @Description 增加了token
* */
public
void
PostHttpClient
(
String
url
,
String
token
,
JSONObject
object
,
final
HttpCallback
callback
)
{
try
{
StringEntity
entity
=
new
StringEntity
(
object
.
toString
(),
"utf-8"
);
entity
.
setContentType
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
asyncClient
.
post
(
mcontext
,
token
,
url
,
entity
,
null
,
new
JsonHttpResponseHandler
()
{
@Override
public
void
onSuccess
(
int
statusCode
,
Header
[]
headers
,
JSONObject
response
)
{
// TODO Auto-generated method stub
callback
.
HttpCallbackResult
(
statusCode
,
response
);
}
@Override
public
void
onSuccess
(
int
statusCode
,
Header
[]
headers
,
String
responseString
)
{
// TODO Auto-generated method stub
callback
.
HttpCallbackResult
(
statusCode
,
responseString
);
}
@Override
public
void
onFailure
(
int
statusCode
,
Header
[]
headers
,
Throwable
throwable
,
JSONObject
errorResponse
)
{
// TODO Auto-generated method stub
callback
.
HttpCallbackResult
(
statusCode
,
errorResponse
);
Log
.
i
(
"appLog"
,
"statusCode="
+
statusCode
);
Log
.
i
(
"appLog"
,
"headers="
+
headers
);
Log
.
i
(
"appLog"
,
"throwable="
+
throwable
.
toString
());
Log
.
i
(
"appLog"
,
"errorResponse="
+
errorResponse
);
}
@Override
public
void
onFailure
(
int
statusCode
,
Header
[]
headers
,
String
responseString
,
Throwable
throwable
)
{
// TODO Auto-generated method stub
callback
.
HttpCallbackResult
(
statusCode
,
responseString
);
Log
.
i
(
"appLog"
,
"statusCode="
+
statusCode
);
Log
.
i
(
"appLog"
,
"headers="
+
headers
);
Log
.
i
(
"appLog"
,
"throwable="
+
throwable
.
toString
());
Log
.
i
(
"appLog"
,
"responseString="
+
responseString
);
}
});
}
catch
(
UnsupportedEncodingException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
public
void
PutHttpClient
(
String
url
,
RequestParams
params
,
public
void
PutHttpClient
(
String
url
,
RequestParams
params
,
final
HttpCallback
callback
)
{
final
HttpCallback
callback
)
{
try
{
try
{
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/LoginBean.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
login/
LoginBean.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
login
;
/**
/**
* @Description : 将账号密码转化为json格式
* @Description : 将账号密码转化为json格式
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/LoginBody.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
login/
LoginBody.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
login
;
/**
/**
* @Description :
* @Description :
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/LoginUser.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
login/
LoginUser.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
login
;
/**
/**
* @Description : 存储账号和密码的bean
* @Description : 存储账号和密码的bean
...
@@ -11,8 +11,23 @@ public class LoginUser {
...
@@ -11,8 +11,23 @@ public class LoginUser {
private
String
code
;
private
String
code
;
private
String
userName
;
private
String
userName
;
private
String
passWord
;
private
String
passWord
;
private
String
token
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
String
getToken
()
{
return
token
;
}
public
String
getPassWord
()
{
public
String
getPassWord
()
{
return
passWord
;
return
passWord
;
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/GetUserByName.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
userInfo/
GetUserByName.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
userInfo
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/GetUserInfoById.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
userInfo/
GetUserInfoById.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
userInfo
;
/**
/**
* @Description : 个人信息bean
* @Description : 个人信息bean
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/ModifyPswBean.java
0 → 100644
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
userInfo
;
/**
* @Description : 修改密码的bean,包括初始密码,新密码和新秘码确认
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/9
*/
public
class
ModifyPswBean
{
private
String
currentPsw
;
private
String
newPsw
;
private
String
loginName
;
private
String
token
;
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setLoginName
(
String
confirmPsw
)
{
this
.
loginName
=
confirmPsw
;
}
public
String
getLoginName
()
{
return
loginName
;
}
public
void
setCurrentPsw
(
String
currentPsw
)
{
this
.
currentPsw
=
currentPsw
;
}
public
String
getCurrentPsw
()
{
return
currentPsw
;
}
public
void
setNewPsw
(
String
newPsw
)
{
this
.
newPsw
=
newPsw
;
}
public
String
getNewPsw
()
{
return
newPsw
;
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/bean/userInfo/ModifyResponseBody.java
0 → 100644
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
userInfo
;
import
com.google.gson.annotations.SerializedName
;
/**
* @Description : 修改密码返回的body
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/9
*/
public
class
ModifyResponseBody
{
@SerializedName
(
"code"
)
String
code
;
@SerializedName
(
"msg"
)
String
msg
;
@SerializedName
(
"data"
)
String
data
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/bean/UserByName.java
→
app/src/main/java/com/senthink/ebike_administrer_tool/bean/
userInfo/
UserByName.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
bean
;
package
com
.
senthink
.
ebike_administrer_tool
.
bean
.
userInfo
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/common/Common.java
View file @
194b9fcb
...
@@ -4,9 +4,15 @@ package com.senthink.ebike_administrer_tool.common;
...
@@ -4,9 +4,15 @@ package com.senthink.ebike_administrer_tool.common;
* @Description :
* @Description :
* @Author : ni
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/
3
* @Date : 2017/6/
9
*/
*/
public
class
Common
{
public
class
Common
{
private
static
final
String
BASE_URL
=
"http://10.200.2.109:9051"
;
public
static
final
int
RE_LOGIN
=
1
;
// 重新登陆
public
static
final
String
LOGIN_USER_SHAREDPREFERENCE
=
"loginUser"
;
public
static
final
String
USER_NAME_SHAREDPREFERENCE
=
"username"
;
public
static
final
String
USER_PASSWORD_SHAREDPREFERENCE
=
"password"
;
public
static
final
String
USER_TOKEN_SHAREDPREFERENCE
=
"token"
;
public
static
final
String
USER_CHECKBOX_SELECTED_SHAREDPREFERENCE
=
"checkBox"
;
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/common/CommonUrl.java
0 → 100644
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
common
;
/**
* @Description :
* @Author : ni
* @Email : lifengni2015@gmail.com
* @Date : 2017/6/9
*/
public
class
CommonUrl
{
public
static
final
String
LOGIN_URL
=
"http://10.200.2.109:9051/auth"
;
public
static
final
String
MODIFY_PASSWORD_URL
=
"http://10.200.2.109:9051/challenger/app/user/updatePass"
;
public
static
final
String
GET_USER_INFO_URL
=
"http://10.200.2.109:9011/challenger/app/user/me/"
;
}
app/src/main/java/com/senthink/ebike_administrer_tool/fragment/MyInformationFragment.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
fragment
;
package
com
.
senthink
.
ebike_administrer_tool
.
fragment
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.Fragment
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.senthink.ebike_administrer_tool.MyApplication
;
import
com.senthink.ebike_administrer_tool.MyApplication
;
import
com.senthink.ebike_administrer_tool.R
;
import
com.senthink.ebike_administrer_tool.R
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.
userInfo.
GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.
LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.
userInfo.ModifyPswBean
;
import
com.senthink.ebike_administrer_tool.
presenter.MyInforPresenter
;
import
com.senthink.ebike_administrer_tool.
common.Common
;
import
com.senthink.ebike_administrer_tool.presenter.impl.MyInforPresenterImpl
;
import
com.senthink.ebike_administrer_tool.presenter.impl.MyInforPresenterImpl
;
import
com.senthink.ebike_administrer_tool.view.IMyInformationFragment
;
import
com.senthink.ebike_administrer_tool.view.IMyInformationFragment
;
import
butterknife.BindColor
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
...
@@ -32,6 +42,7 @@ import butterknife.ButterKnife;
...
@@ -32,6 +42,7 @@ import butterknife.ButterKnife;
public
class
MyInformationFragment
extends
Fragment
implements
IMyInformationFragment
,
View
.
OnClickListener
{
public
class
MyInformationFragment
extends
Fragment
implements
IMyInformationFragment
,
View
.
OnClickListener
{
MyInforPresenterImpl
myInforPresenter
;
MyInforPresenterImpl
myInforPresenter
;
private
View
inflate
;
@BindView
(
R
.
id
.
tv_real_name
)
@BindView
(
R
.
id
.
tv_real_name
)
TextView
mRealNameTv
;
TextView
mRealNameTv
;
@BindView
(
R
.
id
.
tv_password
)
@BindView
(
R
.
id
.
tv_password
)
...
@@ -42,6 +53,14 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
...
@@ -42,6 +53,14 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
TextView
mUserNmaeTv
;
TextView
mUserNmaeTv
;
@BindView
(
R
.
id
.
iv_modify_password
)
@BindView
(
R
.
id
.
iv_modify_password
)
ImageView
mModifyPswIv
;
ImageView
mModifyPswIv
;
private
Dialog
dialog
;
private
Button
confirmBtn
;
private
Button
cancelBtn
;
private
EditText
confirmPswEt
;
private
EditText
newPswEt
;
private
EditText
currentPswEt
;
private
static
final
String
TAG
=
MyInformationFragment
.
class
.
getSimpleName
();
@Nullable
@Nullable
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
@@ -54,7 +73,12 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
...
@@ -54,7 +73,12 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
super
.
onViewCreated
(
view
,
savedInstanceState
);
super
.
onViewCreated
(
view
,
savedInstanceState
);
ButterKnife
.
bind
(
this
,
view
);
ButterKnife
.
bind
(
this
,
view
);
initData
();
initData
();
initView
();
}
private
void
initView
()
{
mModifyPswIv
.
setOnClickListener
(
this
);
}
}
/**
/**
...
@@ -79,7 +103,8 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
...
@@ -79,7 +103,8 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
* */
* */
@Override
@Override
public
void
postInformationFailed
(
String
msg
)
{
public
void
postInformationFailed
(
String
msg
)
{
Log
.
i
(
TAG
,
"postInformationFailed: "
+
msg
);
clearText
();
}
}
/**
/**
...
@@ -115,6 +140,26 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
...
@@ -115,6 +140,26 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
mPasswordTv
.
setText
(
password
);
// 设置密码
mPasswordTv
.
setText
(
password
);
// 设置密码
mUserNmaeTv
.
setText
(
loginName
);
mUserNmaeTv
.
setText
(
loginName
);
}
}
/**
* @Description 密码修改成功
* */
@Override
public
void
modifyPswSuccess
()
{
dialog
.
dismiss
();
getActivity
().
setResult
(
Common
.
RE_LOGIN
);
// TODO: 2017/6/9 密码修改成功提示框的样式可能需要修改
AlertDialog
ad
=
new
AlertDialog
.
Builder
(
getActivity
())
.
setMessage
(
R
.
string
.
modify_password_success
)
.
setPositiveButton
(
R
.
string
.
confirm
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
getActivity
().
finish
();
}
})
.
create
();
ad
.
show
();
}
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
...
@@ -123,13 +168,66 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
...
@@ -123,13 +168,66 @@ public class MyInformationFragment extends Fragment implements IMyInformationFra
case
R
.
id
.
iv_modify_password
:
case
R
.
id
.
iv_modify_password
:
modifyPassword
();
modifyPassword
();
break
;
break
;
case
R
.
id
.
btn_cancel
:
dialog
.
dismiss
();
break
;
case
R
.
id
.
btn_confirm
:
ModifyPswBean
bean
=
new
ModifyPswBean
();
if
(!
newPswEt
.
getText
().
toString
().
equals
(
confirmPswEt
.
getText
().
toString
()))
{
// 如果两次输入的密码不一致,则重新输入
Toast
.
makeText
(
getContext
(),
getString
(
R
.
string
.
psw_not_same
),
Toast
.
LENGTH_LONG
).
show
();
clearText
();
break
;
}
SharedPreferences
sharedPreferences
=
getActivity
()
.
getSharedPreferences
(
"loginUser"
,
Context
.
MODE_PRIVATE
);
String
token
=
sharedPreferences
.
getString
(
"token"
,
null
);
String
name
=
sharedPreferences
.
getString
(
"username"
,
null
);
bean
.
setToken
(
token
);
bean
.
setCurrentPsw
(
currentPswEt
.
getText
().
toString
());
bean
.
setNewPsw
(
newPswEt
.
getText
().
toString
());
bean
.
setLoginName
(
name
);
clearText
();
myInforPresenter
.
modifyPassword
(
bean
);
break
;
}
}
}
}
/**
/**
* @Description 清楚edittext中的文字
* */
private
void
clearText
()
{
currentPswEt
.
setText
(
null
);
newPswEt
.
setText
(
null
);
confirmPswEt
.
setText
(
null
);
}
/**
* @Description 修改密码
* @Description 修改密码
* */
* */
private
void
modifyPassword
()
{
private
void
modifyPassword
()
{
myInforPresenter
.
modifyPassword
();
Log
.
i
(
"!2"
,
"modifyPassword: "
);
dialog
=
new
Dialog
(
getContext
(),
R
.
style
.
modify_psw_dialog
);
inflate
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
dialog_modify_pawssword
,
null
);
currentPswEt
=
(
EditText
)
inflate
.
findViewById
(
R
.
id
.
et_current_psw
);
newPswEt
=
(
EditText
)
inflate
.
findViewById
(
R
.
id
.
et_new_psw
);
confirmPswEt
=
(
EditText
)
inflate
.
findViewById
(
R
.
id
.
et_confirm_psw
);
cancelBtn
=
(
Button
)
inflate
.
findViewById
(
R
.
id
.
btn_cancel
);
confirmBtn
=
(
Button
)
inflate
.
findViewById
(
R
.
id
.
btn_confirm
);
cancelBtn
.
setOnClickListener
(
this
);
confirmBtn
.
setOnClickListener
(
this
);
dialog
.
setContentView
(
inflate
);
Window
dialogWindow
=
dialog
.
getWindow
();
dialogWindow
.
setGravity
(
Gravity
.
BOTTOM
);
WindowManager
m
=
getActivity
().
getWindowManager
();
Display
d
=
m
.
getDefaultDisplay
();
WindowManager
.
LayoutParams
lp
=
dialogWindow
.
getAttributes
();
lp
.
width
=
d
.
getWidth
();
lp
.
height
=
(
int
)
(
d
.
getHeight
()
*
0.4
);
// lp.y = 20;
dialogWindow
.
setAttributes
(
lp
);
dialog
.
show
();
}
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/model/UserInfoModel.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
model
;
package
com
.
senthink
.
ebike_administrer_tool
.
model
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.ModifyPswBean
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
/**
/**
...
@@ -13,4 +14,6 @@ public interface UserInfoModel extends BasePresenter{
...
@@ -13,4 +14,6 @@ public interface UserInfoModel extends BasePresenter{
void
getUserIdByUserName
(
String
userName
,
UserInfoCallback
callback
);
void
getUserIdByUserName
(
String
userName
,
UserInfoCallback
callback
);
void
getUserInfoById
(
int
id
,
UserInfoCallback
callback
);
void
getUserInfoById
(
int
id
,
UserInfoCallback
callback
);
void
modifyPassword
(
ModifyPswBean
bean
,
UserInfoCallback
callback
);
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/model/callback/LoginCallback.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
model
.
callback
;
package
com
.
senthink
.
ebike_administrer_tool
.
model
.
callback
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.
login.
LoginUser
;
/**
/**
* @Description :
* @Description :
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/model/callback/UserInfoCallback.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
model
.
callback
;
package
com
.
senthink
.
ebike_administrer_tool
.
model
.
callback
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.
userInfo.
GetUserInfoById
;
/**
/**
* @Description : 个人信息的回调
* @Description : 个人信息的回调
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/model/impl/LoginModelImpl.java
View file @
194b9fcb
...
@@ -4,8 +4,9 @@ import com.senthink.ebike_administrer_tool.MyApplication;
...
@@ -4,8 +4,9 @@ import com.senthink.ebike_administrer_tool.MyApplication;
import
com.senthink.ebike_administrer_tool.api.LoginApi
;
import
com.senthink.ebike_administrer_tool.api.LoginApi
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp
;
import
com.senthink.ebike_administrer_tool.asynchttp.HttpCallback
;
import
com.senthink.ebike_administrer_tool.asynchttp.HttpCallback
;
import
com.senthink.ebike_administrer_tool.bean.LoginBean
;
import
com.senthink.ebike_administrer_tool.bean.login.LoginBean
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.login.LoginUser
;
import
com.senthink.ebike_administrer_tool.common.CommonUrl
;
import
com.senthink.ebike_administrer_tool.model.callback.LoginCallback
;
import
com.senthink.ebike_administrer_tool.model.callback.LoginCallback
;
import
com.senthink.ebike_administrer_tool.model.LoginModel
;
import
com.senthink.ebike_administrer_tool.model.LoginModel
;
...
@@ -30,7 +31,7 @@ public class LoginModelImpl implements LoginModel {
...
@@ -30,7 +31,7 @@ public class LoginModelImpl implements LoginModel {
// TODO: 2017/6/3 用户名、密码的具体验证逻辑
// TODO: 2017/6/3 用户名、密码的具体验证逻辑
AsyncHttp
http
=
new
AsyncHttp
(
MyApplication
.
getContext
());
AsyncHttp
http
=
new
AsyncHttp
(
MyApplication
.
getContext
());
JSONObject
obj
=
new
JSONObject
();
JSONObject
obj
=
new
JSONObject
();
String
url
=
"http://10.200.2.109:9051/auth"
;
String
url
=
CommonUrl
.
LOGIN_URL
;
try
{
try
{
obj
.
put
(
"password"
,
passWord
);
obj
.
put
(
"password"
,
passWord
);
obj
.
put
(
"username"
,
userName
);
obj
.
put
(
"username"
,
userName
);
...
@@ -45,10 +46,14 @@ public class LoginModelImpl implements LoginModel {
...
@@ -45,10 +46,14 @@ public class LoginModelImpl implements LoginModel {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if
(
code
==
200
)
{
if
(
code
==
200
)
{
// saveInfo(userName,passWord,response.getString("token"));
// saveInfo(userName,passWord,response.getString("token"));
loginUser
.
setUserName
(
userName
);
loginUser
.
setPassWord
(
passWord
);
try
{
// loginUser.setToken(response.getString("token"));
loginUser
.
setUserName
(
userName
);
// saveInfo(loginUser);
loginUser
.
setPassWord
(
passWord
);
loginUser
.
setToken
(
response
.
getString
(
"token"
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
mCallback
.
loginSuccess
(
loginUser
);
mCallback
.
loginSuccess
(
loginUser
);
}
else
{
}
else
{
mCallback
.
loginFailed
(
"Invalid username or password"
);
mCallback
.
loginFailed
(
"Invalid username or password"
);
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/model/impl/UserInfoModelImpl.java
View file @
194b9fcb
...
@@ -4,26 +4,49 @@ import android.content.Context;
...
@@ -4,26 +4,49 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.util.Log
;
import
android.util.Log
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.loopj.android.http.AsyncHttpClient
;
import
com.loopj.android.http.AsyncHttpRequest
;
import
com.senthink.ebike_administrer_tool.MyApplication
;
import
com.senthink.ebike_administrer_tool.MyApplication
;
import
com.senthink.ebike_administrer_tool.api.ApiManager
;
import
com.senthink.ebike_administrer_tool.api.ApiManager
;
import
com.senthink.ebike_administrer_tool.api.UserApi
;
import
com.senthink.ebike_administrer_tool.api.UserApi
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncClient
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncClient
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp
;
import
com.senthink.ebike_administrer_tool.asynchttp.AsyncHttp
;
import
com.senthink.ebike_administrer_tool.asynchttp.HttpCallback
;
import
com.senthink.ebike_administrer_tool.asynchttp.HttpCallback
;
import
com.senthink.ebike_administrer_tool.bean.GetUserByName
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.ModifyPswBean
;
import
com.senthink.ebike_administrer_tool.model.LoginModel
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.ModifyResponseBody
;
import
com.senthink.ebike_administrer_tool.common.CommonUrl
;
import
com.senthink.ebike_administrer_tool.model.UserInfoModel
;
import
com.senthink.ebike_administrer_tool.model.UserInfoModel
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
import
com.squareup.okhttp.FormEncodingBuilder
;
import
com.squareup.okhttp.MediaType
;
import
com.squareup.okhttp.MultipartBuilder
;
import
com.squareup.okhttp.RequestBody
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
rx.Observer
;
import
java.io.IOException
;
import
rx.Subscription
;
import
java.lang.reflect.Type
;
import
rx.android.schedulers.AndroidSchedulers
;
import
java.net.Proxy
;
import
rx.schedulers.Schedulers
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
okhttp3.Authenticator
;
import
okhttp3.Call
;
import
okhttp3.Callback
;
import
okhttp3.Credentials
;
import
okhttp3.FormBody
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
okhttp3.Route
;
import
okio.BufferedSink
;
/**
/**
* @Description :
* @Description :
...
@@ -35,6 +58,12 @@ import rx.schedulers.Schedulers;
...
@@ -35,6 +58,12 @@ import rx.schedulers.Schedulers;
public
class
UserInfoModelImpl
extends
BasePresenterImpl
implements
UserInfoModel
{
public
class
UserInfoModelImpl
extends
BasePresenterImpl
implements
UserInfoModel
{
UserApi
userApi
;
UserApi
userApi
;
private
static
final
String
TAG
=
UserInfoModelImpl
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
UserInfoModelImpl
.
class
.
getSimpleName
();
/**
* @param userName 用户名
* @param callback 成功或失败的回调
* @Description 通过登陆用户名去查询用户ID
*/
@Override
@Override
public
void
getUserIdByUserName
(
String
userName
,
final
UserInfoCallback
callback
)
{
public
void
getUserIdByUserName
(
String
userName
,
final
UserInfoCallback
callback
)
{
userApi
=
ApiManager
.
getInstance
().
getUserId
();
userApi
=
ApiManager
.
getInstance
().
getUserId
();
...
@@ -49,11 +78,11 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
...
@@ -49,11 +78,11 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
JSONObject
obj
=
response
.
getJSONObject
(
"data"
);
JSONObject
obj
=
response
.
getJSONObject
(
"data"
);
int
id
=
obj
.
getInt
(
"userId"
);
int
id
=
obj
.
getInt
(
"userId"
);
Log
.
i
(
TAG
,
"HttpCallbackResult: "
+
id
);
Log
.
i
(
TAG
,
"HttpCallbackResult: "
+
id
);
getUserInfoById
(
id
,
callback
);
getUserInfoById
(
id
,
callback
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
else
{
}
else
{
Log
.
i
(
TAG
,
"请求失败,code ="
+
code
);
Log
.
i
(
TAG
,
"请求失败,code ="
+
code
);
}
}
}
}
...
@@ -65,9 +94,14 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
...
@@ -65,9 +94,14 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
});
});
}
}
/**
* @param id 用户id
* @param callback 成功或失败的回调
* @Description 根据用户id来获取用户信息,主要包括电话,真实姓名
*/
@Override
@Override
public
void
getUserInfoById
(
int
id
,
final
UserInfoCallback
callback
)
{
public
void
getUserInfoById
(
int
id
,
final
UserInfoCallback
callback
)
{
StringBuilder
url
=
new
StringBuilder
().
append
(
"http://10.200.2.109:9011/challenger/app/user/me/"
);
StringBuilder
url
=
new
StringBuilder
().
append
(
CommonUrl
.
GET_USER_INFO_URL
);
url
.
append
(
id
);
url
.
append
(
id
);
AsyncHttp
http
=
new
AsyncHttp
(
MyApplication
.
getContext
());
AsyncHttp
http
=
new
AsyncHttp
(
MyApplication
.
getContext
());
http
.
GetHttpClient
(
url
.
toString
(),
new
HttpCallback
()
{
http
.
GetHttpClient
(
url
.
toString
(),
new
HttpCallback
()
{
...
@@ -90,7 +124,7 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
...
@@ -90,7 +124,7 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
else
{
}
else
{
callback
.
getInfoFailed
(
"信息请求失败"
);
callback
.
getInfoFailed
(
"信息请求失败"
);
}
}
}
}
...
@@ -101,4 +135,55 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
...
@@ -101,4 +135,55 @@ public class UserInfoModelImpl extends BasePresenterImpl implements UserInfoMode
}
}
});
});
}
}
/**
* @param bean 修改密码的bean
* @param callback 是否修改成功的回调
* @Description 修改密码操作
*/
@Override
public
void
modifyPassword
(
ModifyPswBean
bean
,
final
UserInfoCallback
callback
)
{
String
url
=
CommonUrl
.
MODIFY_PASSWORD_URL
;
AsyncHttp
http
=
new
AsyncHttp
(
MyApplication
.
getContext
());
JSONObject
mm
=
new
JSONObject
();
try
{
mm
.
put
(
"beforePassword"
,
bean
.
getCurrentPsw
());
mm
.
put
(
"newPassword"
,
bean
.
getNewPsw
());
mm
.
put
(
"userName"
,
"xjl"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
http
.
PostHttpClient
(
url
,
bean
.
getToken
(),
mm
,
new
HttpCallback
()
{
@Override
public
void
HttpCallbackResult
(
int
code
,
JSONObject
response
)
{
try
{
// 获取response body中的code1,
// 若code1 = 5023, data = "原密码不正确";
// 若code1 = 8001,data = "操作成功";
String
code1
=
response
.
getString
(
"code"
);
String
data
=
response
.
getString
(
"data"
);
Log
.
i
(
TAG
,
"HttpCallbackResult: "
+
code1
+
data
);
switch
(
code1
)
{
case
"5023"
:
callback
.
modifyFailed
(
data
);
break
;
case
"8001"
:
callback
.
modifySuccess
();
break
;
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
HttpCallbackResult
(
int
code
,
String
response
)
{
}
});
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/MyInforPresenter.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
presenter
;
package
com
.
senthink
.
ebike_administrer_tool
.
presenter
;
import
com.senthink.ebike_administrer_tool.
model.BasePresenter
;
import
com.senthink.ebike_administrer_tool.
bean.userInfo.ModifyPswBean
;
/**
/**
* @Description :
* @Description :
...
@@ -13,5 +13,5 @@ public interface MyInforPresenter {
...
@@ -13,5 +13,5 @@ public interface MyInforPresenter {
/** 获取用户信息 */
/** 获取用户信息 */
void
getUserInfo
(
String
name
);
void
getUserInfo
(
String
name
);
/** 修改密码 */
/** 修改密码 */
void
modifyPassword
(
String
psw
);
void
modifyPassword
(
ModifyPswBean
pswBean
);
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/impl/LoginPresenterImpl.java
View file @
194b9fcb
...
@@ -2,7 +2,7 @@ package com.senthink.ebike_administrer_tool.presenter.impl;
...
@@ -2,7 +2,7 @@ package com.senthink.ebike_administrer_tool.presenter.impl;
import
android.util.Log
;
import
android.util.Log
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.
login.
LoginUser
;
import
com.senthink.ebike_administrer_tool.model.callback.LoginCallback
;
import
com.senthink.ebike_administrer_tool.model.callback.LoginCallback
;
import
com.senthink.ebike_administrer_tool.model.impl.LoginModelImpl
;
import
com.senthink.ebike_administrer_tool.model.impl.LoginModelImpl
;
import
com.senthink.ebike_administrer_tool.presenter.LoginPresenter
;
import
com.senthink.ebike_administrer_tool.presenter.LoginPresenter
;
...
@@ -31,7 +31,6 @@ public class LoginPresenterImpl implements LoginPresenter {
...
@@ -31,7 +31,6 @@ public class LoginPresenterImpl implements LoginPresenter {
loginImpl
.
login
(
loginView
.
getUserName
(),
loginView
.
getPassWord
(),
new
LoginCallback
()
{
loginImpl
.
login
(
loginView
.
getUserName
(),
loginView
.
getPassWord
(),
new
LoginCallback
()
{
@Override
@Override
public
void
loginSuccess
(
LoginUser
loginUser
)
{
public
void
loginSuccess
(
LoginUser
loginUser
)
{
loginView
.
toLoginActivity
(
loginUser
);
loginView
.
hideLoading
();
loginView
.
hideLoading
();
loginView
.
toLoginActivity
(
loginUser
);
// 去View层处理存储数据的操作
loginView
.
toLoginActivity
(
loginUser
);
// 去View层处理存储数据的操作
}
}
...
...
app/src/main/java/com/senthink/ebike_administrer_tool/presenter/impl/MyInforPresenterImpl.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
presenter
.
impl
;
package
com
.
senthink
.
ebike_administrer_tool
.
presenter
.
impl
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.ModifyPswBean
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
import
com.senthink.ebike_administrer_tool.model.callback.UserInfoCallback
;
import
com.senthink.ebike_administrer_tool.model.impl.BasePresenterImpl
;
import
com.senthink.ebike_administrer_tool.model.impl.UserInfoModelImpl
;
import
com.senthink.ebike_administrer_tool.model.impl.UserInfoModelImpl
;
import
com.senthink.ebike_administrer_tool.presenter.MyInforPresenter
;
import
com.senthink.ebike_administrer_tool.presenter.MyInforPresenter
;
import
com.senthink.ebike_administrer_tool.view.IMyInformationFragment
;
import
com.senthink.ebike_administrer_tool.view.IMyInformationFragment
;
...
@@ -51,10 +51,30 @@ public class MyInforPresenterImpl implements MyInforPresenter {
...
@@ -51,10 +51,30 @@ public class MyInforPresenterImpl implements MyInforPresenter {
/**
/**
* @Description 修改密码
* @Description 修改密码
* @param psw
密码
* @param psw
Bean 密码bean
* */
* */
@Override
@Override
public
void
modifyPassword
(
String
psw
)
{
public
void
modifyPassword
(
ModifyPswBean
pswBean
)
{
userInfoModel
.
modifyPassword
(
pswBean
,
new
UserInfoCallback
()
{
@Override
public
void
getInfoSuccess
(
GetUserInfoById
user
)
{
}
@Override
public
void
getInfoFailed
(
String
msg
)
{
}
@Override
public
void
modifySuccess
()
{
fragment
.
modifyPswSuccess
();
}
@Override
public
void
modifyFailed
(
String
msg
)
{
fragment
.
postInformationFailed
(
msg
);
}
});
}
}
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/view/IMyInformationFragment.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
view
;
package
com
.
senthink
.
ebike_administrer_tool
.
view
;
import
com.senthink.ebike_administrer_tool.bean.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.userInfo.GetUserInfoById
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
/**
/**
* @Description : 更新信息
* @Description : 更新信息
...
@@ -12,4 +11,5 @@ import com.senthink.ebike_administrer_tool.bean.LoginUser;
...
@@ -12,4 +11,5 @@ import com.senthink.ebike_administrer_tool.bean.LoginUser;
public
interface
IMyInformationFragment
extends
IBaseFragment
{
public
interface
IMyInformationFragment
extends
IBaseFragment
{
void
updateInfor
(
GetUserInfoById
user
);
void
updateInfor
(
GetUserInfoById
user
);
void
modifyPswSuccess
();
}
}
app/src/main/java/com/senthink/ebike_administrer_tool/view/LoginView.java
View file @
194b9fcb
package
com
.
senthink
.
ebike_administrer_tool
.
view
;
package
com
.
senthink
.
ebike_administrer_tool
.
view
;
import
com.senthink.ebike_administrer_tool.bean.LoginUser
;
import
com.senthink.ebike_administrer_tool.bean.
login.
LoginUser
;
/**
/**
* @Description :
* @Description :
...
...
app/src/main/res/layout/dialog_modify_pawssword.xml
0 → 100644
View file @
194b9fcb
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:background=
"@color/background_color_grey"
android:layout_height=
"250dp"
>
<TextView
android:gravity=
"center"
android:layout_width=
"match_parent"
android:layout_height=
"55dp"
android:text=
"@string/modify_password"
/>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:background=
"@color/tab_background_normal"
android:layout_height=
"150dp"
>
<EditText
android:id=
"@+id/et_current_psw"
android:hint=
"@string/current_psw"
android:password=
"true"
android:textSize=
"@dimen/small_text"
android:layout_width=
"match_parent"
android:layout_height=
"37dp"
android:layout_marginTop=
"9dp"
android:layout_marginLeft=
"9dp"
android:layout_marginRight=
"9dp"
android:background=
"@drawable/modify_input_frame"
/>
<EditText
android:id=
"@+id/et_new_psw"
android:hint=
"@string/new_psw"
android:textSize=
"@dimen/small_text"
android:password=
"true"
android:layout_width=
"match_parent"
android:layout_height=
"37dp"
android:layout_marginTop=
"9dp"
android:layout_marginLeft=
"9dp"
android:layout_marginRight=
"9dp"
android:background=
"@drawable/modify_input_frame"
/>
<EditText
android:id=
"@+id/et_confirm_psw"
android:layout_width=
"match_parent"
android:layout_height=
"37dp"
android:password=
"true"
android:layout_marginLeft=
"9dp"
android:layout_marginRight=
"9dp"
android:layout_marginTop=
"9dp"
android:background=
"@drawable/modify_input_frame"
android:hint=
"@string/confirm_psw"
android:textSize=
"@dimen/small_text"
/>
</LinearLayout>
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
>
<Button
android:id=
"@+id/btn_cancel"
android:background=
"@color/background_color_grey"
android:layout_weight=
"0.5"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:text=
"@string/cancel"
/>
<Button
android:id=
"@+id/btn_confirm"
android:background=
"@color/background_color_grey"
android:layout_weight=
"0.5"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:text=
"@string/confirm"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/layout_login.xml
View file @
194b9fcb
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
android:gravity=
"center"
/>
android:gravity=
"center"
/>
<LinearLayout
<LinearLayout
android:layout_width=
"
wrap_content
"
android:layout_width=
"
260dp
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/login_input_frame"
android:background=
"@drawable/login_input_frame"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
...
@@ -42,7 +42,6 @@
...
@@ -42,7 +42,6 @@
android:background=
"@drawable/login_input_frame"
android:background=
"@drawable/login_input_frame"
android:ems=
"10"
android:ems=
"10"
android:inputType=
"textPersonName"
android:inputType=
"textPersonName"
android:text=
"xjl"
android:textColor=
"@color/login_text_color"
/>
android:textColor=
"@color/login_text_color"
/>
<Button
<Button
...
@@ -69,7 +68,7 @@
...
@@ -69,7 +68,7 @@
android:gravity=
"center"
/>
android:gravity=
"center"
/>
<LinearLayout
<LinearLayout
android:layout_width=
"
wrap_content
"
android:layout_width=
"
260dp
"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/login_input_frame"
android:background=
"@drawable/login_input_frame"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
...
@@ -83,7 +82,6 @@
...
@@ -83,7 +82,6 @@
android:ems=
"10"
android:ems=
"10"
android:layout_weight=
"0.9"
android:layout_weight=
"0.9"
android:inputType=
"textPersonName"
android:inputType=
"textPersonName"
android:text=
"123456"
android:textColor=
"@color/login_text_color"
/>
android:textColor=
"@color/login_text_color"
/>
<Button
<Button
...
...
app/src/main/res/layout/layout_main.xml
View file @
194b9fcb
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
>
tools:context=
".MainActivity"
>
<android.support.v4.view.ViewPager
<android.support.v4.view.ViewPager
android:id=
"@+id/viewpager"
android:id=
"@+id/viewpager"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/values-v21/styles.xml
0 → 100644
View file @
194b9fcb
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
parent=
"@android:style/Theme.Material.Dialog.Alert"
name=
"modify_psw_success_dialog"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowFrame"
>
@null
</item>
</style>
</resources>
\ No newline at end of file
app/src/main/res/values/dimens.xml
View file @
194b9fcb
...
@@ -4,4 +4,5 @@
...
@@ -4,4 +4,5 @@
<dimen
name=
"activity_vertical_margin"
>
16dp
</dimen>
<dimen
name=
"activity_vertical_margin"
>
16dp
</dimen>
<dimen
name=
"login_text_size"
>
20sp
</dimen>
<dimen
name=
"login_text_size"
>
20sp
</dimen>
<dimen
name=
"tab_height"
>
60dp
</dimen>
<dimen
name=
"tab_height"
>
60dp
</dimen>
<dimen
name=
"small_text"
>
20sp
</dimen>
</resources>
</resources>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
194b9fcb
...
@@ -10,4 +10,12 @@
...
@@ -10,4 +10,12 @@
<string
name=
"user_info_name"
>
名称
</string>
<string
name=
"user_info_name"
>
名称
</string>
<string
name=
"user_info_username"
>
用户名
</string>
<string
name=
"user_info_username"
>
用户名
</string>
<string
name=
"user_info_password"
>
密码
</string>
<string
name=
"user_info_password"
>
密码
</string>
<string
name=
"modify_password"
>
修改密码
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"confirm"
>
确定
</string>
<string
name=
"current_psw"
>
当前密码
</string>
<string
name=
"new_psw"
>
新密码
</string>
<string
name=
"confirm_psw"
>
再次输入
</string>
<string
name=
"psw_not_same"
>
密码不一致,请重新输入
</string>
<string
name=
"modify_password_success"
>
密码修改成功,请重新登录
</string>
</resources>
</resources>
app/src/main/res/values/styles.xml
View file @
194b9fcb
...
@@ -16,5 +16,20 @@
...
@@ -16,5 +16,20 @@
<item
name=
"tabIndicatorHeight"
>
0dp
</item>
<item
name=
"tabIndicatorHeight"
>
0dp
</item>
</style>
</style>
<!--修改密码提示框-->
<style
parent=
"@android:style/Theme.Dialog"
name=
"modify_psw_dialog"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowFrame"
>
@null
</item>
</style>
<!--密码修改成功提示框-->
<style
parent=
"@android:style/Theme.Holo.Dialog"
name=
"modify_psw_success_dialog"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowFrame"
>
@null
</item>
</style>
</resources>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment