Example #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    //		AdManager.getInstance(this).init("81b5d6a3b8130593", "51f70349743c649d", false);
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
      // 结束你的activity
      this.finish();
      return;
    }
    hideTitlebar();

    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    SharedPreferences sp = getSharedPreferences(GuideActivity.SP_NAME, MODE_PRIVATE);
    if (sp.getInt(GuideActivity.SP_KEY, 0) == 0) {
      Intent intent = new Intent(this, GuideActivity.class);
      startActivity(intent);
      this.finish();
      return;
    }

    initView();

    SharedPreferences shortcutpref =
        WeFlowApplication.getAppInstance().getSharedPreferences("shortcut", Context.MODE_PRIVATE);
    boolean iscreated = shortcutpref.getBoolean("iscreated", false);
    if (!iscreated) {
      createDeskShortCut();
    }

    DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "weflowdb", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();

    accountInfoDao = daoSession.getAccountInfoDao();
    aiList = accountInfoDao.loadAll();

    if (aiList != null && aiList.size() > 0) {
      AccountInfo lastAcc = aiList.get(0);
      if (lastAcc.getUserid() != null && !lastAcc.getUserid().equals("")) {
        // 存在userid
        Requester.autoLogin(false, handler, lastAcc.getUserid());
        return;
      }
    }
    handler.postDelayed(runnable, INTV_TIME);
  }
Example #2
0
  @Override
  public boolean handleMessage(Message msg) {
    switch (msg.what) {
      case Requester.RESPONSE_TYPE_AUTO_LOGIN:
        autoLoginResponse alogin = (autoLoginResponse) msg.obj;
        if (alogin != null) {
          if (alogin.status.equals("0") || alogin.status.equals("0000")) { // 自动登录成功
            AccountInfo acc = new AccountInfo();
            acc.setIsregistration(alogin.isregistration);
            acc.setFlowcoins(alogin.flowcoins);
            acc.setMakeflow(alogin.makeflow);
            acc.setUseflow(alogin.useflow);
            acc.setUserid(alogin.userid);
            acc.setTel(alogin.tel);
            acc.setNickname(alogin.nickname);
            accountInfoDao.deleteAll();
            accountInfoDao.insertOrReplace(acc);
            if (alogin.tel != null && !alogin.tel.equals("")) {
              WeFlowApplication.getAppInstance().addJPushTag(alogin.tel);
            }
            handler.postDelayed(runnable, INTV_TIME);
          } else {
            PromptDialog.Alert(WelcomePageActivity.class, "登录失败,请重新登录");
            Intent i = new Intent(this, LoginActivity.class);
            if (aiList != null && aiList.size() > 0) {
              i.putExtra("tel", aiList.get(0).getTel());
            }
            startActivity(i);
            this.finish();
          }
        } else {
          PromptDialog.Alert(WelcomePageActivity.class, "您的网络不给力啊!");
          handler.postDelayed(runnable, INTV_TIME);
        }
        break;
        /*		case Requester.RESPONSE_TYPE_UPDATE:
        			if (msg.obj != null) {
        				final UpdateResp resp = (UpdateResp) msg.obj;
        				if (Requester.isSuccessed(resp.status)) {
        					try {
        						resp.type = "2";
        						//已经最新
        						if ("0".equals(resp.type)) {
        //							PromptDialog.Dialog(this, "版本升级", "当前已经是最新版本", "确定");
        							//普通升级
        						} else if ("1".equals(resp.type)) {
        							PromptDialog.Dialog(this, true, true, false, "版本升级", resp.description, "下载", "取消", new OnClickListener() {

        								@Override
        								public void onClick(DialogInterface dialog, int which) {
        									// TODO Auto-generated method stub
        									DownloadManager.getInstance().addDownloadTask(resp.filepath, "0", resp.version, "", "",  DownloadType.APP, "", "","","com.etoc.weflow");
        								}
        							}, null, false, null);
        							//强制升级
        						} else if ("2".equals(resp.type)){
        							PromptDialog.Dialog(this, false, false, false, "版本升级", resp.description, "下载", "取消", new OnClickListener() {

        								@Override
        								public void onClick(DialogInterface dialog, int which) {
        									// TODO Auto-generated method stub
        									DownloadManager.getInstance().addDownloadTask(resp.filepath, "0", resp.version, "", "",  DownloadType.APP, "", "","","com.etoc.weflow");
        								}
        							}, null, false, null);
        						}
        					} catch(Exception e) {
        						e.printStackTrace();
        					}
        				}
        			}
        			break;*/
    }
    return false;
  }