| | |
| | | import android.text.TextUtils; |
| | | import android.text.method.LinkMovementMethod; |
| | | import android.text.style.ClickableSpan; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.user.HDLLinkPMUser; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.me.WebActivity; |
| | |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | |
| | | import java.util.List; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | | |
| | | |
| | | /** |
| | |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | //初始化服务器域名(用户注册所在服务器域名地址) |
| | | AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); |
| | | //判断AccessToken是否null |
| | | if (!TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, BPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | // showLoading(); |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | | public void onSuccess(List<HouseIdBean> obj) { |
| | | // hideLoading(); |
| | | HdlResidenceLogic.getInstance().setHouseIdList(obj); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, CPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | // hideLoading(); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, CPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | }); |
| | | } |
| | | //发布审核小米应用市场要求APP第一次启动提前提示《用户协议》和《隐私政策》才允许上线 |
| | | final String key = "is_login"; |
| | | boolean isLogin = SharedPreUtils.getBoolean(key); |
| | | if (!isLogin) { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(this); |
| | | confirmationCancelDialog.setTitle(getString(R.string.user_agreement_and_privacy_agreement)); |
| | | confirmationCancelDialog.setContent(getString(R.string.thank_you_for_using)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.agree)); |
| | | confirmationCancelDialog.setCancel(getString(R.string.loading_on_agree)); |
| | | confirmationCancelDialog.show(); |
| | | setStringDifferentColors(confirmationCancelDialog.getContentTextView()); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | confirmationCancelDialog.dismiss(); |
| | | SharedPreUtils.putBoolean(key, false); |
| | | finish(); |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | confirmationCancelDialog.dismiss(); |
| | | initSdk(); |
| | | SharedPreUtils.putBoolean(key, true); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, LoginActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | }); |
| | | } else { |
| | | //发布审核小米应用市场要求APP第一次启动提前提示《用户协议》和《隐私政策》才允许上线 |
| | | final String key = "is_login"; |
| | | boolean isLogin = SharedPreUtils.getBoolean(key); |
| | | if (isLogin) { |
| | | initSdk(); |
| | | //初始化服务器域名(用户注册所在服务器域名地址) |
| | | AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); |
| | | //判断AccessToken是否null |
| | | if (!TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) { |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //安装商跳转界面 |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, BPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } else { |
| | | //C端用户跳转界面 |
| | | // showLoading(); |
| | | HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { |
| | | @Override |
| | | public void onSuccess(List<HouseIdBean> obj) { |
| | | // hideLoading(); |
| | | HdlResidenceLogic.getInstance().setHouseIdList(obj); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, CPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | // hideLoading(); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, CPowerStationActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, LoginActivity.class); |
| | | openActivity(intent); |
| | | } else { |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(this); |
| | | confirmationCancelDialog.setTitle(getString(R.string.user_agreement_and_privacy_agreement)); |
| | | confirmationCancelDialog.setContent(getString(R.string.thank_you_for_using)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.agree)); |
| | | confirmationCancelDialog.setCancel(getString(R.string.loading_on_agree)); |
| | | confirmationCancelDialog.show(); |
| | | setStringDifferentColors(confirmationCancelDialog.getContentTextView()); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | SharedPreUtils.putBoolean(key, false); |
| | | finish(); |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | SharedPreUtils.putBoolean(key, true); |
| | | Intent intent = new Intent(); |
| | | intent.setClass(StartActivity.this, LoginActivity.class); |
| | | openActivity(intent); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_E6FFFFFF, null)); |
| | | ds.setColor(getResources().getColor(R.color.text_FFACACAC, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(!UserConfigManage.getInstance().isZh()); |
| | | } |
| | |
| | | public void updateDrawState(@NonNull TextPaint ds) { |
| | | super.updateDrawState(ds); |
| | | //设置字体颜色 |
| | | ds.setColor(getResources().getColor(R.color.text_E6FFFFFF, null)); |
| | | ds.setColor(getResources().getColor(R.color.text_FFACACAC, null)); |
| | | // 去掉下划线 |
| | | ds.setUnderlineText(!UserConfigManage.getInstance().isZh()); |
| | | } |
| | |
| | | } |
| | | textView.setText(spannable); |
| | | //中途遇到点击后字体显示高亮,取消高亮 |
| | | textView.setHighlightColor(getResources().getColor(R.color.text_66FFFFFF, null)); |
| | | textView.setHighlightColor(getResources().getColor(R.color.text_FF5B5B5B, null)); |
| | | //最后设置可点击,必须实现,否则只能显示样式,无法实现点击效果 |
| | | textView.setMovementMethod(LinkMovementMethod.getInstance()); |
| | | } catch (Exception ignored) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 初始化三方相关SDK |
| | | * 小米平台上线,需要先同意后,在初始化极光SDK,否则平台审核不让通过 |
| | | */ |
| | | private void initSdk() { |
| | | if (HDLApp.getInstance().isStartInitThirdSDK) { |
| | | return; |
| | | } |
| | | HDLApp.getInstance().isStartInitThirdSDK = true; |
| | | //初始化极光推送 |
| | | initJPush(); |
| | | } |
| | | |
| | | /** |
| | | * 初始化极光SDK |
| | | */ |
| | | private void initJPush() { |
| | | JPushInterface.setDebugMode(true); |
| | | JPushInterface.init(getBaseContext()); |
| | | } |
| | | |
| | | } |