Esempio n. 1
0
  private void populateDiffs(PoiViewHolder holder, ViewGroup parent, PoiUpdateWrapper poiWrapper) {
    holder.getDetailsWrapper().removeAllViews();
    TagChangeViewHolder tagChangeViewHolder;

    if (poiWrapper.isPositionChanged()) {
      View positionChanged = inflater.inflate(R.layout.single_changes_line_layout, parent, false);
      tagChangeViewHolder = new TagChangeViewHolder(positionChanged);
      String positionChangedStr =
          HtmlFontHelper.getBold(context.getString(R.string.position))
              + HtmlFontHelper.addColor(context.getString(R.string.changed), HtmlFontHelper.ORANGE);
      tagChangeViewHolder
          .getNewTag()
          .setText(Html.fromHtml(positionChangedStr), TextView.BufferType.SPANNABLE);
      holder.getDetailsWrapper().addView(positionChanged);
    }

    for (PoiDiffWrapper poiDiffWrapper : poiWrapper.getPoiDiff()) {
      View singleLine = inflater.inflate(R.layout.single_changes_line_layout, parent, false);

      tagChangeViewHolder = new TagChangeViewHolder(singleLine);
      tagChangeViewHolder
          .getNewTag()
          .setText(
              Html.fromHtml(poiDiffWrapper.getColoredDetail(true)), TextView.BufferType.SPANNABLE);
      tagChangeViewHolder
          .getOldTag()
          .setText(
              Html.fromHtml(poiDiffWrapper.getColoredDetail(false)), TextView.BufferType.SPANNABLE);

      holder.getDetailsWrapper().addView(singleLine);
    }
  }
Esempio n. 2
0
 public boolean changedSelected() {
   for (PoiUpdateWrapper poiUpdateWrapper : poisWrapper) {
     if (poiUpdateWrapper.isSelected()) {
       return true;
     }
   }
   return false;
 }
Esempio n. 3
0
 public List<Long> getPoiNodeRefToUpload() {
   List<Long> idsToUpload = new ArrayList<>();
   for (PoiUpdateWrapper poiUpdateWrapper : poisWrapper) {
     if (poiUpdateWrapper.isSelected() && !poiUpdateWrapper.getIsPoi()) {
       idsToUpload.add(poiUpdateWrapper.getId());
     }
   }
   return idsToUpload;
 }
Esempio n. 4
0
  @Override
  public void onBindViewHolder(final PoiViewHolder holder, final int position) {
    final PoiUpdateWrapper poiWrapper = poisWrapper.get(position);

    switch (poiWrapper.getAction()) {
      case CREATE:
        holder.getPoiAction().setText(context.getString(R.string.created));
        break;
      case DELETED:
        holder.getPoiAction().setText(context.getString(R.string.deleted));
        break;
      case UPDATE:
        holder.getPoiAction().setText(context.getString(R.string.updated));
        break;
    }

    final LinearLayout wrapper = holder.getDetailsWrapper();

    if (poiWrapper.getIsPoi()) {
      holder.getPoiType().setText(poiWrapper.getPoiType());
      holder.getPoiName().setText(poiWrapper.getName());
      holder.getExpandBtn().setVisibility(View.VISIBLE);
      populateDiffs(holder, holder.getDetailsWrapper(), poiWrapper);

      View.OnClickListener expendCardnew =
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              poiWrapper.setOpen(!poiWrapper.isOpen());

              ViewAnimation.animate(wrapper, poiWrapper.isOpen());
              if (poiWrapper.isOpen()) {
                holder.getExpandBtn().setImageResource(R.drawable.chevron_up);
              } else {
                holder.getExpandBtn().setImageResource(R.drawable.chevron_down);
              }
            }
          };

      holder.getExpandBtn().setOnClickListener(expendCardnew);
      holder.getHeader().setOnClickListener(expendCardnew);

      if (poiWrapper.isOpen()) {
        wrapper.setVisibility(View.VISIBLE);
        holder.getExpandBtn().setImageResource(R.drawable.chevron_up);
      } else {
        wrapper.setVisibility(View.GONE);
        holder.getExpandBtn().setImageResource(R.drawable.chevron_down);
      }
    } else {
      holder.getExpandBtn().setVisibility(View.GONE);
      wrapper.setVisibility(View.GONE);
      holder.getPoiType().setText(context.getString(R.string.node_ref_title));
      holder.getPoiName().setText("");
    }

    holder
        .getRevertBtn()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                remove(poisWrapper.indexOf(poiWrapper));
              }
            });

    holder.getCheckbox().setChecked(poiWrapper.isSelected());
    holder
        .getCheckbox()
        .setOnCheckedChangeListener(
            new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                poiWrapper.setSelected(isChecked);
              }
            });
  }