Search in sources :

Example 96 with Time

use of org.hl7.elm.r1.Time in project android_packages_apps_Etar by LineageOS.

the class EditEventActivity method getEventInfoFromIntent.

private EventInfo getEventInfoFromIntent(Bundle icicle) {
    EventInfo info = new EventInfo();
    long eventId = -1;
    Intent intent = getIntent();
    Uri data = intent.getData();
    if (data != null) {
        try {
            eventId = Long.parseLong(data.getLastPathSegment());
        } catch (NumberFormatException e) {
            if (DEBUG) {
                Log.d(TAG, "Create new event");
            }
        }
    } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
        eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
    }
    boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false);
    long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
    long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
    if (end != -1) {
        info.endTime = new Time();
        if (allDay) {
            info.endTime.setTimezone(Time.TIMEZONE_UTC);
        }
        info.endTime.set(end);
    }
    if (begin != -1) {
        info.startTime = new Time();
        if (allDay) {
            info.startTime.setTimezone(Time.TIMEZONE_UTC);
        }
        info.startTime.set(begin);
    }
    info.id = eventId;
    info.eventTitle = intent.getStringExtra(Events.TITLE);
    info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1);
    if (allDay) {
        info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY;
    } else {
        info.extraLong = 0;
    }
    return info;
}
Also used : EventInfo(com.android.calendar.CalendarController.EventInfo) Intent(android.content.Intent) Time(com.android.calendarcommon2.Time) Uri(android.net.Uri)

Example 97 with Time

use of org.hl7.elm.r1.Time in project android_packages_apps_Etar by LineageOS.

the class AgendaByDayAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if ((mRowInfo == null) || (position > mRowInfo.size())) {
        // If we have no row info, mAgendaAdapter returns the view.
        return mAgendaAdapter.getView(position, convertView, parent);
    }
    RowInfo row = mRowInfo.get(position);
    if (row.mType == TYPE_DAY) {
        ViewHolder holder = null;
        View agendaDayView = null;
        if ((convertView != null) && (convertView.getTag() != null)) {
            // Listview may get confused and pass in a different type of
            // view since we keep shifting data around. Not a big problem.
            Object tag = convertView.getTag();
            if (tag instanceof ViewHolder) {
                agendaDayView = convertView;
                holder = (ViewHolder) tag;
                holder.julianDay = row.mDay;
            }
        }
        if (holder == null) {
            // Create a new AgendaView with a ViewHolder for fast access to
            // views w/o calling findViewById()
            holder = new ViewHolder();
            agendaDayView = mInflater.inflate(R.layout.agenda_day, parent, false);
            holder.dayView = (TextView) agendaDayView.findViewById(R.id.day);
            holder.dateView = (TextView) agendaDayView.findViewById(R.id.date);
            holder.julianDay = row.mDay;
            holder.grayed = false;
            agendaDayView.setTag(holder);
        }
        // Re-use the member variable "mTime" which is set to the local
        // time zone.
        // It's difficult to find and update all these adapters when the
        // home tz changes so check it here and update if needed.
        String tz = Utils.getTimeZone(mContext, mTZUpdater);
        if (!TextUtils.equals(tz, mTmpTime.getTimezone())) {
            mTimeZone = tz;
            mTmpTime = new Time(tz);
        }
        // Build the text for the day of the week.
        // Should be yesterday/today/tomorrow (if applicable) + day of the week
        final Time date = mTmpTime;
        final long millis = date.setJulianDay(row.mDay);
        int flags = DateUtils.FORMAT_SHOW_WEEKDAY;
        mStringBuilder.setLength(0);
        String dayViewText = Utils.getDayOfWeekString(row.mDay, mTodayJulianDay, millis, mContext);
        // Build text for the date
        // Format should be month day
        mStringBuilder.setLength(0);
        flags = DateUtils.FORMAT_SHOW_DATE;
        String dateViewText = DateUtils.formatDateRange(mContext, mFormatter, millis, millis, flags, mTimeZone).toString();
        if (AgendaWindowAdapter.BASICLOG) {
            dayViewText += " P:" + position;
            dateViewText += " P:" + position;
        }
        holder.dayView.setText(dayViewText);
        holder.dateView.setText(dateViewText);
        // Set the background of the view, it is grayed for day that are in the past and today
        if (row.mDay > mTodayJulianDay) {
            agendaDayView.setBackgroundResource(DynamicTheme.getDrawableId(mContext, "agenda_item_bg_primary"));
            holder.grayed = false;
        } else {
            agendaDayView.setBackgroundResource(DynamicTheme.getDrawableId(mContext, "agenda_item_bg_secondary"));
            holder.grayed = true;
        }
        return agendaDayView;
    } else if (row.mType == TYPE_MEETING) {
        View itemView = mAgendaAdapter.getView(row.mPosition, convertView, parent);
        AgendaAdapter.ViewHolder holder = ((AgendaAdapter.ViewHolder) itemView.getTag());
        TextView title = holder.title;
        // The holder in the view stores information from the cursor, but the cursor has no
        // notion of multi-day event and the start time of each instance of a multi-day event
        // is the same.  RowInfo has the correct info , so take it from there.
        holder.startTimeMilli = row.mEventStartTimeMilli;
        boolean allDay = holder.allDay;
        if (AgendaWindowAdapter.BASICLOG) {
            title.setText(title.getText() + " P:" + position);
        } else {
            title.setText(title.getText());
        }
        // if event in the past or started already, un-bold the title and set the background
        if ((!allDay && row.mEventStartTimeMilli <= System.currentTimeMillis()) || (allDay && row.mDay <= mTodayJulianDay)) {
            itemView.setBackgroundResource(DynamicTheme.getDrawableId(mContext, "agenda_item_bg_secondary"));
            title.setTypeface(Typeface.DEFAULT);
            holder.grayed = true;
        } else {
            itemView.setBackgroundResource(DynamicTheme.getDrawableId(mContext, "agenda_item_bg_primary"));
            title.setTypeface(Typeface.DEFAULT_BOLD);
            holder.grayed = false;
        }
        holder.julianDay = row.mDay;
        return itemView;
    } else {
        // Error
        throw new IllegalStateException("Unknown event type:" + row.mType);
    }
}
Also used : Time(com.android.calendarcommon2.Time) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 98 with Time

use of org.hl7.elm.r1.Time in project android_packages_apps_Etar by LineageOS.

the class AgendaByDayAdapter method calculateDays.

public void calculateDays(DayAdapterInfo dayAdapterInfo) {
    Cursor cursor = dayAdapterInfo.cursor;
    ArrayList<RowInfo> rowInfo = new ArrayList<RowInfo>();
    int prevStartDay = -1;
    Time tempTime = new Time(mTimeZone);
    long now = System.currentTimeMillis();
    tempTime.set(now);
    mTodayJulianDay = Time.getJulianDay(now, tempTime.getGmtOffset());
    LinkedList<MultipleDayInfo> multipleDayList = new LinkedList<MultipleDayInfo>();
    for (int position = 0; cursor.moveToNext(); position++) {
        int startDay = cursor.getInt(AgendaWindowAdapter.INDEX_START_DAY);
        long id = cursor.getLong(AgendaWindowAdapter.INDEX_EVENT_ID);
        long startTime = cursor.getLong(AgendaWindowAdapter.INDEX_BEGIN);
        long endTime = cursor.getLong(AgendaWindowAdapter.INDEX_END);
        long instanceId = cursor.getLong(AgendaWindowAdapter.INDEX_INSTANCE_ID);
        boolean allDay = cursor.getInt(AgendaWindowAdapter.INDEX_ALL_DAY) != 0;
        if (allDay) {
            startTime = Utils.convertAlldayUtcToLocal(tempTime, startTime, mTimeZone);
            endTime = Utils.convertAlldayUtcToLocal(tempTime, endTime, mTimeZone);
        }
        // Skip over the days outside of the adapter's range
        startDay = Math.max(startDay, dayAdapterInfo.start);
        // Make sure event's start time is not before the start of the day
        // (setJulianDay sets the time to 12:00am)
        long adapterStartTime = tempTime.setJulianDay(startDay);
        startTime = Math.max(startTime, adapterStartTime);
        if (startDay != prevStartDay) {
            // Check if we skipped over any empty days
            if (prevStartDay == -1) {
                rowInfo.add(new RowInfo(TYPE_DAY, startDay));
            } else {
                // If there are any multiple-day events that span the empty
                // range of days, then create day headers and events for
                // those multiple-day events.
                boolean dayHeaderAdded = false;
                for (int currentDay = prevStartDay + 1; currentDay <= startDay; currentDay++) {
                    dayHeaderAdded = false;
                    Iterator<MultipleDayInfo> iter = multipleDayList.iterator();
                    while (iter.hasNext()) {
                        MultipleDayInfo info = iter.next();
                        // list.
                        if (info.mEndDay < currentDay) {
                            iter.remove();
                            continue;
                        }
                        // insert a day header.
                        if (!dayHeaderAdded) {
                            rowInfo.add(new RowInfo(TYPE_DAY, currentDay));
                            dayHeaderAdded = true;
                        }
                        long nextMidnight = Utils.getNextMidnight(tempTime, info.mEventStartTimeMilli, mTimeZone);
                        long infoEndTime = (info.mEndDay == currentDay) ? info.mEventEndTimeMilli : nextMidnight;
                        rowInfo.add(new RowInfo(TYPE_MEETING, currentDay, info.mPosition, info.mEventId, info.mEventStartTimeMilli, infoEndTime, info.mInstanceId, info.mAllDay));
                        info.mEventStartTimeMilli = nextMidnight;
                    }
                }
                // add it now.
                if (!dayHeaderAdded) {
                    rowInfo.add(new RowInfo(TYPE_DAY, startDay));
                }
            }
            prevStartDay = startDay;
        }
        // If this event spans multiple days, then add it to the multipleDay
        // list.
        int endDay = cursor.getInt(AgendaWindowAdapter.INDEX_END_DAY);
        // Skip over the days outside of the adapter's range
        endDay = Math.min(endDay, dayAdapterInfo.end);
        if (endDay > startDay) {
            long nextMidnight = Utils.getNextMidnight(tempTime, startTime, mTimeZone);
            multipleDayList.add(new MultipleDayInfo(position, endDay, id, nextMidnight, endTime, instanceId, allDay));
            // Add in the event for this cursor position - since it is the start of a multi-day
            // event, the end time is midnight
            rowInfo.add(new RowInfo(TYPE_MEETING, startDay, position, id, startTime, nextMidnight, instanceId, allDay));
        } else {
            // Add in the event for this cursor position
            rowInfo.add(new RowInfo(TYPE_MEETING, startDay, position, id, startTime, endTime, instanceId, allDay));
        }
    }
    // events left.  So create day headers and events for those.
    if (prevStartDay > 0) {
        for (int currentDay = prevStartDay + 1; currentDay <= dayAdapterInfo.end; currentDay++) {
            boolean dayHeaderAdded = false;
            Iterator<MultipleDayInfo> iter = multipleDayList.iterator();
            while (iter.hasNext()) {
                MultipleDayInfo info = iter.next();
                // list.
                if (info.mEndDay < currentDay) {
                    iter.remove();
                    continue;
                }
                // insert a day header.
                if (!dayHeaderAdded) {
                    rowInfo.add(new RowInfo(TYPE_DAY, currentDay));
                    dayHeaderAdded = true;
                }
                long nextMidnight = Utils.getNextMidnight(tempTime, info.mEventStartTimeMilli, mTimeZone);
                long infoEndTime = (info.mEndDay == currentDay) ? info.mEventEndTimeMilli : nextMidnight;
                rowInfo.add(new RowInfo(TYPE_MEETING, currentDay, info.mPosition, info.mEventId, info.mEventStartTimeMilli, infoEndTime, info.mInstanceId, info.mAllDay));
                info.mEventStartTimeMilli = nextMidnight;
            }
        }
    }
    mRowInfo = rowInfo;
    if (mTodayJulianDay >= dayAdapterInfo.start && mTodayJulianDay <= dayAdapterInfo.end) {
        insertTodayRowIfNeeded();
    }
}
Also used : ArrayList(java.util.ArrayList) Time(com.android.calendarcommon2.Time) Cursor(android.database.Cursor) LinkedList(java.util.LinkedList)

Example 99 with Time

use of org.hl7.elm.r1.Time in project android_packages_apps_Etar by LineageOS.

the class AgendaFragment method onScroll.

// Gets the time of the first visible view. If it is a new time, send a message to update
// the time on the ActionBar
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    int julianDay = mAgendaListView.getJulianDayFromPosition(firstVisibleItem - mAgendaListView.getHeaderViewsCount());
    // On error - leave the old view
    if (julianDay == 0) {
        return;
    }
    // If the day changed, update the ActionBar
    if (mJulianDayOnTop != julianDay) {
        mJulianDayOnTop = julianDay;
        Time t = new Time(mTimeZone);
        t.setJulianDay(mJulianDayOnTop);
        mController.setTime(t.toMillis());
        // so instead post a runnable that will run when the layout is done
        if (!mIsTabletConfig) {
            view.post(new Runnable() {

                @Override
                public void run() {
                    Time t = new Time(mTimeZone);
                    t.setJulianDay(mJulianDayOnTop);
                    mController.sendEvent(this, EventType.UPDATE_TITLE, t, t, null, -1, ViewType.CURRENT, 0, null, null);
                }
            });
        }
    }
}
Also used : Time(com.android.calendarcommon2.Time)

Example 100 with Time

use of org.hl7.elm.r1.Time in project android_packages_apps_Etar by LineageOS.

the class SearchActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Time t = null;
    final int itemId = item.getItemId();
    if (itemId == R.id.action_today) {
        t = new Time();
        t.set(System.currentTimeMillis());
        mController.sendEvent(this, EventType.GO_TO, t, null, -1, ViewType.CURRENT);
        return true;
    } else if (itemId == R.id.action_search) {
        return false;
    } else if (itemId == R.id.action_settings) {
        mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0);
        return true;
    } else if (itemId == android.R.id.home) {
        Utils.returnToCalendarHome(this);
        return true;
    } else {
        return false;
    }
}
Also used : Time(com.android.calendarcommon2.Time)

Aggregations

Time (com.android.calendarcommon2.Time)178 ArrayList (java.util.ArrayList)64 List (java.util.List)40 Timer (com.codahale.metrics.Timer)27 Trace (com.newrelic.api.agent.Trace)23 Date (java.util.Date)23 Test (org.junit.jupiter.api.Test)23 IOException (java.io.IOException)21 FHIRException (org.hl7.fhir.exceptions.FHIRException)21 Paint (android.graphics.Paint)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)19 Resource (org.hl7.fhir.r4.model.Resource)19 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)18 Condition (org.hl7.fhir.r4.model.Condition)16 Optional (java.util.Optional)15 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)15 Bundle (org.hl7.fhir.r4.model.Bundle)15 Coding (org.hl7.fhir.r4.model.Coding)15 Reference (org.hl7.fhir.r4.model.Reference)15 HashMap (java.util.HashMap)14