예제 #1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Intent intent = getActivity().getIntent();
    mStatType = intent.getIntExtra(EXTRA_STAT_TYPE, -1);
    if (mStatType == -1) {
      mStatType = Preferences.getStatType();
    }

    StatController controller;
    switch (mStatType) {
      case STAT_TYPE_DELIVER:
        controller = new DeliverLogisticsStatController(this);
        break;
      case STAT_TYPE_MOTOR:
        controller = new MotorLogisticsStatController(this);
        break;
      case STAT_TYPE_GANGER:
        controller = new GangerLogisticsStatController(this);
        break;
      default:
        throw new IllegalArgumentException("unknown type " + mStatType);
    }

    mModel = controller.getDeliverStatModel();
    mAdapter = controller.getAdapter();

    View view = inflater.inflate(controller.getResId(), container, false);
    ListView listView = (ListView) view.findViewById(R.id.deliver_stat_list);
    listView.setAdapter(mAdapter);

    return view;
  }
예제 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_deliver_stat_option) {
      Intent intent = new Intent(getActivity(), DeliverStatOptionActivity.class);
      intent.putExtra(EXTRA_STAT_INTERVAL, mModel.getInterval());
      startActivityForResult(intent, REQUEST_CODE_SET_INTERVAL);

      Preferences.setStatType(mStatType);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }