|
|
@@ -1,34 +1,30 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
import android.Manifest;
|
|
|
-import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
-import android.content.res.Resources;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.ActivityCompat;
|
|
|
import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
|
|
|
+import com.sheep.gamegroup.SheepApp;
|
|
|
+import com.sheep.gamegroup.absBase.BaseUMActivity;
|
|
|
import com.sheep.gamegroup.di.components.DaggerLoginComponent;
|
|
|
-import com.sheep.gamegroup.di.components.LoginComponent;
|
|
|
import com.sheep.gamegroup.di.modules.LoginModule;
|
|
|
import com.sheep.gamegroup.presenter.LoginContract;
|
|
|
-import com.sheep.gamegroup.util.ActivityManager;
|
|
|
+import com.sheep.gamegroup.presenter.LoginPresenter;
|
|
|
+import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
-import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
-import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
|
-import com.sheep.jiuyan.samllsheep.page.MainActivity;
|
|
|
-import com.sheep.jiuyan.samllsheep.wxapi.WXEntryActivity;
|
|
|
import com.umeng.socialize.UMAuthListener;
|
|
|
import com.umeng.socialize.UMShareAPI;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
-import com.umeng.socialize.utils.SocializeUtils;
|
|
|
-import com.uuzuche.lib_zxing.decoding.Intents;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.inject.Inject;
|
|
|
+
|
|
|
import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.OnClick;
|
|
|
@@ -37,12 +33,17 @@ import butterknife.OnClick;
|
|
|
* Created by ljy on 2018/3/8.
|
|
|
*/
|
|
|
|
|
|
-public class LoginAct extends BaseActivity implements LoginContract.View{
|
|
|
- Activity activity;
|
|
|
- @BindView(R.id.weixin_login_tv)
|
|
|
- TextView weixinLoginTv;
|
|
|
+public class LoginAct extends BaseUMActivity implements LoginContract.View {
|
|
|
+
|
|
|
+ @Inject
|
|
|
+ LoginPresenter mPresenter;
|
|
|
@BindView(R.id.tel_login_tv)
|
|
|
TextView telLoginTv;
|
|
|
+ @BindView(R.id.iv_wx)
|
|
|
+ ImageView ivWx;
|
|
|
+ @BindView(R.id.iv_qq)
|
|
|
+ ImageView ivQq;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
@@ -51,21 +52,19 @@ public class LoginAct extends BaseActivity implements LoginContract.View{
|
|
|
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
- ActivityManager.getInstance().pushActivity(this);
|
|
|
- activity = this;
|
|
|
DaggerLoginComponent.builder()
|
|
|
.netComponent(SheepApp.get(this).getNetComponent())
|
|
|
.loginModule(new LoginModule(this))
|
|
|
.build()
|
|
|
- .inject(this);
|
|
|
- setTvBg(R.id.weixin_login_tv);
|
|
|
+ .inject(this);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void requestPremiss(){
|
|
|
- if(Build.VERSION.SDK_INT>=23){
|
|
|
- String[] mPermissionList = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.CALL_PHONE,Manifest.permission.READ_LOGS,Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.SET_DEBUG_APP,Manifest.permission.SYSTEM_ALERT_WINDOW,Manifest.permission.GET_ACCOUNTS,Manifest.permission.WRITE_APN_SETTINGS};
|
|
|
- ActivityCompat.requestPermissions(this,mPermissionList,123);
|
|
|
+ private void requestPremiss() {
|
|
|
+ if (Build.VERSION.SDK_INT >= 23) {
|
|
|
+ String[] mPermissionList = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CALL_PHONE, Manifest.permission.READ_LOGS, Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.SET_DEBUG_APP, Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.GET_ACCOUNTS, Manifest.permission.WRITE_APN_SETTINGS};
|
|
|
+ ActivityCompat.requestPermissions(this, mPermissionList, 123);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -77,7 +76,6 @@ public class LoginAct extends BaseActivity implements LoginContract.View{
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void initListener() {
|
|
|
|
|
|
@@ -89,87 +87,104 @@ public class LoginAct extends BaseActivity implements LoginContract.View{
|
|
|
}
|
|
|
|
|
|
|
|
|
- @OnClick({R.id.weixin_login_tv, R.id.tel_login_tv})
|
|
|
- public void onViewClicked(View view) {
|
|
|
-
|
|
|
- setTvBg(view.getId());
|
|
|
- switch (view.getId()) {
|
|
|
- case R.id.weixin_login_tv:
|
|
|
- goWeixin();
|
|
|
- break;
|
|
|
- case R.id.tel_login_tv:
|
|
|
- goTelLogin();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
private void goTelLogin() {
|
|
|
- Intent intent = new Intent(activity, PhoneAct.class);
|
|
|
+ Intent intent = new Intent(this, PhoneAct.class);
|
|
|
startActivity(intent);
|
|
|
-// finish();
|
|
|
+ finish();
|
|
|
}
|
|
|
|
|
|
private void goWeixin() {
|
|
|
UMShareAPI.get(this).doOauthVerify(this, SHARE_MEDIA.WEIXIN, new UMAuthListener() {
|
|
|
@Override
|
|
|
public void onStart(SHARE_MEDIA platform) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
|
|
|
+ mPresenter.logByAuther(1,data.get("access_token"),data.get("openid"));
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onError(SHARE_MEDIA platform, int action, Throwable t) {
|
|
|
+ showToast("微信授权失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancel(SHARE_MEDIA platform, int action) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void loginQQ() {
|
|
|
+ UMShareAPI.get(this).doOauthVerify(this, SHARE_MEDIA.QQ, new UMAuthListener() {
|
|
|
+ @Override
|
|
|
+ public void onStart(SHARE_MEDIA platform) {
|
|
|
+ showProgress();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
|
|
|
+// mPresenter.logByAuther(2,data.get("openid"));
|
|
|
+ mPresenter.logByAuther(2,data.get("access_token"),data.get("openid"));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
|
|
|
-
|
|
|
+ showToast("QQ授权失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onCancel(SHARE_MEDIA platform, int action) {
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ public void NetSuccess(int code, String msg) {
|
|
|
+ showToast(msg);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void NetError(int code, String errorMsg) {
|
|
|
+ showToast(errorMsg);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置按钮背景
|
|
|
- */
|
|
|
- private void setTvBg(int select){
|
|
|
- switch (select){
|
|
|
- case R.id.weixin_login_tv:
|
|
|
- weixinLoginTv.setBackgroundResource(R.drawable.sp_bg_transparency_line_white);
|
|
|
- weixinLoginTv.setTextColor(getResources().getColor(R.color.white));
|
|
|
- telLoginTv.setBackgroundColor(getResources().getColor(R.color.transparent));
|
|
|
- telLoginTv.setTextColor(getResources().getColor(R.color.grgray));
|
|
|
- break;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ // TODO: add setContentView(...) invocation
|
|
|
+ ButterKnife.bind(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @OnClick({R.id.tel_login_tv, R.id.iv_wx, R.id.iv_qq})
|
|
|
+ public void onViewClicked(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
case R.id.tel_login_tv:
|
|
|
- telLoginTv.setBackgroundResource(R.drawable.sp_bg_transparency_line_white);
|
|
|
- telLoginTv.setTextColor(getResources().getColor(R.color.white));
|
|
|
- weixinLoginTv.setBackgroundColor(getResources().getColor(R.color.transparent));
|
|
|
- weixinLoginTv.setTextColor(getResources().getColor(R.color.grgray));
|
|
|
+ goTelLogin();
|
|
|
+ break;
|
|
|
+ case R.id.iv_wx:
|
|
|
+ Jump2View.getInstance().goHomePageView(this,null);
|
|
|
+// goWeixin();
|
|
|
break;
|
|
|
- default:
|
|
|
- weixinLoginTv.setBackgroundResource(R.drawable.sp_bg_transparency_line_white);
|
|
|
- weixinLoginTv.setTextColor(getResources().getColor(R.color.white));
|
|
|
- telLoginTv.setBackgroundColor(getResources().getColor(R.color.transparent));
|
|
|
- telLoginTv.setTextColor(getResources().getColor(R.color.grgray));
|
|
|
+ case R.id.iv_qq:
|
|
|
+ loginQQ();
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|