Exemplo n.º 1
0
  public void showDetails(Equipment equipment) {
    equip = equipment;
    View view;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      view = getActivity().findViewById(R.id.detail_frag);
    } else {
      view = getActivity().findViewById(R.id.main_frame);
      Button button = (Button) view.findViewById(R.id.closeButton);
      button.setVisibility(View.VISIBLE);
    }

    TextView textIt_no = (TextView) view.findViewById(R.id.it_no2);
    TextView textType = (TextView) view.findViewById(R.id.type2);
    TextView textBrand = (TextView) view.findViewById(R.id.brand2);
    TextView textModel = (TextView) view.findViewById(R.id.model2);
    TextView textE_id = (TextView) view.findViewById(R.id.e_id);
    TextView textDescription = (TextView) view.findViewById(R.id.description);
    TextView textAquired = (TextView) view.findViewById(R.id.aquired);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeLandscape);
    } else {
      textIt_no.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textType.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textBrand.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textAquired.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textModel.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
      textE_id.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizePortrait);
    }
    textIt_no.setText("Item nr: \t\t\t\t" + equipment.getIt_no());
    textType.setText("Type: \t\t\t\t\t" + equipment.getType());
    textBrand.setText("Brand: \t\t\t\t" + equipment.getBrand());
    textModel.setText("Model: \t\t\t\t" + equipment.getModel());
    textE_id.setText("Equipment ID: \t" + equipment.getE_id());
    textDescription.setText("Description: \t" + equipment.getDescription());
    textAquired.setText("Aquired: \t\t\t" + equipment.getAquired());

    downloadImageThread();

    ImageView image = (ImageView) view.findViewById(R.id.equipment_image);
    image.setImageBitmap(bitmap);
  }
Exemplo n.º 2
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.content_list_item, null);
      }
      TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title);
      TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state);
      TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar);
      Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button);
      Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button);

      LocationInfo info = mInfoList.get(position);
      String titleText = info.title;
      String stateText = "";

      if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "...";

      synchronized (mLoaderMap) {
        if (mLoaderMap.containsKey(info.title)) {
          LoaderState loader = mLoaderMap.get(info.title);
          if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state);
          else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!");
          else stateText = String.format(Locale.ENGLISH, "Failed!");
        }
      }

      if (info.localVersion < 0) titleText += " (?)";
      else {
        if (info.localModified)
          titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion);
        else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion);
      }

      String mapFile = NavigineApp.Settings.getString("map_file", "");
      if (mapFile.equals(info.archiveFile)) {
        titleTextView.setTypeface(null, Typeface.BOLD);
        view.setBackgroundColor(Color.parseColor("#590E0E"));
      } else {
        titleTextView.setTypeface(null, Typeface.NORMAL);
        view.setBackgroundColor(Color.BLACK);
      }

      titleTextView.setText(titleText);
      stateTextView.setText(stateText);

      if (info.localModified) {
        downloadButton.setVisibility(View.GONE);
        uploadButton.setVisibility(View.VISIBLE);
        downTextView.setText("Version is modified. Upload?");
      } else if (info.serverVersion > info.localVersion) {
        downloadButton.setVisibility(View.VISIBLE);
        uploadButton.setVisibility(View.GONE);
        String downText =
            String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion);
        downTextView.setText(downText);
      } else {
        downloadButton.setVisibility(View.INVISIBLE);
        uploadButton.setVisibility(View.GONE);
        downTextView.setText("Version is up to date");
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startDownload(position);
            }
          });

      uploadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startUpload(position);
            }
          });

      return view;
    }