-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/unknown' into develop
- Loading branch information
Showing
15 changed files
with
298 additions
and
12 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
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/sollyu/android/appenv/activitys/ActivityRegister.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,82 @@ | ||
/* | ||
* Copyright © 2017 Sollyu <https://www.sollyu.com/> | ||
* | ||
* Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. | ||
* | ||
* This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. | ||
*/ | ||
|
||
package com.sollyu.android.appenv.activitys | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.view.View | ||
import com.afollestad.materialdialogs.MaterialDialog | ||
import com.alibaba.fastjson.JSON | ||
import com.sollyu.android.appenv.R | ||
import com.sollyu.android.appenv.define.AppEnvConstants | ||
import com.squareup.okhttp.* | ||
import kotlinx.android.synthetic.main.activity_register.* | ||
import kotlinx.android.synthetic.main.include_toolbar.* | ||
import org.xutils.view.annotation.Event | ||
import org.xutils.x | ||
import java.io.IOException | ||
|
||
class ActivityRegister : ActivityBase() { | ||
|
||
companion object { | ||
fun launch(activity: Activity) { | ||
activity.startActivity(Intent(activity, ActivityRegister::class.java)) | ||
} | ||
} | ||
|
||
override fun getMobclickAgentTag(): String { | ||
return "Register" | ||
} | ||
|
||
override fun onInitView() { | ||
super.onInitView() | ||
setContentView(R.layout.activity_register) | ||
x.view().inject(activity) | ||
|
||
setSupportActionBar(toolbar) | ||
supportActionBar?.setTitle(R.string.register_title) | ||
supportActionBar?.setHomeButtonEnabled(true) | ||
supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||
} | ||
|
||
@Suppress("unused") | ||
@Event(R.id.btnLogin) | ||
private fun onItemClickLogin(view: View) { | ||
|
||
val postBody = FormEncodingBuilder() | ||
.add("user_name" , etUserName.text.toString()) | ||
.add("user_password" , etPwd.text.toString()) | ||
.add("user_password_confirm", etPwdConfirm.text.toString()) | ||
.add("user_email" , etEMail.text.toString()) | ||
.build() | ||
|
||
val materialDialog = MaterialDialog.Builder(activity).title(R.string.tip).content(R.string.register_processing).progress(true, 0).cancelable(false).show() | ||
OkHttpClient().newCall(Request.Builder().url(AppEnvConstants.URL_APPENV_REGISTER).post(postBody).build()).enqueue(object : Callback{ | ||
override fun onFailure(request: Request, e: IOException) { | ||
materialDialog.dismiss() | ||
activity.runOnUiThread { MaterialDialog.Builder(activity).title(R.string.error).content(e.message?:"null").show() } | ||
} | ||
|
||
override fun onResponse(response: Response) { | ||
materialDialog.dismiss() | ||
val serverResult = response.body().string() | ||
try { | ||
val resultJsonObject = JSON.parseObject(serverResult) | ||
if (resultJsonObject.getInteger("ret") == 200) { | ||
activity.runOnUiThread { MaterialDialog.Builder(activity).title(R.string.tip).content("注册成功").canceledOnTouchOutside(false).positiveText(android.R.string.ok).onPositive { _, _ -> activity.finish() }.show() } | ||
} else { | ||
activity.runOnUiThread { MaterialDialog.Builder(activity).title(R.string.tip).content("注册失败:\n" + resultJsonObject.getString("msg")).positiveText(android.R.string.ok).show() } | ||
} | ||
} catch (e: Exception) { | ||
activity.runOnUiThread { MaterialDialog.Builder(activity).title(R.string.tip).content("注册失败,原因未知").positiveText(android.R.string.ok).show() } | ||
} | ||
} | ||
}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
~ Copyright © 2017 Sollyu <https://www.sollyu.com/> | ||
~ | ||
~ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. | ||
~ | ||
~ This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. | ||
--> | ||
|
||
<vector android:height="24dp" android:viewportHeight="1024.0" | ||
android:viewportWidth="1024.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="#ffffff" android:pathData="M813.9,128.3l-199.5,0 0,40.9 199.5,0c10.8,0 21.1,4.3 28.9,12.1 7.8,7.8 12.1,18 12.1,28.9l0,199.5 40.9,0 0,-199.5C895.7,165.1 858.9,128.3 813.9,128.3z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M854.8,813.9c0,10.8 -4.3,21.1 -12.1,28.9 -7.8,7.8 -18,12.1 -28.9,12.1l-199.5,0 0,40.9 199.5,0c45,0 81.9,-36.8 81.9,-81.9l0,-199.5 -40.9,0L854.8,813.9z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M181.3,842.7c-7.8,-7.8 -12.1,-18 -12.1,-28.9l0,-199.5 -40.9,0 0,199.5c0,45 36.8,81.9 81.9,81.9l199.5,0 0,-40.9 -199.5,0C199.3,854.8 189,850.5 181.3,842.7z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M128.3,210.1l0,199.5 40.9,0 0,-199.5c0,-10.8 4.3,-21.1 12.1,-28.9 7.8,-7.8 18,-12.1 28.9,-12.1l199.5,0 0,-40.9 -199.5,0C165.1,128.3 128.3,165.1 128.3,210.1z"/> | ||
<path android:fillColor="#ffffff" android:pathData="M148.7,491.5l726.5,0 0,40.9 -726.5,0 0,-40.9Z"/> | ||
</vector> |
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
Oops, something went wrong.