|
|
@@ -1,9 +1,19 @@
|
|
|
package com.jiuyan.sheep_children.page;
|
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.app.Dialog;
|
|
|
import android.content.Intent;
|
|
|
+import android.os.Build;
|
|
|
+import android.support.design.widget.TextInputEditText;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.RadioButton;
|
|
|
+import android.widget.RadioGroup;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import com.jiuyan.sheep_children.BuildConfig;
|
|
|
+import com.jiuyan.sheep_children.Config;
|
|
|
import com.jiuyan.sheep_children.R;
|
|
|
import com.jiuyan.sheep_children.base.BaseActivity;
|
|
|
import com.jiuyan.sheep_children.utils.SpUtils;
|
|
|
@@ -14,6 +24,7 @@ import com.jiuyan.sheep_children.utils.SpUtils;
|
|
|
|
|
|
public class LoginActivity extends BaseActivity {
|
|
|
private ImageView mImgLogin;
|
|
|
+ private AlertDialog mDialog;
|
|
|
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
@@ -42,9 +53,54 @@ public class LoginActivity extends BaseActivity {
|
|
|
finish();
|
|
|
}
|
|
|
});
|
|
|
+ if (BuildConfig.DEBUG)
|
|
|
+ mImgLogin.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onLongClick(View v) {
|
|
|
+ initDialog();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initDialog() {
|
|
|
+ if (mDialog == null) {
|
|
|
+ final View view = View.inflate(this, R.layout.baseurl_dialog, null);
|
|
|
+ final RadioGroup mRgUrl = (RadioGroup) view.findViewById(R.id.rg_url);
|
|
|
+ final TextInputEditText mEtUrl = (TextInputEditText) view.findViewById(R.id.et_url);
|
|
|
+ TextView tvEnter = (TextView) view.findViewById(R.id.tv_enter);
|
|
|
+ for (String url : Config.instance().mUrlList) {
|
|
|
+ RadioButton button = new RadioButton(this);
|
|
|
+ button.setText(url);
|
|
|
+ mRgUrl.addView(button);
|
|
|
+ }
|
|
|
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
+ mDialog = builder.setView(view).create();
|
|
|
+ mDialog.setCanceledOnTouchOutside(true);
|
|
|
+ tvEnter.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String url = mEtUrl.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(url)) {
|
|
|
+ int id = mRgUrl.getCheckedRadioButtonId();
|
|
|
+ if (id != -1) {
|
|
|
+ RadioButton btn = view.findViewById(id);
|
|
|
+ url = btn.getText().toString().trim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(url)) {
|
|
|
+ Config.instance().setBaseUrl(url);
|
|
|
+ }
|
|
|
+ mDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ mDialog.show();
|
|
|
}
|
|
|
|
|
|
private void loginFromWx() {
|
|
|
SpUtils.login(this, "testkajhsdasdjoasd");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|