// TODO: Need to handle rotation
 private void initWorkerPager() {
   mWorkerPagerAdapter = new WorkerPagerAdapter(mFragmentManager);
   createWorkerPages(WorkingData.getInstance(mContext).getFactories().get(0).workers);
   initWorkerPagerIndicator();
   mWorkerPagerAdapter.setWorkerPages(mWorkerPageList);
   mWorkerPager.setAdapter(mWorkerPagerAdapter);
   mWorkerPager.setOnPageChangeListener(this);
 }
  private void setFactorySpinnerDatas() {
    mFactorySpinnerData.clear();
    for (Factory factory : WorkingData.getInstance(mContext).getFactories()) {
      mFactorySpinnerData.add(factory);
    }

    mFactorySpinnerAdapter.notifyDataSetChanged();
  }
  private void setVendorSpinnerDatas() {
    mVendorSpinnerData.clear();
    mVendorSpinnerData.add(
        new Vendor("", getResources().getString(R.string.case_spinner_all_vendors)));
    mVendorSpinnerData.addAll(WorkingData.getInstance(mContext).getVendors());

    mVendorSpinnerAdapter.notifyDataSetChanged();
  }
  @Override
  public void execute() {
    HashMap<String, String> headers = new HashMap<>();
    headers.put("x-user-id", WorkingData.getUserId());
    headers.put("x-auth-token", WorkingData.getAuthToken());

    HashMap<String, String> bodies = new HashMap<>();
    bodies.put("ted", mTaskWarningId);
    bodies.put("msg", mComment);

    PostRequestStrategy uploadingCommentStrategy =
        new PostRequestStrategy(
            LoadingDataUtils.WorkingDataUrl.EndPoints.COMMENT_TEXT_ACTIVITY_TO_TASK_WARNING,
            headers,
            bodies);
    mPostRequestAsyncTask = new PostRequestAsyncTask(mContext, uploadingCommentStrategy, this);
    mPostRequestAsyncTask.execute();
  }
  private void initCaseView() {
    mCaseAdapter = new CaseAdapter(mContext, WorkingData.getInstance(mContext).getCases().get(0));
    mCaseOnTouchListener = new CaseOnTouchListener(mContext, mCaseView);
    mCaseLayoutManager = new LinearLayoutManager(mContext);

    mCaseView.setLayoutManager(mCaseLayoutManager);
    mCaseView.addItemDecoration(new CaseCardDecoration(mContext));
    mCaseView.setOnTouchListener(mCaseOnTouchListener);
    mCaseView.setAdapter(mCaseAdapter);
  }
  private void showViews() {
    initVendorSpinner();
    initCaseSpinner();
    initFactorySpinner();

    setVendorSpinnerDatas();
    setCaseSpinnerDatas(WorkingData.getInstance(mContext).getCases());
    setFactorySpinnerDatas();

    initCaseView();
    initWorkerPager();

    Utils.replaceProgressBarWhenLoadingFinished(mContext, mMainView, mProgressBar);
  }
Exemple #7
0
  public static String getWorkerWipEquipmentName(Context context, Worker worker) {
    String result = context.getString(R.string.no_equipment);

    if (worker.hasWipTask()) {
      Equipment wipEquipment =
          WorkingData.getInstance(context).getEquipmentById(worker.getWipTask().equipmentId);

      if (wipEquipment != null) {
        result = wipEquipment.name;
      }
    }

    return result;
  }
  @Override
  public void updateData() {
    int vendorSpinnerSelectedPos = mVendorSpinner.getSelectedItemPosition();

    setVendorSpinnerDatas();
    setCaseSpinnerDatas(
        vendorSpinnerSelectedPos == Spinner.INVALID_POSITION || vendorSpinnerSelectedPos == 0
            ? WorkingData.getInstance(mContext).getCases()
            : mVendorSpinnerData.get(mVendorSpinner.getSelectedItemPosition()).getCases());
    setFactorySpinnerDatas();

    mCaseAdapter.notifyDataSetChanged();
    for (WorkerFragment workerFragment : mWorkerPageList) {
      workerFragment.notifyDataSetChanged();
    }
  }
 @Override
 public void onStop() {
   super.onStop();
   WorkingData.getInstance(mContext).removeDataObserver(this);
 }
 @Override
 public void onStart() {
   super.onStart();
   WorkingData.getInstance(mContext).registerDataObserver(this);
   updateData();
 }