Comments (1)
Reference source codes:
package com.kantv.ui.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import com.google.android.gms.analytics.HitBuilders.ScreenViewBuilder;
import com.google.android.gms.analytics.Tracker;
import com.kantv.common.api.Api;
import com.kantv.common.api.ApiService;
import com.kantv.common.api.CommonCallBack;
import com.kantv.common.utils.StringUtils;
import com.kantv.common.utils.Utils;
import com.kantv.ui.PackageActivity;
import com.kantv.ui.config.SignConfig;
import com.kantv.ui.utils.PreferenceUtil;
import com.kantv.ui.utils.ToastUtils;
import debug.KanApplication;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import okhttp3.ResponseBody;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Response;
public class RegisterActivity
extends PackageActivity
{
private int mCount = 120;
private int mCountCloud;
private Handler mHandler = new MyHandler(this);
@BindView(2131296447)
TextView mTitle;
@BindView(2131296948)
TextView regArea;
@BindView(2131296956)
TextView regBtn;
@BindView(2131296951)
EditText regPhone;
@BindView(2131296952)
EditText regPwd;
@BindView(2131296936)
CheckBox regPwdSafe;
@BindView(2131296955)
EditText regVercode;
@BindView(2131296954)
ImageView rmRegPhone;
@BindView(2131297140)
LinearLayout titleLeftLayout;
@BindView(2131297142)
LinearLayout titleRightLayout;
@BindView(2131297176)
TextView vercodeTip;
private void checkRegPhone()
{
if (!StringUtils.isEmpty(this.regPhone.getText()))
{
if ((!StringUtils.isEmpty(this.regPwd.getText())) && (!StringUtils.isEmpty(this.regVercode.getText()))) {
this.regBtn.setEnabled(true);
}
this.rmRegPhone.setVisibility(0);
return;
}
this.regBtn.setEnabled(false);
this.rmRegPhone.setVisibility(4);
}
private void checkRegPwd()
{
if (!StringUtils.isEmpty(this.regPwd.getText()))
{
if ((!StringUtils.isEmpty(this.regPhone.getText())) && (!StringUtils.isEmpty(this.regVercode.getText()))) {
this.regBtn.setEnabled(true);
}
this.regPwdSafe.setVisibility(0);
return;
}
this.regBtn.setEnabled(false);
this.regPwdSafe.setVisibility(4);
}
private void checkRegVercode()
{
if (!StringUtils.isEmpty(this.regVercode.getText()))
{
if ((!StringUtils.isEmpty(this.regPhone.getText())) && (!StringUtils.isEmpty(this.regPwd.getText()))) {
this.regBtn.setEnabled(true);
}
}
else {
this.regBtn.setEnabled(false);
}
}
private void getVercode()
{
String str1 = this.regArea.getText().toString().trim();
String str2 = this.regPhone.getText().toString().trim();
this.request.clear();
this.request.put("noncestr", SignConfig.noncestr);
this.request.put("timestamp", SignConfig.timestamp);
this.request.put("sbID", SignConfig.sbID);
this.request.put("sign", SignConfig.sign);
this.request.put("code", str1);
this.request.put("iso_code", (String)PreferenceUtil.get(Utils.getContext(), "iso_code", "AU"));
this.request.put("mobile", str2);
this.request.put("devicetype", "0");
this.request.put("interfaceVersion", Utils.interfaceVersion);
Api.getService().getCode(this.request).enqueue(new CommonCallBack(this, true)
{
public void onResponse(Call<ResponseBody> paramAnonymousCall, Response<ResponseBody> paramAnonymousResponse)
{
super.onResponse(paramAnonymousCall, paramAnonymousResponse);
if (RegisterActivity.this.isDestroy) {
return;
}
paramAnonymousCall = StringUtils.toJsonObject(this.json);
if (paramAnonymousCall == null) {
return;
}
if (paramAnonymousCall.optString("status").equals("200"))
{
paramAnonymousResponse = StringUtils.toJsonObject(paramAnonymousCall.optString("data"));
if ((paramAnonymousResponse != null) && (!StringUtils.isEmpty(paramAnonymousResponse.optString("expire"))))
{
RegisterActivity.access$602(RegisterActivity.this, Integer.parseInt(paramAnonymousResponse.optString("expire")));
paramAnonymousResponse = RegisterActivity.this;
RegisterActivity.access$702(paramAnonymousResponse, paramAnonymousResponse.mCountCloud);
}
RegisterActivity.this.mHandler.sendMessageDelayed(Message.obtain(), 1000L);
}
ToastUtils.showShort(paramAnonymousCall.optString("msg"));
}
});
}
private void initView()
{
this.titleLeftLayout.setVisibility(0);
this.mTitle.setText("注册");
this.titleRightLayout.setVisibility(8);
Object localObject = (String)PreferenceUtil.get(Utils.getContext(), "area_country", "");
if (!StringUtils.isEmpty((CharSequence)localObject)) {
this.regArea.setText((CharSequence)localObject);
}
localObject = new Timer();
String str = (String)PreferenceUtil.get(Utils.getContext(), "ACCOUNTID", "");
if (!StringUtils.isEmpty(str))
{
if (!str.contains("@")) {
this.regPhone.setText(str);
}
((Timer)localObject).schedule(new TimerTask()
{
public void run()
{
RegisterActivity localRegisterActivity = RegisterActivity.this;
localRegisterActivity.showKeyboard(localRegisterActivity.regPwd);
}
}, 200L);
}
else
{
((Timer)localObject).schedule(new TimerTask()
{
public void run()
{
RegisterActivity localRegisterActivity = RegisterActivity.this;
localRegisterActivity.showKeyboard(localRegisterActivity.regPhone);
}
}, 200L);
}
checkRegPhone();
checkRegVercode();
checkRegPwd();
this.regPhone.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable paramAnonymousEditable) {}
public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {}
public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
{
RegisterActivity.this.checkRegPhone();
}
});
this.regPwd.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable paramAnonymousEditable) {}
public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {}
public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
{
RegisterActivity.this.checkRegPwd();
}
});
this.regVercode.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable paramAnonymousEditable) {}
public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {}
public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
{
RegisterActivity.this.checkRegVercode();
}
});
this.regPwdSafe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton paramAnonymousCompoundButton, boolean paramAnonymousBoolean)
{
if (paramAnonymousBoolean)
{
RegisterActivity.this.regPwd.setInputType(144);
RegisterActivity.this.regPwd.setSelection(RegisterActivity.this.regPwd.getText().toString().length());
return;
}
RegisterActivity.this.regPwd.setInputType(129);
RegisterActivity.this.regPwd.setSelection(RegisterActivity.this.regPwd.getText().toString().length());
}
});
}
private void regAccount()
{
String str1 = this.regPhone.getText().toString().trim();
String str2 = this.regArea.getText().toString().trim();
String str3 = this.regPwd.getText().toString().trim();
String str4 = this.regVercode.getText().toString().trim();
if (StringUtils.isEmpty(str1))
{
ToastUtils.showShort("请输入电话号码");
return;
}
if (str2.equals("区号"))
{
ToastUtils.showShort("请选择手机区号");
return;
}
if (StringUtils.isEmpty(str4))
{
ToastUtils.showShort("请输入短信验证码");
return;
}
if (StringUtils.isEmpty(str3))
{
ToastUtils.showShort("请输入登录密码");
return;
}
if (str3.length() < 6)
{
ToastUtils.showShort("请输入6-16位登录密码");
return;
}
this.request.clear();
this.request.put("noncestr", SignConfig.noncestr);
this.request.put("timestamp", SignConfig.timestamp);
this.request.put("sbID", SignConfig.sbID);
this.request.put("sign", SignConfig.sign);
this.request.put("code", str2);
this.request.put("iso_code", (String)PreferenceUtil.get(Utils.getContext(), "iso_code", "AU"));
this.request.put("mobile", str1);
this.request.put("verifyCode", str4);
this.request.put("password", str3);
this.request.put("devicetype", "0");
this.request.put("interfaceVersion", Utils.interfaceVersion);
Api.getService().Register(this.request).enqueue(new CommonCallBack(this, true)
{
public void onResponse(Call<ResponseBody> paramAnonymousCall, Response<ResponseBody> paramAnonymousResponse)
{
super.onResponse(paramAnonymousCall, paramAnonymousResponse);
if (RegisterActivity.this.isDestroy) {
return;
}
if (!StringUtils.isEmpty(this.json))
{
paramAnonymousCall = StringUtils.toJsonObject(this.json);
if (paramAnonymousCall == null) {
return;
}
if (paramAnonymousCall.optString("status").equals("200"))
{
paramAnonymousResponse = StringUtils.toJsonObject(paramAnonymousCall.optString("data"));
if (paramAnonymousResponse == null) {
return;
}
PreferenceUtil.put(Utils.getContext(), "token", paramAnonymousResponse.optString("token"));
RegisterActivity.this.gotoActivity(BasicInfoActivity.class);
RegisterActivity.this.finish();
}
ToastUtils.showShort(paramAnonymousCall.optString("msg"));
}
}
});
}
private void showKeyboard(final TextView paramTextView)
{
runOnUiThread(new Runnable()
{
public void run()
{
TextView localTextView = paramTextView;
if (localTextView != null)
{
localTextView.setFocusable(true);
paramTextView.setFocusableInTouchMode(true);
if (!StringUtils.isEmpty(RegisterActivity.this.regPhone.getText().toString())) {
paramTextView.requestFocus();
}
((InputMethodManager)paramTextView.getContext().getSystemService("input_method")).showSoftInput(paramTextView, 0);
}
}
});
}
public void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
super.onActivityResult(paramInt1, paramInt2, paramIntent);
if ((paramInt1 == 10) && (paramIntent != null))
{
paramIntent = paramIntent.getExtras().getString("area");
this.regArea.setText(paramIntent);
}
}
@OnClick({2131297140, 2131296948, 2131296955, 2131296954, 2131296956, 2131297176})
public void onClick(View paramView)
{
switch (paramView.getId())
{
default:
return;
case 2131297176:
getVercode();
return;
case 2131297140:
finish();
return;
case 2131296956:
regAccount();
return;
case 2131296954:
this.regPhone.setText("");
return;
}
startActivityForResult(new Intent(Utils.getContext(), AreaActivity.class), 10);
}
protected void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(2131493025);
initBase();
initView();
KanApplication.getDefaultTracker().setScreenName("登录_注册");
KanApplication.getDefaultTracker().send(new HitBuilders.ScreenViewBuilder().build());
}
protected void onDestroy()
{
super.onDestroy();
this.mHandler.removeCallbacksAndMessages(null);
this.mHandler = null;
}
public void todo()
{
this.mCount -= 1;
if (this.mCount > 0)
{
this.vercodeTip.setEnabled(false);
this.mHandler.sendEmptyMessageDelayed(0, 1000L);
TextView localTextView = this.vercodeTip;
StringBuilder localStringBuilder = new StringBuilder();
localStringBuilder.append(this.mCount);
localStringBuilder.append("秒");
localTextView.setText(localStringBuilder.toString());
return;
}
this.vercodeTip.setText("获取验证码");
this.mCount = this.mCountCloud;
this.vercodeTip.setEnabled(true);
}
private static class MyHandler
extends Handler
{
private final WeakReference<RegisterActivity> mActivity;
public MyHandler(RegisterActivity paramRegisterActivity)
{
this.mActivity = new WeakReference(paramRegisterActivity);
}
public void handleMessage(Message paramMessage)
{
if (this.mActivity.get() == null) {
return;
}
((RegisterActivity)this.mActivity.get()).todo();
}
}
}
from kantv-downloader-cli.
Related Issues (20)
- Add downloading "selected/some of" episodes video option, only raw files
- Add ffmpeg integration to convert the downloaded m3u8 files to mkv
- Add config, need to be persistent
- Figuring out how the response get decoded HOT 4
- Integrate with CI platform HOT 1
- Add option to show streaming play link, which can be used for playing videos on 3rd party playsers
- The souce codes are pieces of shits, there's no point to rewrite it in Golang. I'll move it to Java and copy pages source codes. HOT 1
- Use UUID generator tool to generate and save the UUID for persistence
- Allow user to set android ID
- Add verbose flag to allow the flag was accessible via all apis HOT 1
- Migrate to urfav/cli v2
- Implement json parser in a neat and easy way
- Some API dumps HOT 2
- Add build targets to different platforms for releases HOT 1
- Better video download experience HOT 1
- Add anonymous API HOT 1
- Add search function, need to page the results
- Add downloading one video option, only raw files HOT 1
- Add downloading all episodes video option, only raw files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kantv-downloader-cli.