admin
2021-02-03 1981dee5aec45793d3c4ebdbc4e637528c71b3c5
BuWanVideo/src/com/weikou/beibeivideo/ui/login/LoginActivity.java
@@ -12,19 +12,16 @@
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.lcjian.library.util.SingleToast;
import com.lcjian.library.util.common.StringUtils;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
@@ -32,16 +29,14 @@
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.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.BeibeiVideoApplication;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.ui.mine.BrowserActivity;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.util.XGPush;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.util.novel.NovelJNZUtil;
import org.apache.http.Header;
import org.json.JSONException;
@@ -97,7 +92,7 @@
        findViewById(R.id.login_tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                onResult(RESULT_CANCELED);
            }
        });
@@ -125,9 +120,13 @@
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.login_tv_cancel:// 取消
                finish();
                onResult(RESULT_CANCELED);
                break;
            case R.id.ll_login_qq:// QQ登录
                if (!cb_user_agreement.isChecked()) {
                    SingleToast.showToast(LoginActivity.this, "选择同意用户协议后方可登录");
                    break;
                }
                if (isQQClientAvailable()) {
                    loginType = "1";
                    // qq登录逻辑处理 点击登录后需要暂时锁定返回键和返回功能 不然会报错
@@ -139,6 +138,10 @@
                break;
            case R.id.ll_login_wx://微信登录
                if (!cb_user_agreement.isChecked()) {
                    SingleToast.showToast(LoginActivity.this, "选择同意用户协议后方可登录");
                    break;
                }
                if (isWXClientAvailable()) {
                    loginType = "2";
                    SendAuth.Req req = new SendAuth.Req();
@@ -241,12 +244,10 @@
                                    data.get("gender"));
                            edit.commit();
                            NovelJNZUtil.setUid(getApplicationContext());
                            SingleToast.showToast(LoginActivity.this,
                                    "登录成功");
                            XGPush.registerPush(LoginActivity.this);
                            finish();
                            onResult(RESULT_OK);
                        }
                        @Override
@@ -312,7 +313,7 @@
                            jsonObject.optJSONObject("Data").optString("Nickname"));
                    edit.commit();
                    SingleToast.showToast(LoginActivity.this, "登录成功" + "昵称为:" + jsonObject.optJSONObject("Data").optString("Nickname"));
                    finish();
                    onResult(RESULT_OK);
                } else {
                    SingleToast.showToast(LoginActivity.this, "登录失败");
                }
@@ -331,7 +332,7 @@
    public void onResume() {
        super.onResume();
        if (!StringUtils.isEmpty(getSharedPreferences("user", Context.MODE_PRIVATE).getString("LoginUid", ""))) {
            finish();
            onResult(RESULT_OK);
        }
        MobclickAgent.onPageStart("登录页");
    }
@@ -398,12 +399,10 @@
                                            response.getString("gender"));
                                    edit.commit();
                                    NovelJNZUtil.setUid(getApplicationContext());
                                    SingleToast.showToast(LoginActivity.this,
                                            "登录成功");
                                    XGPush.registerPush(LoginActivity.this);
                                    finish();
                                    onResult(RESULT_OK);
                                }
                                @Override
@@ -430,4 +429,19 @@
            }
        }
    };
    private void onResult(int resultCode) {
        boolean result = getIntent().getBooleanExtra("result", false);
        if (result) {
            Intent intent = new Intent();
            //把返回数据存入Intent
            setResult(resultCode, intent);
            //关闭Activity
            finish();
        } else {
            //关闭Activity
            finish();
        }
    }
}