示例#1
0
 public int compare(Item item1, Item item2) {
   if ((item1.getDate() != null) && (item2.getDate() != null)) {
     return item1.getDate().compareTo(item2.getDate());
   } else {
     return -1;
   }
 }
  private void manageDayView(TextView dayTV, ImageView dayIV, Item item) {
    dayTV.setText(item.getDay());

    switch (item.getType()) { // apply styles
      case DEFAULT:
        {
          dayTV.setTextColor(getResources().getColor(R.color.black));
          dayIV.setImageResource(R.drawable.calendarcell);
          dayIV.setTag(item);
          dayIV.setOnClickListener(this);
        }
        break;

      case LEAVEDAY:
        {
          ItemLeaveDay itemLeaveDay = (ItemLeaveDay) item;
          dayTV.setTextColor(getResources().getColor(R.color.black));
          if (itemLeaveDay.getDuration() == Leave.Duration.AM)
            dayIV.setImageResource(R.drawable.calendarcell_sel_pm);
          else if (itemLeaveDay.getDuration() == Leave.Duration.PM)
            dayIV.setImageResource(R.drawable.calendarcell_sel_am);
          else dayIV.setImageResource(R.drawable.calendarcell_sel);
          dayIV.setTag(itemLeaveDay);
          dayIV.setOnClickListener(
              (itemLeaveDay.getDuration() == Leave.Duration.ONEDAY) ? null : this);
        }
        break;

      case NONWORKINGDAY:
        {
          dayTV.setTextColor(getResources().getColor(android.R.color.tertiary_text_light));
          dayIV.setImageResource(R.drawable.calendarcell_na);
          dayIV.setOnClickListener(null);
        }
        break;
    }

    // let the selected items be colored blue on reuse
    if (leaveEndCalendar != null && tempEndLeaveEndCalendar != null) {
      if (item.getType() == ITEMTYPE.DEFAULT
          && item.getDate().compareTo(leaveEndCalendar.getTime()) >= 0
          && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) <= 0) {
        dayIV.setImageResource(R.drawable.calendarcell_leave);
      } else if (item.getType() == ITEMTYPE.LEAVEDAY
          && item.getDate().compareTo(tempEndLeaveEndCalendar.getTime()) == 0) {
        if (Math.abs(leaveDays.get(item.getStringedDate()) - 0.1) < 0.00001)
          dayIV.setImageResource(R.drawable.calendarcell_leave_am_whole);
        else dayIV.setImageResource(R.drawable.calendarcell_leave_pm_whole);
      }
    }
  }
示例#3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
      LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(id, null);
    }

    /* create a new view of my layout and inflate it in the row */
    // convertView = ( RelativeLayout ) inflater.inflate( resource, null );

    final Item o = items.get(position);
    if (o != null) {
      TextView t1 = (TextView) v.findViewById(R.id.TextView01);
      TextView t2 = (TextView) v.findViewById(R.id.TextView02);
      TextView t3 = (TextView) v.findViewById(R.id.TextViewDate);
      /* Take the ImageView from layout and set the city's image */
      ImageView imageCity = (ImageView) v.findViewById(R.id.fd_Icon1);
      String uri = "drawable/" + o.getImage();
      int imageResource = c.getResources().getIdentifier(uri, null, c.getPackageName());
      Drawable image = c.getResources().getDrawable(imageResource);
      imageCity.setImageDrawable(image);

      if (t1 != null) t1.setText(o.getName());
      if (t2 != null) t2.setText(o.getData());
      if (t3 != null) t3.setText(o.getDate());
    }
    return v;
  }
示例#4
0
 @Override
 public void onViewStateRestored(Bundle savedInstanceState) {
   super.onViewStateRestored(savedInstanceState);
   if (savedInstanceState != null && savedInstanceState.containsKey("itemDate")) {
     DateTime itemDate = (DateTime) savedInstanceState.getSerializable("itemDate");
     mItem.setDate(itemDate);
     mDate.setText(mItem.getLocalizedDate());
   }
   Log.d(TAG, "onViewStateRestored : " + mItem.getDate("YYYY-MM-DD"));
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    Holder holder;

    if (view == null) {
      holder = new Holder();
      view =
          linearNavFragmentActivity
              .getLayoutInflater()
              .inflate(R.layout.node_listviewcalendar, null);

      holder.bgSun = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_0);
      holder.bgMon = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_1);
      holder.bgTue = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_2);
      holder.bgWed = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_3);
      holder.bgThu = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_4);
      holder.bgFri = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_5);
      holder.bgSat = (ImageView) view.findViewById(R.id.iviews_listviewcalendar_nodes_6);
      holder.daySun = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_0);
      holder.dayMon = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_1);
      holder.dayTue = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_2);
      holder.dayWed = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_3);
      holder.dayThu = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_4);
      holder.dayFri = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_5);
      holder.daySat = (TextView) view.findViewById(R.id.tviews_listviewcalendar_nodes_6);

      view.setTag(holder);
    }

    holder = (Holder) view.getTag();

    Item sundayItem = perWeekItems.get(position).get(Calendar.SUNDAY);
    String weekStartDate = monthYearFormat.format(sundayItem.getDate());
    if (!tvMonthYearHeader.getText().equals(weekStartDate))
      tvMonthYearHeader.setText(weekStartDate);
    manageDayView(holder.daySun, holder.bgSun, sundayItem);
    manageDayView(holder.dayMon, holder.bgMon, perWeekItems.get(position).get(Calendar.MONDAY));
    manageDayView(holder.dayTue, holder.bgTue, perWeekItems.get(position).get(Calendar.TUESDAY));
    manageDayView(holder.dayWed, holder.bgWed, perWeekItems.get(position).get(Calendar.WEDNESDAY));
    manageDayView(holder.dayThu, holder.bgThu, perWeekItems.get(position).get(Calendar.THURSDAY));
    manageDayView(holder.dayFri, holder.bgFri, perWeekItems.get(position).get(Calendar.FRIDAY));
    manageDayView(holder.daySat, holder.bgSat, perWeekItems.get(position).get(Calendar.SATURDAY));

    return view;
  }
示例#6
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putSerializable("itemDate", mItem.getDate());
 }
示例#7
0
  /**
   * All items for given list of uploads. Respect startItem and maxItem
   *
   * @param uploads
   * @return
   */
  private List<Item> itemsByUploads(List<DataUpload> uploads) {

    if (resultItemList != null) return resultItemList;
    resultItemList = new ArrayList<Item>();
    long currentStart = 0l;
    int itemsRead = 0;
    boolean transform = false;
    for (DataUpload du : uploads) {
      transform = false;
      if (du.getItemXpath() != null) {
        if (DB.getTransformationDAO().findByUpload(du).size() > 0) {
          if (DB.getTransformationDAO().findByUpload(du).get(0).getStatusCode() == 0)
            transform = true;
        }
        if (currentStart + du.getItemXpath().getCount() < startItem) {
          currentStart += du.getItemXpath().getCount();
          continue;
        }
        List<XMLNode> l =
            du.getItemXpath().getNodes(startItem + itemsRead - currentStart, maxItems);
        for (XMLNode x : l) {
          log.debug("get tree .. ");
          XMLNode tree = DB.getXMLNodeDAO().getDOMTree(x);
          boolean trunc = false;
          if (tree.getSize() > 20000) {
            trunc = true;
          }

          log.debug(" . done");
          if (itemsRead < maxItems) {
            List<? extends XMLNode> labelList = tree.getChildrenByXpath(du.getItemLabelXpath());
            if (labelList.size() != 1) log.warn("Label not unique");

            XMLNode label;
            Item i = new Item();
            if (labelList.size() == 1) {
              label = labelList.get(0);
              i.name = label.getContent();
            } else if (labelList.size() == 0) {
              i.name = "<no label>";
            } else {
              i.name = "<" + labelList.size() + " labels>";
            }
            i.truncated = trunc;
            i.uploadId = du.getDbID();
            i.direct = du.isDirect();
            i.nodeId = x.getNodeId();
            i.transformed = transform;
            if (du.getUploadDate() == null) i.itemdate = "";
            else i.itemdate = new SimpleDateFormat("dd/MM/yyyy HH:mm").format(du.getUploadDate());
            i.importname = du.getOriginalFilename();
            /*if( du.getOriginalFilename().length()<15 )
            	i.importname=du.getOriginalFilename();
            else
            	i.importname=".."+du.getOriginalFilename()
            	.substring(du.getOriginalFilename().length()-12);
            	 */
            resultItemList.add(i);
            itemsRead += 1;
            log.debug("adding item:" + itemsRead + " with date:" + i.getDate());
          }
        }
        if (itemsRead == maxItems) break;
        currentStart += du.getItemXpath().getCount();
      }
    }
    endItem = startItem + resultItemList.size();
    return resultItemList;
  }