|
@@ -3,24 +3,34 @@ package com.sheep.gamegroup.view.activity;
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
|
|
+import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
|
|
+import com.sheep.gamegroup.greendao.DDProviderHelper;
|
|
|
|
|
+import com.sheep.gamegroup.greendao.download.SdkLoginUser;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
import com.sheep.gamegroup.util.CertificationUtil;
|
|
import com.sheep.gamegroup.util.CertificationUtil;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
|
|
+import com.sheep.gamegroup.util.ListUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.customview.TextProgressBar;
|
|
import com.sheep.gamegroup.view.customview.TextProgressBar;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
import butterknife.OnClick;
|
|
import butterknife.OnClick;
|
|
|
import rx.functions.Action1;
|
|
import rx.functions.Action1;
|
|
@@ -32,29 +42,31 @@ import rx.functions.Action1;
|
|
|
|
|
|
|
|
public class GameCertificationActivity extends BaseActivity {
|
|
public class GameCertificationActivity extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
+ @BindView(R.id.sdk_arrow)
|
|
|
|
|
+ ImageView sdk_arrow;
|
|
|
@BindView(R.id.icon_iv)
|
|
@BindView(R.id.icon_iv)
|
|
|
ImageView icon_iv;
|
|
ImageView icon_iv;
|
|
|
@BindView(R.id.app_name_tv)
|
|
@BindView(R.id.app_name_tv)
|
|
|
TextView app_name_tv;
|
|
TextView app_name_tv;
|
|
|
- @BindView(R.id.name_tv)
|
|
|
|
|
- TextView name_tv;
|
|
|
|
|
- @BindView(R.id.invite_num_tv)
|
|
|
|
|
- TextView invite_num_tv;
|
|
|
|
|
- @BindView(R.id.user_icon_iv)
|
|
|
|
|
- ImageView user_icon_iv;
|
|
|
|
|
|
|
+ @BindView(R.id.sdk_user_name)
|
|
|
|
|
+ TextView sdk_user_name;
|
|
|
|
|
+ @BindView(R.id.sdk_user_code)
|
|
|
|
|
+ TextView sdk_user_code;
|
|
|
|
|
+ @BindView(R.id.sdk_user_iv)
|
|
|
|
|
+ ImageView sdk_user_iv;
|
|
|
|
|
+ @BindView(R.id.sdk_change_user_list)
|
|
|
|
|
+ RecyclerView sdk_change_user_list;
|
|
|
@BindView(R.id.loading_view_img)
|
|
@BindView(R.id.loading_view_img)
|
|
|
View loading_view_img;
|
|
View loading_view_img;
|
|
|
@BindView(R.id.change_account_tv)
|
|
@BindView(R.id.change_account_tv)
|
|
|
TextView change_account_tv;
|
|
TextView change_account_tv;
|
|
|
@BindView(R.id.change_commit)
|
|
@BindView(R.id.change_commit)
|
|
|
TextView change_commit;
|
|
TextView change_commit;
|
|
|
- @BindView(R.id.empty_view)
|
|
|
|
|
- View empty_view;
|
|
|
|
|
|
|
|
|
|
private Activity activity;
|
|
private Activity activity;
|
|
|
private Bundle extras;
|
|
private Bundle extras;
|
|
|
- private UserEntity userEntity;
|
|
|
|
|
- private String packgeName;
|
|
|
|
|
|
|
+ private UserEntity userEntity;
|
|
|
|
|
+ private String packageName;
|
|
|
private TextProgressBar textProgressBar;
|
|
private TextProgressBar textProgressBar;
|
|
|
private boolean isChangeAccount;
|
|
private boolean isChangeAccount;
|
|
|
|
|
|
|
@@ -70,7 +82,51 @@ public class GameCertificationActivity extends BaseActivity {
|
|
|
textProgressBar.setVisibility(View.VISIBLE);
|
|
textProgressBar.setVisibility(View.VISIBLE);
|
|
|
TitleBarUtils.getInstance().setTitle(activity, "授权登录")
|
|
TitleBarUtils.getInstance().setTitle(activity, "授权登录")
|
|
|
.setTitleListen(activity, 0, null);
|
|
.setTitleListen(activity, 0, null);
|
|
|
|
|
+ sdk_change_user_list.setVisibility(View.GONE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<SdkLoginUser> userList = ListUtil.emptyList();
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void initListener() {
|
|
|
|
|
+ sdk_change_user_list.setLayoutManager(new LinearLayoutManager(this));
|
|
|
|
|
+ sdk_change_user_list.setHasFixedSize(true);
|
|
|
|
|
+ sdk_change_user_list.setNestedScrollingEnabled(false);
|
|
|
|
|
+ sdk_change_user_list.setAdapter(new RecyclerViewAdapter<SdkLoginUser>(this, R.layout.include_item_sdk_user, userList) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void convert(ViewHolder viewHolder, final SdkLoginUser item, final int position) {
|
|
|
|
|
+ ImageView item_sdk_arrow = viewHolder.itemView.findViewById(R.id.item_sdk_arrow);
|
|
|
|
|
+ ImageView item_sdk_user_iv = viewHolder.itemView.findViewById(R.id.item_sdk_user_iv);
|
|
|
|
|
+ TextView item_sdk_user_name = viewHolder.itemView.findViewById(R.id.item_sdk_user_name);
|
|
|
|
|
+ TextView item_sdk_user_code = viewHolder.itemView.findViewById(R.id.item_sdk_user_code);
|
|
|
|
|
+ View item_sdk_user_line = viewHolder.itemView.findViewById(R.id.item_sdk_user_line);
|
|
|
|
|
+ ViewUtil.setVisibility2(item_sdk_user_line, position != 0);
|
|
|
|
|
+ ViewUtil.setText(item_sdk_user_name, item.getNickname());
|
|
|
|
|
+ ViewUtil.setText(item_sdk_user_code, item.getInvitation_code());
|
|
|
|
|
+ GlideImageLoader.setAvatar(item_sdk_user_iv, item.getAvatar());
|
|
|
|
|
+ item_sdk_arrow.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View view) {
|
|
|
|
|
+ DDProviderHelper.getInstance().deleteSdkLoginUser(SheepApp.getInstance(), item);
|
|
|
|
|
+ try {
|
|
|
|
|
+ userList.remove(position);
|
|
|
|
|
+ sdk_change_user_list.getAdapter().notifyDataSetChanged();
|
|
|
|
|
+ ViewUtil.setVisibility(sdk_change_user_list, !userList.isEmpty() && isUserListOpen);
|
|
|
|
|
+ ViewUtil.setVisibility2(sdk_arrow, !userList.isEmpty());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View view) {
|
|
|
|
|
+ CertificationUtil.newInstance().authCertificationCode(activity, item.getToken());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void initData() {
|
|
public void initData() {
|
|
@@ -78,27 +134,43 @@ public class GameCertificationActivity extends BaseActivity {
|
|
|
userEntity = DataUtil.getInstance().getUserEntity();
|
|
userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
if (extras != null) {
|
|
if (extras != null) {
|
|
|
SheepApp.getInstance().setGameCode(extras.getString(getString(R.string.kfzs_duanduan_datashare_game_code), ""));
|
|
SheepApp.getInstance().setGameCode(extras.getString(getString(R.string.kfzs_duanduan_datashare_game_code), ""));
|
|
|
- packgeName = extras.getString(getString(R.string.kfzs_duanduan_datashare_package_name), "");
|
|
|
|
|
- SheepApp.getInstance().setGamePackgeName(packgeName);
|
|
|
|
|
- if(TextUtils.isEmpty(SheepApp.getInstance().getGameCode()) || TextUtils.isEmpty(packgeName)){
|
|
|
|
|
- CertificationUtil.newInstance().showCertificationErrorAndExitApp("",2000);
|
|
|
|
|
|
|
+ packageName = extras.getString(getString(R.string.kfzs_duanduan_datashare_package_name), "");
|
|
|
|
|
+ SheepApp.getInstance().setGamePackgeName(packageName);
|
|
|
|
|
+ if (TextUtils.isEmpty(SheepApp.getInstance().getGameCode()) || TextUtils.isEmpty(packageName)) {
|
|
|
|
|
+ CertificationUtil.newInstance().showCertificationErrorAndExitApp("", 2000);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
hasToken();
|
|
hasToken();
|
|
|
} else {
|
|
} else {
|
|
|
- CertificationUtil.newInstance().showCertificationErrorAndExitApp("",2000);
|
|
|
|
|
|
|
+ CertificationUtil.newInstance().showCertificationErrorAndExitApp("", 2000);
|
|
|
}
|
|
}
|
|
|
|
|
+ //获取登录过的用户列表
|
|
|
|
|
+ userList.addAll(DDProviderHelper.getInstance().getSdkLoginUserList(activity, SheepApp.getInstance().getConnectAddress().name()));
|
|
|
|
|
+ sdk_change_user_list.getAdapter().notifyDataSetChanged();
|
|
|
|
|
+ ViewUtil.setVisibility2(sdk_arrow, !userList.isEmpty());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @OnClick({R.id.icon_iv, R.id.change_account_tv, R.id.change_commit})
|
|
|
|
|
|
|
+ //是否展开登录用户列表
|
|
|
|
|
+ private boolean isUserListOpen = false;
|
|
|
|
|
+
|
|
|
|
|
+ @OnClick({R.id.icon_iv, R.id.change_account_tv, R.id.change_commit, R.id.sdk_arrow})
|
|
|
public void onViewClicked(View view) {
|
|
public void onViewClicked(View view) {
|
|
|
switch (view.getId()) {
|
|
switch (view.getId()) {
|
|
|
|
|
+ case R.id.sdk_arrow:
|
|
|
|
|
+ if (isUserListOpen) {//展开
|
|
|
|
|
+ sdk_arrow.setRotation(0);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sdk_arrow.setRotation(180);
|
|
|
|
|
+ }
|
|
|
|
|
+ isUserListOpen = !isUserListOpen;
|
|
|
|
|
+ ViewUtil.setVisibility(sdk_change_user_list, isUserListOpen);
|
|
|
|
|
+ break;
|
|
|
case R.id.icon_iv:
|
|
case R.id.icon_iv:
|
|
|
textProgressBar.setVisibility(View.GONE);
|
|
textProgressBar.setVisibility(View.GONE);
|
|
|
break;
|
|
break;
|
|
|
case R.id.change_account_tv:
|
|
case R.id.change_account_tv:
|
|
|
isChangeAccount = true;
|
|
isChangeAccount = true;
|
|
|
- Jump2View.getInstance().goLoginView(activity,SheepApp.getInstance().getGameCode());
|
|
|
|
|
|
|
+ Jump2View.getInstance().goLoginView(activity, SheepApp.getInstance().getGameCode());
|
|
|
break;
|
|
break;
|
|
|
case R.id.change_commit:
|
|
case R.id.change_commit:
|
|
|
commitChange();
|
|
commitChange();
|
|
@@ -113,52 +185,52 @@ public class GameCertificationActivity extends BaseActivity {
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
- if(!isChangeAccount)
|
|
|
|
|
- CertificationUtil.newInstance().authCerticicationCode(activity);
|
|
|
|
|
|
|
+ if (!isChangeAccount)
|
|
|
|
|
+ CertificationUtil.newInstance().authCertificationCode(activity, SpUtils.getToken(SheepApp.getInstance()));
|
|
|
}
|
|
}
|
|
|
- },3000);
|
|
|
|
|
|
|
+ }, 3000);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 是否登录
|
|
* 是否登录
|
|
|
* 请求授权
|
|
* 请求授权
|
|
|
*/
|
|
*/
|
|
|
- private void hasToken(){
|
|
|
|
|
|
|
+ private void hasToken() {
|
|
|
String token = SpUtils.getToken(SheepApp.getInstance());
|
|
String token = SpUtils.getToken(SheepApp.getInstance());
|
|
|
- if(TextUtils.isEmpty(token)){
|
|
|
|
|
- Jump2View.getInstance().goLoginView(activity,SheepApp.getInstance().getGameCode());
|
|
|
|
|
- }else {
|
|
|
|
|
- if(userEntity == null){
|
|
|
|
|
|
|
+ if (TextUtils.isEmpty(token)) {
|
|
|
|
|
+ Jump2View.getInstance().goLoginView(activity, SheepApp.getInstance().getGameCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (userEntity == null) {
|
|
|
CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
|
|
CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
@Override
|
|
|
public void call(UserEntity userEntity) {
|
|
public void call(UserEntity userEntity) {
|
|
|
- if(userEntity == null){
|
|
|
|
|
- Jump2View.getInstance().goLoginView(activity,SheepApp.getInstance().getGameCode());
|
|
|
|
|
- }else {
|
|
|
|
|
|
|
+ if (userEntity == null) {
|
|
|
|
|
+ Jump2View.getInstance().goLoginView(activity, SheepApp.getInstance().getGameCode());
|
|
|
|
|
+ } else {
|
|
|
initWidget();
|
|
initWidget();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
initWidget();
|
|
initWidget();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 赋值
|
|
* 赋值
|
|
|
*/
|
|
*/
|
|
|
- private void initWidget(){
|
|
|
|
|
- empty_view.setVisibility(View.GONE);
|
|
|
|
|
- name_tv.setText(userEntity.getNickname());
|
|
|
|
|
- invite_num_tv.setText(userEntity.getInvitation_code()+"");
|
|
|
|
|
- GlideImageLoader.setAvatar(user_icon_iv, userEntity.getAvatar());
|
|
|
|
|
|
|
+ private void initWidget() {
|
|
|
|
|
+ ViewUtil.setText(sdk_user_name, userEntity.getNickname());
|
|
|
|
|
+ ViewUtil.setText(sdk_user_code, userEntity.getInvitation_code());
|
|
|
|
|
+ GlideImageLoader.setAvatar(sdk_user_iv, userEntity.getAvatar());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onBackPressed() {
|
|
public void onBackPressed() {
|
|
|
super.onBackPressed();
|
|
super.onBackPressed();
|
|
|
- if (!TextUtils.isEmpty(SheepApp.getInstance().getGamePackgeName())){
|
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(SheepApp.getInstance().getGamePackgeName())) {
|
|
|
SheepApp.getInstance().setGameFlag(true);
|
|
SheepApp.getInstance().setGameFlag(true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|