package com.usermodule; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.mm.android.deviceaddmodule.LCDeviceEngine; import com.mm.android.deviceaddmodule.mobilecommon.base.BaseActivity; import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil; import com.usermodule.net.IUserDataCallBack; import com.usermodule.net.UserNetManager; //import static com.mm.android.deviceaddmodule.mobilecommon.route.RoutePathManager.ActivityPath.LoginActivityPath; import com.lechange.demo.R; public class LoginActivity extends BaseActivity implements View.OnClickListener { public static final String TAG = BaseActivity.class.getSimpleName(); TextView mName; LinearLayout mLoginBtn; TextView mRegesiter; ImageView mReturn; private String mOpenId; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_activity); initView(); } private void initView(){ mOpenId = "c11b4f38c6aa4563a17e3cb35b6882df06"; getSubAccountToken(mOpenId); } @Override public void onClick(View v) { int id = v.getId(); if (id == R.id.login_login) { getSubAccountToken(mOpenId); } else if (id == R.id.user_register) { toRegesiterPage(); }else if (id == R.id.iv_back){ finish(); } } private void toRegesiterPage(){ Intent intent = new Intent(this, UserRegesiterActivity.class); startActivity(intent); } private void getSubAccountToken(String openId){ UserNetManager.getInstance().subAccountToken(openId, new IUserDataCallBack() { @Override public void onCallBackOpenId(String str) { if (str!=null){ //暂不保存到sp中了,因为获取需要context。 // PreferencesHelper.getInstance(getApplicationContext()).set(Constants.SUBACCOUNTTOKEN,str); LogUtil.debugLog(TAG,"str:::"+str); LCDeviceEngine.newInstance().setSubAccessToken(str); toDeviceList(); } } @Override public void onError(Throwable throwable) { } }); } private void toDeviceList(){ // ARouter.getInstance().build(RoutePathManager.ActivityPath.DeviceListActivityPath).navigation(); } }