Ejemplo n.º 1
0
 @Override
 public void onReceive(Context context, Intent intent) {
   int code = intent.getIntExtra("code", 0);
   if (99999 == code) {
     ToastUtil.toast(BaseActivity.this, intent.getStringExtra("reLoginReason"));
     // 重新登录
     RequestCenter.login(
         SharedPreferenceManager.getInstance().getString("lastLoginName", ""),
         SharedPreferenceManager.getInstance().getString("lastLoginPassword", ""),
         loginListener);
   } else if (30001 == code) {
     ToastUtil.toast(BaseActivity.this, intent.getStringExtra("reLoginReason"));
     // 登录失败
     SysManager.logout();
     SysManager.exitSystem(BaseActivity.this);
     startActivity(new Intent(BaseActivity.this, LoginActivity_.class));
   }
 }
  @Override
  protected void initView() {
    ivUserLogo.setImageResource(R.drawable.ic_head_default);
    ivUserLogo.setOnClickListener(this);
    btnSetting.setOnClickListener(this);
    ivScan.setOnClickListener(this);
    // 不启动任何刷新
    plServiceList.setMode(Mode.PULL_FROM_START);
    // 不显示指示器
    plServiceList.setShowIndicator(false);
    plServiceList
        .getLoadingLayoutProxy()
        .setLastUpdatedLabel(SharedPreferenceManager.getInstance().getString(getFragmentTag(), ""));
    plServiceList.setOnPullEventListener(pullEventListener);
    plServiceList.setOnRefreshListener(this);
    listView = plServiceList.getRefreshableView();
    listView.setOnItemClickListener(itemClick);
    initUserMsg();

    if (serviceHeaderView != null) listView.removeHeaderView(serviceHeaderView);
    if (listView.getHeaderViewsCount() == 0) {
      serviceHeaderView =
          new ServiceHeaderView(getActivity(), new ArrayList<SystemPromotionBanner>());
      listView.addHeaderView(serviceHeaderView);
    }

    adapter =
        new SystemPromotionListAdapter(getActivity(), new ArrayList<SystemPromotionDiscovery>());
    listView.setAdapter(adapter);

    requestSystemMessage();
    if (!SharedPreferenceManager.getInstance().getBoolean("isClickSetting", false)
        && SharedPreferenceManager.getInstance().getBoolean("isHaveNewVersion", false)) {
      ivVersionFlag.setVisibility(View.VISIBLE);
    } else {
      ivVersionFlag.setVisibility(View.GONE);
    }
  }
 @Override
 public void onPullEvent(
     PullToRefreshBase<ListView> refreshView, State state, Mode direction) {
   switch (direction) {
     case PULL_FROM_START:
       refreshView
           .getLoadingLayoutProxy()
           .setLastUpdatedLabel(
               SharedPreferenceManager.getInstance().getString(getFragmentTag(), ""));
       break;
     default:
       refreshView.getLoadingLayoutProxy().setLastUpdatedLabel("");
       break;
   }
 }
 @Override
 public void onClick(View v) {
   super.onClick(v);
   switch (v.getId()) {
     case R.id.iv_user_logo:
       startActivity(new Intent(getActivity(), PersonalActivity_.class));
       MobclickAgent.onEvent(getActivity(), "1");
       SysManager.analysis(R.string.c_type_click, R.string.c001);
       break;
     case R.id.rl_setting:
       MobclickAgent.onEvent(getActivity(), "2");
       SysManager.analysis(R.string.c_type_click, R.string.c002);
       startActivity(new Intent(getActivity(), SettingActivity_.class));
       SharedPreferenceManager.getInstance().putBoolean("isClickSetting", true);
       ivVersionFlag.setVisibility(View.GONE);
       break;
     case R.id.iv_scan:
       getActivity().startActivityForResult((new Intent(getActivity(), CaptureActivity.class)), 1);
       break;
   }
 }