예제 #1
0
 @Override
 protected void onActivityResult(int arg0, int arg1, Intent arg2) {
   super.onActivityResult(arg0, arg1, arg2);
   if (arg0 == Constants.RequestResultCode.SURE_COURSES && arg1 == RESULT_OK && null != arg2) {
     if (TutorApplication.getRole() == Constants.General.ROLE_TUTOR) {
       // 老师搜索
       setTutorData(arg2);
     } else {
       setData(arg2);
     }
   }
 }
예제 #2
0
  @Override
  protected void initView() {
    Intent intent = getIntent();
    if (intent != null) {
      isFromTeacher = intent.getBooleanExtra(Constants.General.IS_FROM_TEACHER, false);
    }
    TitleBar bar = getView(R.id.title_bar);
    bar.setTitle(R.string.label_search_conditions);
    bar.initBack(this);
    bar.setRightText(
        R.string.label_search,
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // 保存
            SearchCondition condition = new SearchCondition();
            condition.setVoluntaryTutoring(cbIsVoluntary.isChecked());
            condition.setCertified(cbIsCertified.isChecked());
            condition.setAreaValue(areaValue);
            String areaName = "";
            if (!curCity.equals(getString(R.string.label_please_choose))) {
              areaName = curCity + curCountry;
            } else {
              areaName = "";
            }
            condition.setAreaName(areaName);
            condition.setCourseValues(courseValues);
            String courseName = "";
            if (!courseTextView
                .getText()
                .toString()
                .equals(getString(R.string.label_please_choose_course))) {
              courseName = courseTextView.getText().toString();
            } else {
              courseName = "";
            }
            condition.setCourseName(courseName);
            if (timeslots != null && timeslots.size() > 0) {
              condition.setTimeslot(timeslots.get(0));
            }
            condition.setGender(genderValue);
            String genderName = "";
            if (genderValue == -1) {
              genderName = "";
            } else if (genderValue == Constants.General.MALE) {
              genderName = getString(R.string.label_man);
            } else {
              genderName = getString(R.string.label_woman);
            }
            condition.setGenderName(genderName);
            Intent intent = new Intent();
            intent.putExtra(Constants.IntentExtra.INTENT_EXTRA_SEARCH_CONDITION, condition);
            setResult(Constants.RequestResultCode.SEARCH_CONDITIONS, intent);
            SearchConditionsActivity.this.finish();
          }
        });
    // 选择课程
    courseTextView = getView(R.id.et_course);
    courseTextView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent(SearchConditionsActivity.this, SureCourseActivity.class);
            intent.putExtra(Constants.IntentExtra.INTENT_EXTRA_ROLE, TutorApplication.getRole());
            intent.putExtra(Constants.General.IS_FROM_TO_BY_MY_STUDENT_ACTIVITY, false);
            startActivityForResult(intent, Constants.RequestResultCode.SURE_COURSES);
          }
        });
    // 是否义务补习
    llIsVoluntary = getView(R.id.ll_isVoluntary);
    cbIsVoluntary = getView(R.id.cb_is_voluntary);
    // 是否已经通过认证
    llIsCertified = getView(R.id.ll_is_certified);
    cbIsCertified = getView(R.id.cb_is_certified);
    TextView tvNote = getView(R.id.tv_note);
    if (TutorApplication.getRole() != Constants.General.ROLE_TUTOR) {
      tvNote.setVisibility(View.GONE);
      llIsVoluntary.setVisibility(View.VISIBLE);
      llIsCertified.setVisibility(View.VISIBLE);
    }
    llGender = getView(R.id.ll_gender);
    // tip
    flTipSearch = getView(R.id.fl_tip_search);
    flTipSearch.setOnClickListener(this);
    TextView tvTimeSlot = getView(R.id.tv_timeslot);
    boolean isChinese = TutorApplication.isCH();
    if (isChinese) {
      tvTimeSlot.setBackgroundResource(R.drawable.timeslot_zh);
    } else {
      tvTimeSlot.setBackgroundResource(R.drawable.timeslot);
    }
    // 当切换为这个tab的时候才显示tip
    boolean isNeedShow =
        SharePrefUtil.getBoolean(
            getApplicationContext(), Constants.General.IS_NEED_SHOW_SEARCH_TIP, true);
    if (isNeedShow) {
      flTipSearch.setVisibility(View.VISIBLE);
    } else {
      flTipSearch.setVisibility(View.GONE);
    }
    // etSearch = getView(R.id.fragment_find_student_et);
    // getView(R.id.fragment_find_student_btn).setVisibility(View.GONE);
    weekTextView = getView(R.id.ac_fill_personal_time_tv_week);
    weekTextView.setOnClickListener(this);
    startTimeTextView = getView(R.id.ac_fill_personal_time_tv_start);
    startTimeTextView.setOnClickListener(this);
    endTimeTextView = getView(R.id.ac_fill_personal_time_tv_end);
    endTimeTextView.setOnClickListener(this);
    saveTime = getView(R.id.ac_fill_personal_info_btn_save_timeslot);
    saveTime.setOnClickListener(this);
    // 时间段列表
    listView = getView(R.id.ac_fill_personal_info_timeslot_lv);
    adapter = new TimeSlotAdapter(this, timeslots, true);
    listView.setAdapter(adapter);
    // 性別
    spGender = getView(R.id.sp_gender);
    genders = new ArrayList<String>();
    genders.add(getString(R.string.label_please_choose));
    genders.add(getString(R.string.label_man));
    genders.add(getString(R.string.label_woman));
    spGender.setSelection(0);
    genderAdapter =
        new ArrayAdapter<String>(
            SearchConditionsActivity.this, R.layout.layout_gender_item, genders);
    spGender.setAdapter(genderAdapter);
    spGender.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String currentGender = genderAdapter.getItem(position);
            if (currentGender.equals(getString(R.string.label_please_choose))) {
              genderValue = -1;
            } else if (currentGender.equals(getString(R.string.label_man))) {
              genderValue = Constants.General.MALE;
            } else {
              genderValue = Constants.General.FEMALE;
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
          }
        });
    // 如果是老师则隐藏性别布局
    if (isFromTeacher) {
      llGender.setVisibility(View.GONE);
    } else {
      llGender.setVisibility(View.VISIBLE);
    }
  }