示例#1
0
  private void doGetBannerUsers() {
    lastArea = SalonTools.getArea(mActivity);
    mActivity.showWaitDialog();
    accountService.getBannerUsers(
        SalonTools.getArea(mActivity),
        new AsyncResponseCompletedHandler<String>() {

          @Override
          public String doCompleted(ResponseBean<?> response, ChCareWepApiServiceType servieType) {

            salons.clear();
            barbers.clear();

            if (response.getState() >= 0 && response.getData() != null) {
              ArrayList<SalonUser> users = (ArrayList<SalonUser>) response.getData();
              for (SalonUser user : users) {
                if (user.getRole() == Role.SALON) {
                  salons.add(user);
                } else if (user.getRole() == Role.BARBER) {
                  barbers.add(user);
                }
              }
            }

            initSalons();
            initBarbers();
            doGetBanners();
            return null;
          }
        });
  }
示例#2
0
  public void initView(BaseActivity activity, CHApplication app, Handler handler) {
    mActivity = activity;
    mainHandler = handler;

    findViewById(R.id.title_search).setVisibility(View.GONE);
    //		mSearch.setOnClickListener(this);
    //		mBtnSearch.setOnClickListener(this);
    salon1.setOnClickListener(this);
    salon2.setOnClickListener(this);
    barber1.setOnClickListener(this);
    barber2.setOnClickListener(this);
    barber3.setOnClickListener(this);
    mArea.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent(mContext, DistrictActivity.class);
            intent.putExtra("address", SalonTools.getDistrict(mActivity)); // 不传参数也可以,就不会有默认选中某个值
            mActivity.startActivityForResult(intent, MainActivity.SELECT_DISTRICT);
          }
        });

    findViewById(R.id.rl_salon)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                try {
                  mainHandler.sendEmptyMessage(R.string.action_show_salon_view);
                } catch (Exception e) {
                }
              }
            });

    findViewById(R.id.rl_barber)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                try {
                  mainHandler.sendEmptyMessage(R.string.action_show_barber_view);
                } catch (Exception e) {
                }
              }
            });

    mArea.setText(SalonTools.getArea(mActivity));
    imageFetcher = SalonTools.getImageFetcher(mContext, app, false, 0);
    imageFetcherRound = SalonTools.getImageFetcher(mContext, app, true, 0);

    backcolor = getResources().getColor(R.color.activity_back);

    doGetBannerUsers();
  }
示例#3
0
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == Activity.RESULT_OK) {
     if (requestCode == MainActivity.SELECT_DISTRICT) {
       SalonTools.saveDistrict(mActivity, data.getStringExtra("address"));
       mArea.setText(SalonTools.getArea(mActivity));
       if (!lastArea.equals(SalonTools.getArea(mActivity))) {
         doGetBannerUsers();
       }
     }
   }
 }
示例#4
0
  private void initBarbers() {
    // 设置没有barber时的文字
    //		if(barbers.size() == 0){
    //			none_barber.setVisibility(VISIBLE);
    //		}else{
    //			none_barber.setVisibility(GONE);
    //		}

    if (barbers.size() == 0) {
      barber1.setImageDrawable(null);
      barber2.setImageDrawable(null);
      barber3.setImageDrawable(null);
      baber1_txt.setVisibility(INVISIBLE);
      baber2_txt.setVisibility(INVISIBLE);
      baber3_txt.setVisibility(INVISIBLE);
    } else if (barbers.size() == 1) {
      try {
        imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1);
        baber1_txt.setVisibility(VISIBLE);
        baber1_txt.setText(SalonTools.getName(barbers.get(0)));
        barber2.setImageDrawable(null);
        barber3.setImageDrawable(null);
        baber2_txt.setVisibility(INVISIBLE);
        baber3_txt.setVisibility(INVISIBLE);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (barbers.size() == 2) {
      try {
        imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1);
        baber1_txt.setVisibility(VISIBLE);
        baber1_txt.setText(SalonTools.getName(barbers.get(0)));
        imageFetcher.loadFormCache(barbers.get(1).getPhoto(), barber2);
        baber2_txt.setVisibility(VISIBLE);
        baber2_txt.setText(SalonTools.getName(barbers.get(1)));
        barber3.setImageDrawable(null);
        baber3_txt.setVisibility(INVISIBLE);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (barbers.size() == 3) {
      try {
        imageFetcher.loadFormCache(barbers.get(0).getPhoto(), barber1);
        baber1_txt.setVisibility(VISIBLE);
        baber1_txt.setText(SalonTools.getName(barbers.get(0)));
        imageFetcher.loadFormCache(barbers.get(1).getPhoto(), barber2);
        baber2_txt.setVisibility(VISIBLE);
        baber2_txt.setText(SalonTools.getName(barbers.get(1)));
        imageFetcher.loadFormCache(barbers.get(2).getPhoto(), barber3);
        baber3_txt.setVisibility(VISIBLE);
        baber3_txt.setText(SalonTools.getName(barbers.get(2)));
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
示例#5
0
 public void refresh() {
   mArea.setText(SalonTools.getArea(mActivity));
   if (!lastArea.endsWith(SalonTools.getArea(mActivity))) {
     doGetBannerUsers();
   }
 }