id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,300 | goldmansachs/reladomo | reladomo/src/main/java/com/gs/fw/common/mithra/finder/DeepFetchNode.java | DeepFetchNode.getSimplifiedJoinOp | public Operation getSimplifiedJoinOp(Mapper mapper, List parentList)
{
int maxSimplifiedIn = DeepRelationshipUtility.MAX_SIMPLIFIED_IN;
boolean differentPersisterThanParent = differentPersisterIdThanParent(mapper);
if (differentPersisterThanParent)
{
maxSimplifiedIn = Integer.MAX_VALUE;
}
return mapper.getSimplifiedJoinOp(parentList, maxSimplifiedIn, this, differentPersisterThanParent);
} | java | public Operation getSimplifiedJoinOp(Mapper mapper, List parentList)
{
int maxSimplifiedIn = DeepRelationshipUtility.MAX_SIMPLIFIED_IN;
boolean differentPersisterThanParent = differentPersisterIdThanParent(mapper);
if (differentPersisterThanParent)
{
maxSimplifiedIn = Integer.MAX_VALUE;
}
return mapper.getSimplifiedJoinOp(parentList, maxSimplifiedIn, this, differentPersisterThanParent);
} | [
"public",
"Operation",
"getSimplifiedJoinOp",
"(",
"Mapper",
"mapper",
",",
"List",
"parentList",
")",
"{",
"int",
"maxSimplifiedIn",
"=",
"DeepRelationshipUtility",
".",
"MAX_SIMPLIFIED_IN",
";",
"boolean",
"differentPersisterThanParent",
"=",
"differentPersisterIdThanPare... | mapper is not necessarily this.relatedFinder.mapper. chained mapper | [
"mapper",
"is",
"not",
"necessarily",
"this",
".",
"relatedFinder",
".",
"mapper",
".",
"chained",
"mapper"
] | e9a069452eece7a6ef9551caf81a69d3d9a3d990 | https://github.com/goldmansachs/reladomo/blob/e9a069452eece7a6ef9551caf81a69d3d9a3d990/reladomo/src/main/java/com/gs/fw/common/mithra/finder/DeepFetchNode.java#L885-L894 |
31,301 | goldmansachs/reladomo | reladomo/src/main/java/com/gs/fw/common/mithra/superclassimpl/MithraTransactionalObjectImpl.java | MithraTransactionalObjectImpl.zSetData | protected void zSetData(MithraDataObject data)
{
this.currentData = data;
this.persistenceState = PersistenceState.PERSISTED;
MithraTransaction currentTransaction = MithraManagerProvider.getMithraManager().getCurrentTransaction();
if (currentTransaction != null && zGetPortal().getTxParticipationMode(currentTransaction).mustParticipateInTxOnRead())
{
this.transactionalState = currentTransaction.getReadLockedTransactionalState(null, PersistenceState.PERSISTED);
}
} | java | protected void zSetData(MithraDataObject data)
{
this.currentData = data;
this.persistenceState = PersistenceState.PERSISTED;
MithraTransaction currentTransaction = MithraManagerProvider.getMithraManager().getCurrentTransaction();
if (currentTransaction != null && zGetPortal().getTxParticipationMode(currentTransaction).mustParticipateInTxOnRead())
{
this.transactionalState = currentTransaction.getReadLockedTransactionalState(null, PersistenceState.PERSISTED);
}
} | [
"protected",
"void",
"zSetData",
"(",
"MithraDataObject",
"data",
")",
"{",
"this",
".",
"currentData",
"=",
"data",
";",
"this",
".",
"persistenceState",
"=",
"PersistenceState",
".",
"PERSISTED",
";",
"MithraTransaction",
"currentTransaction",
"=",
"MithraManagerP... | also called after constructing a new object for remote insert, non-persistent copy and detached copy | [
"also",
"called",
"after",
"constructing",
"a",
"new",
"object",
"for",
"remote",
"insert",
"non",
"-",
"persistent",
"copy",
"and",
"detached",
"copy"
] | e9a069452eece7a6ef9551caf81a69d3d9a3d990 | https://github.com/goldmansachs/reladomo/blob/e9a069452eece7a6ef9551caf81a69d3d9a3d990/reladomo/src/main/java/com/gs/fw/common/mithra/superclassimpl/MithraTransactionalObjectImpl.java#L1593-L1603 |
31,302 | goldmansachs/reladomo | reladomo/src/main/java/com/gs/fw/common/mithra/util/BigDecimalUtil.java | BigDecimalUtil.calculateQuotientScale | public static int calculateQuotientScale(int precision1, int scale1,int precision2, int scale2)
{
return Math.max(scale1 + precision2 -scale2 + 1, 6);
} | java | public static int calculateQuotientScale(int precision1, int scale1,int precision2, int scale2)
{
return Math.max(scale1 + precision2 -scale2 + 1, 6);
} | [
"public",
"static",
"int",
"calculateQuotientScale",
"(",
"int",
"precision1",
",",
"int",
"scale1",
",",
"int",
"precision2",
",",
"int",
"scale2",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"scale1",
"+",
"precision2",
"-",
"scale2",
"+",
"1",
",",
"... | From the Sybase Transact-SQL user guide | [
"From",
"the",
"Sybase",
"Transact",
"-",
"SQL",
"user",
"guide"
] | e9a069452eece7a6ef9551caf81a69d3d9a3d990 | https://github.com/goldmansachs/reladomo/blob/e9a069452eece7a6ef9551caf81a69d3d9a3d990/reladomo/src/main/java/com/gs/fw/common/mithra/util/BigDecimalUtil.java#L124-L127 |
31,303 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.onSizeChanged | @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mAreDimensionsInvalid = true;
} | java | @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mAreDimensionsInvalid = true;
} | [
"@",
"Override",
"protected",
"void",
"onSizeChanged",
"(",
"int",
"w",
",",
"int",
"h",
",",
"int",
"oldw",
",",
"int",
"oldh",
")",
"{",
"super",
".",
"onSizeChanged",
"(",
"w",
",",
"h",
",",
"oldw",
",",
"oldh",
")",
";",
"mAreDimensionsInvalid",
... | fix rotation changes | [
"fix",
"rotation",
"changes"
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L469-L473 |
31,304 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.getTimeFromPoint | private Calendar getTimeFromPoint(float x, float y){
int leftDaysWithGaps = (int) -(Math.ceil(mCurrentOrigin.x / (mWidthPerDay + mColumnGap)));
float startPixel = mCurrentOrigin.x + (mWidthPerDay + mColumnGap) * leftDaysWithGaps +
mHeaderColumnWidth;
for (int dayNumber = leftDaysWithGaps + 1;
dayNumber <= leftDaysWithGaps + mNumberOfVisibleDays + 1;
dayNumber++) {
float start = (startPixel < mHeaderColumnWidth ? mHeaderColumnWidth : startPixel);
if (mWidthPerDay + startPixel - start > 0 && x > start && x < startPixel + mWidthPerDay){
Calendar day = today();
day.add(Calendar.DATE, dayNumber - 1);
float pixelsFromZero = y - mCurrentOrigin.y - mHeaderHeight
- mHeaderRowPadding * 2 - mTimeTextHeight/2 - mHeaderMarginBottom;
int hour = (int)(pixelsFromZero / mHourHeight);
int minute = (int) (60 * (pixelsFromZero - hour * mHourHeight) / mHourHeight);
day.add(Calendar.HOUR, hour);
day.set(Calendar.MINUTE, minute);
return day;
}
startPixel += mWidthPerDay + mColumnGap;
}
return null;
} | java | private Calendar getTimeFromPoint(float x, float y){
int leftDaysWithGaps = (int) -(Math.ceil(mCurrentOrigin.x / (mWidthPerDay + mColumnGap)));
float startPixel = mCurrentOrigin.x + (mWidthPerDay + mColumnGap) * leftDaysWithGaps +
mHeaderColumnWidth;
for (int dayNumber = leftDaysWithGaps + 1;
dayNumber <= leftDaysWithGaps + mNumberOfVisibleDays + 1;
dayNumber++) {
float start = (startPixel < mHeaderColumnWidth ? mHeaderColumnWidth : startPixel);
if (mWidthPerDay + startPixel - start > 0 && x > start && x < startPixel + mWidthPerDay){
Calendar day = today();
day.add(Calendar.DATE, dayNumber - 1);
float pixelsFromZero = y - mCurrentOrigin.y - mHeaderHeight
- mHeaderRowPadding * 2 - mTimeTextHeight/2 - mHeaderMarginBottom;
int hour = (int)(pixelsFromZero / mHourHeight);
int minute = (int) (60 * (pixelsFromZero - hour * mHourHeight) / mHourHeight);
day.add(Calendar.HOUR, hour);
day.set(Calendar.MINUTE, minute);
return day;
}
startPixel += mWidthPerDay + mColumnGap;
}
return null;
} | [
"private",
"Calendar",
"getTimeFromPoint",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"int",
"leftDaysWithGaps",
"=",
"(",
"int",
")",
"-",
"(",
"Math",
".",
"ceil",
"(",
"mCurrentOrigin",
".",
"x",
"/",
"(",
"mWidthPerDay",
"+",
"mColumnGap",
")",
... | Get the time and date where the user clicked on.
@param x The x position of the touch event.
@param y The y position of the touch event.
@return The time and date at the clicked position. | [
"Get",
"the",
"time",
"and",
"date",
"where",
"the",
"user",
"clicked",
"on",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L750-L772 |
31,305 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.drawEvents | private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
if (mEventRects != null && mEventRects.size() > 0) {
for (int i = 0; i < mEventRects.size(); i++) {
if (isSameDay(mEventRects.get(i).event.getStartTime(), date) && !mEventRects.get(i).event.isAllDay()){
// Calculate top.
float top = mHourHeight * 24 * mEventRects.get(i).top / 1440 + mCurrentOrigin.y + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight/2 + mEventMarginVertical;
// Calculate bottom.
float bottom = mEventRects.get(i).bottom;
bottom = mHourHeight * 24 * bottom / 1440 + mCurrentOrigin.y + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight/2 - mEventMarginVertical;
// Calculate left and right.
float left = startFromPixel + mEventRects.get(i).left * mWidthPerDay;
if (left < startFromPixel)
left += mOverlappingEventGap;
float right = left + mEventRects.get(i).width * mWidthPerDay;
if (right < startFromPixel + mWidthPerDay)
right -= mOverlappingEventGap;
// Draw the event and the event name on top of it.
if (left < right &&
left < getWidth() &&
top < getHeight() &&
right > mHeaderColumnWidth &&
bottom > mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight / 2 + mHeaderMarginBottom
) {
mEventRects.get(i).rectF = new RectF(left, top, right, bottom);
mEventBackgroundPaint.setColor(mEventRects.get(i).event.getColor() == 0 ? mDefaultEventColor : mEventRects.get(i).event.getColor());
canvas.drawRoundRect(mEventRects.get(i).rectF, mEventCornerRadius, mEventCornerRadius, mEventBackgroundPaint);
drawEventTitle(mEventRects.get(i).event, mEventRects.get(i).rectF, canvas, top, left);
}
else
mEventRects.get(i).rectF = null;
}
}
}
} | java | private void drawEvents(Calendar date, float startFromPixel, Canvas canvas) {
if (mEventRects != null && mEventRects.size() > 0) {
for (int i = 0; i < mEventRects.size(); i++) {
if (isSameDay(mEventRects.get(i).event.getStartTime(), date) && !mEventRects.get(i).event.isAllDay()){
// Calculate top.
float top = mHourHeight * 24 * mEventRects.get(i).top / 1440 + mCurrentOrigin.y + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight/2 + mEventMarginVertical;
// Calculate bottom.
float bottom = mEventRects.get(i).bottom;
bottom = mHourHeight * 24 * bottom / 1440 + mCurrentOrigin.y + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight/2 - mEventMarginVertical;
// Calculate left and right.
float left = startFromPixel + mEventRects.get(i).left * mWidthPerDay;
if (left < startFromPixel)
left += mOverlappingEventGap;
float right = left + mEventRects.get(i).width * mWidthPerDay;
if (right < startFromPixel + mWidthPerDay)
right -= mOverlappingEventGap;
// Draw the event and the event name on top of it.
if (left < right &&
left < getWidth() &&
top < getHeight() &&
right > mHeaderColumnWidth &&
bottom > mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight / 2 + mHeaderMarginBottom
) {
mEventRects.get(i).rectF = new RectF(left, top, right, bottom);
mEventBackgroundPaint.setColor(mEventRects.get(i).event.getColor() == 0 ? mDefaultEventColor : mEventRects.get(i).event.getColor());
canvas.drawRoundRect(mEventRects.get(i).rectF, mEventCornerRadius, mEventCornerRadius, mEventBackgroundPaint);
drawEventTitle(mEventRects.get(i).event, mEventRects.get(i).rectF, canvas, top, left);
}
else
mEventRects.get(i).rectF = null;
}
}
}
} | [
"private",
"void",
"drawEvents",
"(",
"Calendar",
"date",
",",
"float",
"startFromPixel",
",",
"Canvas",
"canvas",
")",
"{",
"if",
"(",
"mEventRects",
"!=",
"null",
"&&",
"mEventRects",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"int",
"i",... | Draw all the events of a particular day.
@param date The day.
@param startFromPixel The left position of the day area. The events will never go any left from this value.
@param canvas The canvas to draw upon. | [
"Draw",
"all",
"the",
"events",
"of",
"a",
"particular",
"day",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L780-L817 |
31,306 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.drawEventTitle | private void drawEventTitle(WeekViewEvent event, RectF rect, Canvas canvas, float originalTop, float originalLeft) {
if (rect.right - rect.left - mEventPadding * 2 < 0) return;
if (rect.bottom - rect.top - mEventPadding * 2 < 0) return;
// Prepare the name of the event.
SpannableStringBuilder bob = new SpannableStringBuilder();
if (event.getName() != null) {
bob.append(event.getName());
bob.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, bob.length(), 0);
bob.append(' ');
}
// Prepare the location of the event.
if (event.getLocation() != null) {
bob.append(event.getLocation());
}
int availableHeight = (int) (rect.bottom - originalTop - mEventPadding * 2);
int availableWidth = (int) (rect.right - originalLeft - mEventPadding * 2);
// Get text dimensions.
StaticLayout textLayout = new StaticLayout(bob, mEventTextPaint, availableWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
int lineHeight = textLayout.getHeight() / textLayout.getLineCount();
if (availableHeight >= lineHeight) {
// Calculate available number of line counts.
int availableLineCount = availableHeight / lineHeight;
do {
// Ellipsize text to fit into event rect.
textLayout = new StaticLayout(TextUtils.ellipsize(bob, mEventTextPaint, availableLineCount * availableWidth, TextUtils.TruncateAt.END), mEventTextPaint, (int) (rect.right - originalLeft - mEventPadding * 2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
// Reduce line count.
availableLineCount--;
// Repeat until text is short enough.
} while (textLayout.getHeight() > availableHeight);
// Draw text.
canvas.save();
canvas.translate(originalLeft + mEventPadding, originalTop + mEventPadding);
textLayout.draw(canvas);
canvas.restore();
}
} | java | private void drawEventTitle(WeekViewEvent event, RectF rect, Canvas canvas, float originalTop, float originalLeft) {
if (rect.right - rect.left - mEventPadding * 2 < 0) return;
if (rect.bottom - rect.top - mEventPadding * 2 < 0) return;
// Prepare the name of the event.
SpannableStringBuilder bob = new SpannableStringBuilder();
if (event.getName() != null) {
bob.append(event.getName());
bob.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, bob.length(), 0);
bob.append(' ');
}
// Prepare the location of the event.
if (event.getLocation() != null) {
bob.append(event.getLocation());
}
int availableHeight = (int) (rect.bottom - originalTop - mEventPadding * 2);
int availableWidth = (int) (rect.right - originalLeft - mEventPadding * 2);
// Get text dimensions.
StaticLayout textLayout = new StaticLayout(bob, mEventTextPaint, availableWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
int lineHeight = textLayout.getHeight() / textLayout.getLineCount();
if (availableHeight >= lineHeight) {
// Calculate available number of line counts.
int availableLineCount = availableHeight / lineHeight;
do {
// Ellipsize text to fit into event rect.
textLayout = new StaticLayout(TextUtils.ellipsize(bob, mEventTextPaint, availableLineCount * availableWidth, TextUtils.TruncateAt.END), mEventTextPaint, (int) (rect.right - originalLeft - mEventPadding * 2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
// Reduce line count.
availableLineCount--;
// Repeat until text is short enough.
} while (textLayout.getHeight() > availableHeight);
// Draw text.
canvas.save();
canvas.translate(originalLeft + mEventPadding, originalTop + mEventPadding);
textLayout.draw(canvas);
canvas.restore();
}
} | [
"private",
"void",
"drawEventTitle",
"(",
"WeekViewEvent",
"event",
",",
"RectF",
"rect",
",",
"Canvas",
"canvas",
",",
"float",
"originalTop",
",",
"float",
"originalLeft",
")",
"{",
"if",
"(",
"rect",
".",
"right",
"-",
"rect",
".",
"left",
"-",
"mEventP... | Draw the name of the event on top of the event rectangle.
@param event The event of which the title (and location) should be drawn.
@param rect The rectangle on which the text is to be drawn.
@param canvas The canvas to draw upon.
@param originalTop The original top position of the rectangle. The rectangle may have some of its portion outside of the visible area.
@param originalLeft The original left position of the rectangle. The rectangle may have some of its portion outside of the visible area. | [
"Draw",
"the",
"name",
"of",
"the",
"event",
"on",
"top",
"of",
"the",
"event",
"rectangle",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L872-L916 |
31,307 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.cacheEvent | private void cacheEvent(WeekViewEvent event) {
if(event.getStartTime().compareTo(event.getEndTime()) >= 0)
return;
List<WeekViewEvent> splitedEvents = event.splitWeekViewEvents();
for(WeekViewEvent splitedEvent: splitedEvents){
mEventRects.add(new EventRect(splitedEvent, event, null));
}
} | java | private void cacheEvent(WeekViewEvent event) {
if(event.getStartTime().compareTo(event.getEndTime()) >= 0)
return;
List<WeekViewEvent> splitedEvents = event.splitWeekViewEvents();
for(WeekViewEvent splitedEvent: splitedEvents){
mEventRects.add(new EventRect(splitedEvent, event, null));
}
} | [
"private",
"void",
"cacheEvent",
"(",
"WeekViewEvent",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getStartTime",
"(",
")",
".",
"compareTo",
"(",
"event",
".",
"getEndTime",
"(",
")",
")",
">=",
"0",
")",
"return",
";",
"List",
"<",
"WeekViewEvent",
... | Cache the event for smooth scrolling functionality.
@param event The event to cache. | [
"Cache",
"the",
"event",
"for",
"smooth",
"scrolling",
"functionality",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1053-L1060 |
31,308 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.sortAndCacheEvents | private void sortAndCacheEvents(List<? extends WeekViewEvent> events) {
sortEvents(events);
for (WeekViewEvent event : events) {
cacheEvent(event);
}
} | java | private void sortAndCacheEvents(List<? extends WeekViewEvent> events) {
sortEvents(events);
for (WeekViewEvent event : events) {
cacheEvent(event);
}
} | [
"private",
"void",
"sortAndCacheEvents",
"(",
"List",
"<",
"?",
"extends",
"WeekViewEvent",
">",
"events",
")",
"{",
"sortEvents",
"(",
"events",
")",
";",
"for",
"(",
"WeekViewEvent",
"event",
":",
"events",
")",
"{",
"cacheEvent",
"(",
"event",
")",
";",... | Sort and cache events.
@param events The events to be sorted and cached. | [
"Sort",
"and",
"cache",
"events",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1066-L1071 |
31,309 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.sortEvents | private void sortEvents(List<? extends WeekViewEvent> events) {
Collections.sort(events, new Comparator<WeekViewEvent>() {
@Override
public int compare(WeekViewEvent event1, WeekViewEvent event2) {
long start1 = event1.getStartTime().getTimeInMillis();
long start2 = event2.getStartTime().getTimeInMillis();
int comparator = start1 > start2 ? 1 : (start1 < start2 ? -1 : 0);
if (comparator == 0) {
long end1 = event1.getEndTime().getTimeInMillis();
long end2 = event2.getEndTime().getTimeInMillis();
comparator = end1 > end2 ? 1 : (end1 < end2 ? -1 : 0);
}
return comparator;
}
});
} | java | private void sortEvents(List<? extends WeekViewEvent> events) {
Collections.sort(events, new Comparator<WeekViewEvent>() {
@Override
public int compare(WeekViewEvent event1, WeekViewEvent event2) {
long start1 = event1.getStartTime().getTimeInMillis();
long start2 = event2.getStartTime().getTimeInMillis();
int comparator = start1 > start2 ? 1 : (start1 < start2 ? -1 : 0);
if (comparator == 0) {
long end1 = event1.getEndTime().getTimeInMillis();
long end2 = event2.getEndTime().getTimeInMillis();
comparator = end1 > end2 ? 1 : (end1 < end2 ? -1 : 0);
}
return comparator;
}
});
} | [
"private",
"void",
"sortEvents",
"(",
"List",
"<",
"?",
"extends",
"WeekViewEvent",
">",
"events",
")",
"{",
"Collections",
".",
"sort",
"(",
"events",
",",
"new",
"Comparator",
"<",
"WeekViewEvent",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
... | Sorts the events in ascending order.
@param events The events to be sorted. | [
"Sorts",
"the",
"events",
"in",
"ascending",
"order",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1077-L1092 |
31,310 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.computePositionOfEvents | private void computePositionOfEvents(List<EventRect> eventRects) {
// Make "collision groups" for all events that collide with others.
List<List<EventRect>> collisionGroups = new ArrayList<List<EventRect>>();
for (EventRect eventRect : eventRects) {
boolean isPlaced = false;
outerLoop:
for (List<EventRect> collisionGroup : collisionGroups) {
for (EventRect groupEvent : collisionGroup) {
if (isEventsCollide(groupEvent.event, eventRect.event) && groupEvent.event.isAllDay() == eventRect.event.isAllDay()) {
collisionGroup.add(eventRect);
isPlaced = true;
break outerLoop;
}
}
}
if (!isPlaced) {
List<EventRect> newGroup = new ArrayList<EventRect>();
newGroup.add(eventRect);
collisionGroups.add(newGroup);
}
}
for (List<EventRect> collisionGroup : collisionGroups) {
expandEventsToMaxWidth(collisionGroup);
}
} | java | private void computePositionOfEvents(List<EventRect> eventRects) {
// Make "collision groups" for all events that collide with others.
List<List<EventRect>> collisionGroups = new ArrayList<List<EventRect>>();
for (EventRect eventRect : eventRects) {
boolean isPlaced = false;
outerLoop:
for (List<EventRect> collisionGroup : collisionGroups) {
for (EventRect groupEvent : collisionGroup) {
if (isEventsCollide(groupEvent.event, eventRect.event) && groupEvent.event.isAllDay() == eventRect.event.isAllDay()) {
collisionGroup.add(eventRect);
isPlaced = true;
break outerLoop;
}
}
}
if (!isPlaced) {
List<EventRect> newGroup = new ArrayList<EventRect>();
newGroup.add(eventRect);
collisionGroups.add(newGroup);
}
}
for (List<EventRect> collisionGroup : collisionGroups) {
expandEventsToMaxWidth(collisionGroup);
}
} | [
"private",
"void",
"computePositionOfEvents",
"(",
"List",
"<",
"EventRect",
">",
"eventRects",
")",
"{",
"// Make \"collision groups\" for all events that collide with others.",
"List",
"<",
"List",
"<",
"EventRect",
">>",
"collisionGroups",
"=",
"new",
"ArrayList",
"<",... | Calculates the left and right positions of each events. This comes handy specially if events
are overlapping.
@param eventRects The events along with their wrapper class. | [
"Calculates",
"the",
"left",
"and",
"right",
"positions",
"of",
"each",
"events",
".",
"This",
"comes",
"handy",
"specially",
"if",
"events",
"are",
"overlapping",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1099-L1126 |
31,311 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.expandEventsToMaxWidth | private void expandEventsToMaxWidth(List<EventRect> collisionGroup) {
// Expand the events to maximum possible width.
List<List<EventRect>> columns = new ArrayList<List<EventRect>>();
columns.add(new ArrayList<EventRect>());
for (EventRect eventRect : collisionGroup) {
boolean isPlaced = false;
for (List<EventRect> column : columns) {
if (column.size() == 0) {
column.add(eventRect);
isPlaced = true;
}
else if (!isEventsCollide(eventRect.event, column.get(column.size()-1).event)) {
column.add(eventRect);
isPlaced = true;
break;
}
}
if (!isPlaced) {
List<EventRect> newColumn = new ArrayList<EventRect>();
newColumn.add(eventRect);
columns.add(newColumn);
}
}
// Calculate left and right position for all the events.
// Get the maxRowCount by looking in all columns.
int maxRowCount = 0;
for (List<EventRect> column : columns){
maxRowCount = Math.max(maxRowCount, column.size());
}
for (int i = 0; i < maxRowCount; i++) {
// Set the left and right values of the event.
float j = 0;
for (List<EventRect> column : columns) {
if (column.size() >= i+1) {
EventRect eventRect = column.get(i);
eventRect.width = 1f / columns.size();
eventRect.left = j / columns.size();
if(!eventRect.event.isAllDay()) {
eventRect.top = eventRect.event.getStartTime().get(Calendar.HOUR_OF_DAY) * 60 + eventRect.event.getStartTime().get(Calendar.MINUTE);
eventRect.bottom = eventRect.event.getEndTime().get(Calendar.HOUR_OF_DAY) * 60 + eventRect.event.getEndTime().get(Calendar.MINUTE);
}
else{
eventRect.top = 0;
eventRect.bottom = mAllDayEventHeight;
}
mEventRects.add(eventRect);
}
j++;
}
}
} | java | private void expandEventsToMaxWidth(List<EventRect> collisionGroup) {
// Expand the events to maximum possible width.
List<List<EventRect>> columns = new ArrayList<List<EventRect>>();
columns.add(new ArrayList<EventRect>());
for (EventRect eventRect : collisionGroup) {
boolean isPlaced = false;
for (List<EventRect> column : columns) {
if (column.size() == 0) {
column.add(eventRect);
isPlaced = true;
}
else if (!isEventsCollide(eventRect.event, column.get(column.size()-1).event)) {
column.add(eventRect);
isPlaced = true;
break;
}
}
if (!isPlaced) {
List<EventRect> newColumn = new ArrayList<EventRect>();
newColumn.add(eventRect);
columns.add(newColumn);
}
}
// Calculate left and right position for all the events.
// Get the maxRowCount by looking in all columns.
int maxRowCount = 0;
for (List<EventRect> column : columns){
maxRowCount = Math.max(maxRowCount, column.size());
}
for (int i = 0; i < maxRowCount; i++) {
// Set the left and right values of the event.
float j = 0;
for (List<EventRect> column : columns) {
if (column.size() >= i+1) {
EventRect eventRect = column.get(i);
eventRect.width = 1f / columns.size();
eventRect.left = j / columns.size();
if(!eventRect.event.isAllDay()) {
eventRect.top = eventRect.event.getStartTime().get(Calendar.HOUR_OF_DAY) * 60 + eventRect.event.getStartTime().get(Calendar.MINUTE);
eventRect.bottom = eventRect.event.getEndTime().get(Calendar.HOUR_OF_DAY) * 60 + eventRect.event.getEndTime().get(Calendar.MINUTE);
}
else{
eventRect.top = 0;
eventRect.bottom = mAllDayEventHeight;
}
mEventRects.add(eventRect);
}
j++;
}
}
} | [
"private",
"void",
"expandEventsToMaxWidth",
"(",
"List",
"<",
"EventRect",
">",
"collisionGroup",
")",
"{",
"// Expand the events to maximum possible width.",
"List",
"<",
"List",
"<",
"EventRect",
">>",
"columns",
"=",
"new",
"ArrayList",
"<",
"List",
"<",
"EventR... | Expands all the events to maximum possible width. The events will try to occupy maximum
space available horizontally.
@param collisionGroup The group of events which overlap with each other. | [
"Expands",
"all",
"the",
"events",
"to",
"maximum",
"possible",
"width",
".",
"The",
"events",
"will",
"try",
"to",
"occupy",
"maximum",
"space",
"available",
"horizontally",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1133-L1185 |
31,312 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.isEventsCollide | private boolean isEventsCollide(WeekViewEvent event1, WeekViewEvent event2) {
long start1 = event1.getStartTime().getTimeInMillis();
long end1 = event1.getEndTime().getTimeInMillis();
long start2 = event2.getStartTime().getTimeInMillis();
long end2 = event2.getEndTime().getTimeInMillis();
return !((start1 >= end2) || (end1 <= start2));
} | java | private boolean isEventsCollide(WeekViewEvent event1, WeekViewEvent event2) {
long start1 = event1.getStartTime().getTimeInMillis();
long end1 = event1.getEndTime().getTimeInMillis();
long start2 = event2.getStartTime().getTimeInMillis();
long end2 = event2.getEndTime().getTimeInMillis();
return !((start1 >= end2) || (end1 <= start2));
} | [
"private",
"boolean",
"isEventsCollide",
"(",
"WeekViewEvent",
"event1",
",",
"WeekViewEvent",
"event2",
")",
"{",
"long",
"start1",
"=",
"event1",
".",
"getStartTime",
"(",
")",
".",
"getTimeInMillis",
"(",
")",
";",
"long",
"end1",
"=",
"event1",
".",
"get... | Checks if two events overlap.
@param event1 The first event.
@param event2 The second event.
@return true if the events overlap. | [
"Checks",
"if",
"two",
"events",
"overlap",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1194-L1200 |
31,313 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.getDateTimeInterpreter | public DateTimeInterpreter getDateTimeInterpreter() {
if (mDateTimeInterpreter == null) {
mDateTimeInterpreter = new DateTimeInterpreter() {
@Override
public String interpretDate(Calendar date) {
try {
SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE M/dd", Locale.getDefault()) : new SimpleDateFormat("EEE M/dd", Locale.getDefault());
return sdf.format(date.getTime()).toUpperCase();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override
public String interpretTime(int hour) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, 0);
try {
SimpleDateFormat sdf = DateFormat.is24HourFormat(getContext()) ? new SimpleDateFormat("HH:mm", Locale.getDefault()) : new SimpleDateFormat("hh a", Locale.getDefault());
return sdf.format(calendar.getTime());
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
};
}
return mDateTimeInterpreter;
} | java | public DateTimeInterpreter getDateTimeInterpreter() {
if (mDateTimeInterpreter == null) {
mDateTimeInterpreter = new DateTimeInterpreter() {
@Override
public String interpretDate(Calendar date) {
try {
SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE M/dd", Locale.getDefault()) : new SimpleDateFormat("EEE M/dd", Locale.getDefault());
return sdf.format(date.getTime()).toUpperCase();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override
public String interpretTime(int hour) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, 0);
try {
SimpleDateFormat sdf = DateFormat.is24HourFormat(getContext()) ? new SimpleDateFormat("HH:mm", Locale.getDefault()) : new SimpleDateFormat("hh a", Locale.getDefault());
return sdf.format(calendar.getTime());
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
};
}
return mDateTimeInterpreter;
} | [
"public",
"DateTimeInterpreter",
"getDateTimeInterpreter",
"(",
")",
"{",
"if",
"(",
"mDateTimeInterpreter",
"==",
"null",
")",
"{",
"mDateTimeInterpreter",
"=",
"new",
"DateTimeInterpreter",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"interpretDate",
"(",
... | Get the interpreter which provides the text to show in the header column and the header row.
@return The date, time interpreter. | [
"Get",
"the",
"interpreter",
"which",
"provides",
"the",
"text",
"to",
"show",
"in",
"the",
"header",
"column",
"and",
"the",
"header",
"row",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1299-L1330 |
31,314 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.forceFinishScroll | private boolean forceFinishScroll() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// current velocity only available since api 14
return mScroller.getCurrVelocity() <= mMinimumFlingVelocity;
} else {
return false;
}
} | java | private boolean forceFinishScroll() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// current velocity only available since api 14
return mScroller.getCurrVelocity() <= mMinimumFlingVelocity;
} else {
return false;
}
} | [
"private",
"boolean",
"forceFinishScroll",
"(",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"{",
"// current velocity only available since api 14",
"return",
"mScroller",
".",
"ge... | Check if scrolling should be stopped.
@return true if scrolling should be stopped before reaching the end of animation. | [
"Check",
"if",
"scrolling",
"should",
"be",
"stopped",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1893-L1900 |
31,315 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.goToDate | public void goToDate(Calendar date) {
mScroller.forceFinished(true);
mCurrentScrollDirection = mCurrentFlingDirection = Direction.NONE;
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
if(mAreDimensionsInvalid) {
mScrollToDay = date;
return;
}
mRefreshEvents = true;
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
long day = 1000L * 60L * 60L * 24L;
long dateInMillis = date.getTimeInMillis() + date.getTimeZone().getOffset(date.getTimeInMillis());
long todayInMillis = today.getTimeInMillis() + today.getTimeZone().getOffset(today.getTimeInMillis());
long dateDifference = (dateInMillis/day) - (todayInMillis/day);
mCurrentOrigin.x = - dateDifference * (mWidthPerDay + mColumnGap);
invalidate();
} | java | public void goToDate(Calendar date) {
mScroller.forceFinished(true);
mCurrentScrollDirection = mCurrentFlingDirection = Direction.NONE;
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
if(mAreDimensionsInvalid) {
mScrollToDay = date;
return;
}
mRefreshEvents = true;
Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
long day = 1000L * 60L * 60L * 24L;
long dateInMillis = date.getTimeInMillis() + date.getTimeZone().getOffset(date.getTimeInMillis());
long todayInMillis = today.getTimeInMillis() + today.getTimeZone().getOffset(today.getTimeInMillis());
long dateDifference = (dateInMillis/day) - (todayInMillis/day);
mCurrentOrigin.x = - dateDifference * (mWidthPerDay + mColumnGap);
invalidate();
} | [
"public",
"void",
"goToDate",
"(",
"Calendar",
"date",
")",
"{",
"mScroller",
".",
"forceFinished",
"(",
"true",
")",
";",
"mCurrentScrollDirection",
"=",
"mCurrentFlingDirection",
"=",
"Direction",
".",
"NONE",
";",
"date",
".",
"set",
"(",
"Calendar",
".",
... | Show a specific day on the week view.
@param date The date to show. | [
"Show",
"a",
"specific",
"day",
"on",
"the",
"week",
"view",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1921-L1949 |
31,316 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekView.java | WeekView.goToHour | public void goToHour(double hour){
if (mAreDimensionsInvalid) {
mScrollToHour = hour;
return;
}
int verticalOffset = 0;
if (hour > 24)
verticalOffset = mHourHeight * 24;
else if (hour > 0)
verticalOffset = (int) (mHourHeight * hour);
if (verticalOffset > mHourHeight * 24 - getHeight() + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)
verticalOffset = (int)(mHourHeight * 24 - getHeight() + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom);
mCurrentOrigin.y = -verticalOffset;
invalidate();
} | java | public void goToHour(double hour){
if (mAreDimensionsInvalid) {
mScrollToHour = hour;
return;
}
int verticalOffset = 0;
if (hour > 24)
verticalOffset = mHourHeight * 24;
else if (hour > 0)
verticalOffset = (int) (mHourHeight * hour);
if (verticalOffset > mHourHeight * 24 - getHeight() + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)
verticalOffset = (int)(mHourHeight * 24 - getHeight() + mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom);
mCurrentOrigin.y = -verticalOffset;
invalidate();
} | [
"public",
"void",
"goToHour",
"(",
"double",
"hour",
")",
"{",
"if",
"(",
"mAreDimensionsInvalid",
")",
"{",
"mScrollToHour",
"=",
"hour",
";",
"return",
";",
"}",
"int",
"verticalOffset",
"=",
"0",
";",
"if",
"(",
"hour",
">",
"24",
")",
"verticalOffset... | Vertically scroll to a specific hour in the week view.
@param hour The hour to scroll to in 24-hour format. Supported values are 0-24. | [
"Vertically",
"scroll",
"to",
"a",
"specific",
"hour",
"in",
"the",
"week",
"view",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1963-L1980 |
31,317 | alamkanak/Android-Week-View | sample/src/main/java/com/alamkanak/weekview/sample/AsynchronousActivity.java | AsynchronousActivity.eventMatches | private boolean eventMatches(WeekViewEvent event, int year, int month) {
return (event.getStartTime().get(Calendar.YEAR) == year && event.getStartTime().get(Calendar.MONTH) == month - 1) || (event.getEndTime().get(Calendar.YEAR) == year && event.getEndTime().get(Calendar.MONTH) == month - 1);
} | java | private boolean eventMatches(WeekViewEvent event, int year, int month) {
return (event.getStartTime().get(Calendar.YEAR) == year && event.getStartTime().get(Calendar.MONTH) == month - 1) || (event.getEndTime().get(Calendar.YEAR) == year && event.getEndTime().get(Calendar.MONTH) == month - 1);
} | [
"private",
"boolean",
"eventMatches",
"(",
"WeekViewEvent",
"event",
",",
"int",
"year",
",",
"int",
"month",
")",
"{",
"return",
"(",
"event",
".",
"getStartTime",
"(",
")",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"==",
"year",
"&&",
"event",
"... | Checks if an event falls into a specific year and month.
@param event The event to check for.
@param year The year.
@param month The month.
@return True if the event matches the year and month. | [
"Checks",
"if",
"an",
"event",
"falls",
"into",
"a",
"specific",
"year",
"and",
"month",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/sample/src/main/java/com/alamkanak/weekview/sample/AsynchronousActivity.java#L59-L61 |
31,318 | alamkanak/Android-Week-View | library/src/main/java/com/alamkanak/weekview/WeekViewUtil.java | WeekViewUtil.isSameDay | public static boolean isSameDay(Calendar dayOne, Calendar dayTwo) {
return dayOne.get(Calendar.YEAR) == dayTwo.get(Calendar.YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR);
} | java | public static boolean isSameDay(Calendar dayOne, Calendar dayTwo) {
return dayOne.get(Calendar.YEAR) == dayTwo.get(Calendar.YEAR) && dayOne.get(Calendar.DAY_OF_YEAR) == dayTwo.get(Calendar.DAY_OF_YEAR);
} | [
"public",
"static",
"boolean",
"isSameDay",
"(",
"Calendar",
"dayOne",
",",
"Calendar",
"dayTwo",
")",
"{",
"return",
"dayOne",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"==",
"dayTwo",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"&&",
"dayOne",
... | Checks if two times are on the same day.
@param dayOne The first day.
@param dayTwo The second day.
@return Whether the times are on the same day. | [
"Checks",
"if",
"two",
"times",
"are",
"on",
"the",
"same",
"day",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/library/src/main/java/com/alamkanak/weekview/WeekViewUtil.java#L23-L25 |
31,319 | alamkanak/Android-Week-View | sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java | BaseActivity.setupDateTimeInterpreter | private void setupDateTimeInterpreter(final boolean shortDate) {
mWeekView.setDateTimeInterpreter(new DateTimeInterpreter() {
@Override
public String interpretDate(Calendar date) {
SimpleDateFormat weekdayNameFormat = new SimpleDateFormat("EEE", Locale.getDefault());
String weekday = weekdayNameFormat.format(date.getTime());
SimpleDateFormat format = new SimpleDateFormat(" M/d", Locale.getDefault());
// All android api level do not have a standard way of getting the first letter of
// the week day name. Hence we get the first char programmatically.
// Details: http://stackoverflow.com/questions/16959502/get-one-letter-abbreviation-of-week-day-of-a-date-in-java#answer-16959657
if (shortDate)
weekday = String.valueOf(weekday.charAt(0));
return weekday.toUpperCase() + format.format(date.getTime());
}
@Override
public String interpretTime(int hour) {
return hour > 11 ? (hour - 12) + " PM" : (hour == 0 ? "12 AM" : hour + " AM");
}
});
} | java | private void setupDateTimeInterpreter(final boolean shortDate) {
mWeekView.setDateTimeInterpreter(new DateTimeInterpreter() {
@Override
public String interpretDate(Calendar date) {
SimpleDateFormat weekdayNameFormat = new SimpleDateFormat("EEE", Locale.getDefault());
String weekday = weekdayNameFormat.format(date.getTime());
SimpleDateFormat format = new SimpleDateFormat(" M/d", Locale.getDefault());
// All android api level do not have a standard way of getting the first letter of
// the week day name. Hence we get the first char programmatically.
// Details: http://stackoverflow.com/questions/16959502/get-one-letter-abbreviation-of-week-day-of-a-date-in-java#answer-16959657
if (shortDate)
weekday = String.valueOf(weekday.charAt(0));
return weekday.toUpperCase() + format.format(date.getTime());
}
@Override
public String interpretTime(int hour) {
return hour > 11 ? (hour - 12) + " PM" : (hour == 0 ? "12 AM" : hour + " AM");
}
});
} | [
"private",
"void",
"setupDateTimeInterpreter",
"(",
"final",
"boolean",
"shortDate",
")",
"{",
"mWeekView",
".",
"setDateTimeInterpreter",
"(",
"new",
"DateTimeInterpreter",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"interpretDate",
"(",
"Calendar",
"date"... | Set up a date time interpreter which will show short date values when in week view and long
date values otherwise.
@param shortDate True if the date values should be short. | [
"Set",
"up",
"a",
"date",
"time",
"interpreter",
"which",
"will",
"show",
"short",
"date",
"values",
"when",
"in",
"week",
"view",
"and",
"long",
"date",
"values",
"otherwise",
"."
] | dc3f97d65d44785d1a761b52b58527c86c4eee1b | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/sample/src/main/java/com/alamkanak/weekview/sample/BaseActivity.java#L121-L142 |
31,320 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java | DialogPlusBuilder.setOutMostMargin | public DialogPlusBuilder setOutMostMargin(int left, int top, int right, int bottom) {
this.outMostMargin[0] = left;
this.outMostMargin[1] = top;
this.outMostMargin[2] = right;
this.outMostMargin[3] = bottom;
return this;
} | java | public DialogPlusBuilder setOutMostMargin(int left, int top, int right, int bottom) {
this.outMostMargin[0] = left;
this.outMostMargin[1] = top;
this.outMostMargin[2] = right;
this.outMostMargin[3] = bottom;
return this;
} | [
"public",
"DialogPlusBuilder",
"setOutMostMargin",
"(",
"int",
"left",
",",
"int",
"top",
",",
"int",
"right",
",",
"int",
"bottom",
")",
"{",
"this",
".",
"outMostMargin",
"[",
"0",
"]",
"=",
"left",
";",
"this",
".",
"outMostMargin",
"[",
"1",
"]",
"... | Add margins to your outmost view which contains everything. As default they are 0
are applied | [
"Add",
"margins",
"to",
"your",
"outmost",
"view",
"which",
"contains",
"everything",
".",
"As",
"default",
"they",
"are",
"0",
"are",
"applied"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java#L208-L214 |
31,321 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java | DialogPlusBuilder.setMargin | public DialogPlusBuilder setMargin(int left, int top, int right, int bottom) {
this.margin[0] = left;
this.margin[1] = top;
this.margin[2] = right;
this.margin[3] = bottom;
return this;
} | java | public DialogPlusBuilder setMargin(int left, int top, int right, int bottom) {
this.margin[0] = left;
this.margin[1] = top;
this.margin[2] = right;
this.margin[3] = bottom;
return this;
} | [
"public",
"DialogPlusBuilder",
"setMargin",
"(",
"int",
"left",
",",
"int",
"top",
",",
"int",
"right",
",",
"int",
"bottom",
")",
"{",
"this",
".",
"margin",
"[",
"0",
"]",
"=",
"left",
";",
"this",
".",
"margin",
"[",
"1",
"]",
"=",
"top",
";",
... | Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins
are applied | [
"Add",
"margins",
"to",
"your",
"dialog",
".",
"They",
"are",
"set",
"to",
"0",
"except",
"when",
"gravity",
"is",
"center",
".",
"In",
"that",
"case",
"basic",
"margins",
"are",
"applied"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java#L220-L226 |
31,322 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java | DialogPlusBuilder.setPadding | public DialogPlusBuilder setPadding(int left, int top, int right, int bottom) {
this.padding[0] = left;
this.padding[1] = top;
this.padding[2] = right;
this.padding[3] = bottom;
return this;
} | java | public DialogPlusBuilder setPadding(int left, int top, int right, int bottom) {
this.padding[0] = left;
this.padding[1] = top;
this.padding[2] = right;
this.padding[3] = bottom;
return this;
} | [
"public",
"DialogPlusBuilder",
"setPadding",
"(",
"int",
"left",
",",
"int",
"top",
",",
"int",
"right",
",",
"int",
"bottom",
")",
"{",
"this",
".",
"padding",
"[",
"0",
"]",
"=",
"left",
";",
"this",
".",
"padding",
"[",
"1",
"]",
"=",
"top",
";"... | Set paddings for the dialog content | [
"Set",
"paddings",
"for",
"the",
"dialog",
"content"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java#L231-L237 |
31,323 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java | DialogPlusBuilder.getMargin | private int getMargin(int gravity, int margin, int minimumMargin) {
switch (gravity) {
case Gravity.CENTER:
return (margin == INVALID) ? minimumMargin : margin;
default:
return (margin == INVALID) ? 0 : margin;
}
} | java | private int getMargin(int gravity, int margin, int minimumMargin) {
switch (gravity) {
case Gravity.CENTER:
return (margin == INVALID) ? minimumMargin : margin;
default:
return (margin == INVALID) ? 0 : margin;
}
} | [
"private",
"int",
"getMargin",
"(",
"int",
"gravity",
",",
"int",
"margin",
",",
"int",
"minimumMargin",
")",
"{",
"switch",
"(",
"gravity",
")",
"{",
"case",
"Gravity",
".",
"CENTER",
":",
"return",
"(",
"margin",
"==",
"INVALID",
")",
"?",
"minimumMarg... | Get margins if provided or assign default values based on gravity
@param gravity the gravity of the dialog
@param margin the value defined in the builder
@param minimumMargin the minimum margin when gravity center is selected
@return the value of the margin | [
"Get",
"margins",
"if",
"provided",
"or",
"assign",
"default",
"values",
"based",
"on",
"gravity"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlusBuilder.java#L415-L422 |
31,324 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.isShowing | public boolean isShowing() {
View view = decorView.findViewById(R.id.dialogplus_outmost_container);
return view != null;
} | java | public boolean isShowing() {
View view = decorView.findViewById(R.id.dialogplus_outmost_container);
return view != null;
} | [
"public",
"boolean",
"isShowing",
"(",
")",
"{",
"View",
"view",
"=",
"decorView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"dialogplus_outmost_container",
")",
";",
"return",
"view",
"!=",
"null",
";",
"}"
] | Checks if the dialog is shown | [
"Checks",
"if",
"the",
"dialog",
"is",
"shown"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L145-L148 |
31,325 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.dismiss | public void dismiss() {
if (isDismissing) {
return;
}
outAnim.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {
}
@Override public void onAnimationEnd(Animation animation) {
decorView.post(new Runnable() {
@Override public void run() {
decorView.removeView(rootView);
isDismissing = false;
if (onDismissListener != null) {
onDismissListener.onDismiss(DialogPlus.this);
}
}
});
}
@Override public void onAnimationRepeat(Animation animation) {
}
});
contentContainer.startAnimation(outAnim);
isDismissing = true;
} | java | public void dismiss() {
if (isDismissing) {
return;
}
outAnim.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {
}
@Override public void onAnimationEnd(Animation animation) {
decorView.post(new Runnable() {
@Override public void run() {
decorView.removeView(rootView);
isDismissing = false;
if (onDismissListener != null) {
onDismissListener.onDismiss(DialogPlus.this);
}
}
});
}
@Override public void onAnimationRepeat(Animation animation) {
}
});
contentContainer.startAnimation(outAnim);
isDismissing = true;
} | [
"public",
"void",
"dismiss",
"(",
")",
"{",
"if",
"(",
"isDismissing",
")",
"{",
"return",
";",
"}",
"outAnim",
".",
"setAnimationListener",
"(",
"new",
"Animation",
".",
"AnimationListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationStar... | Dismisses the displayed dialog. | [
"Dismisses",
"the",
"displayed",
"dialog",
"."
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L153-L181 |
31,326 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.initContentView | private void initContentView(LayoutInflater inflater, View header, boolean fixedHeader, View footer,
boolean fixedFooter, BaseAdapter adapter, int[] padding, int[] margin) {
View contentView = createView(inflater, header, fixedHeader, footer, fixedFooter, adapter);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
);
params.setMargins(margin[0], margin[1], margin[2], margin[3]);
contentView.setLayoutParams(params);
getHolderView().setPadding(padding[0], padding[1], padding[2], padding[3]);
contentContainer.addView(contentView);
} | java | private void initContentView(LayoutInflater inflater, View header, boolean fixedHeader, View footer,
boolean fixedFooter, BaseAdapter adapter, int[] padding, int[] margin) {
View contentView = createView(inflater, header, fixedHeader, footer, fixedFooter, adapter);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
);
params.setMargins(margin[0], margin[1], margin[2], margin[3]);
contentView.setLayoutParams(params);
getHolderView().setPadding(padding[0], padding[1], padding[2], padding[3]);
contentContainer.addView(contentView);
} | [
"private",
"void",
"initContentView",
"(",
"LayoutInflater",
"inflater",
",",
"View",
"header",
",",
"boolean",
"fixedHeader",
",",
"View",
"footer",
",",
"boolean",
"fixedFooter",
",",
"BaseAdapter",
"adapter",
",",
"int",
"[",
"]",
"padding",
",",
"int",
"["... | It is called in order to create content | [
"It",
"is",
"called",
"in",
"order",
"to",
"create",
"content"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L234-L244 |
31,327 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.initCancelable | private void initCancelable() {
if (!isCancelable) {
return;
}
View view = rootView.findViewById(R.id.dialogplus_outmost_container);
view.setOnTouchListener(onCancelableTouchListener);
} | java | private void initCancelable() {
if (!isCancelable) {
return;
}
View view = rootView.findViewById(R.id.dialogplus_outmost_container);
view.setOnTouchListener(onCancelableTouchListener);
} | [
"private",
"void",
"initCancelable",
"(",
")",
"{",
"if",
"(",
"!",
"isCancelable",
")",
"{",
"return",
";",
"}",
"View",
"view",
"=",
"rootView",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"dialogplus_outmost_container",
")",
";",
"view",
".",
"setO... | It is called to set whether the dialog is cancellable by pressing back button or
touching the black overlay | [
"It",
"is",
"called",
"to",
"set",
"whether",
"the",
"dialog",
"is",
"cancellable",
"by",
"pressing",
"back",
"button",
"or",
"touching",
"the",
"black",
"overlay"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L250-L256 |
31,328 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.assignClickListenerRecursively | private void assignClickListenerRecursively(View parent) {
if (parent == null) {
return;
}
if (parent instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) parent;
int childCount = viewGroup.getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
View child = viewGroup.getChildAt(i);
assignClickListenerRecursively(child);
}
}
setClickListener(parent);
} | java | private void assignClickListenerRecursively(View parent) {
if (parent == null) {
return;
}
if (parent instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) parent;
int childCount = viewGroup.getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
View child = viewGroup.getChildAt(i);
assignClickListenerRecursively(child);
}
}
setClickListener(parent);
} | [
"private",
"void",
"assignClickListenerRecursively",
"(",
"View",
"parent",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"parent",
"instanceof",
"ViewGroup",
")",
"{",
"ViewGroup",
"viewGroup",
"=",
"(",
"ViewGroup",
... | Loop among the views in the hierarchy and assign listener to them | [
"Loop",
"among",
"the",
"views",
"in",
"the",
"hierarchy",
"and",
"assign",
"listener",
"to",
"them"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L300-L314 |
31,329 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.setClickListener | private void setClickListener(View view) {
if (view.getId() == INVALID) {
return;
}
//adapterview does not support click listener
if (view instanceof AdapterView) {
return;
}
view.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
if (onClickListener == null) {
return;
}
onClickListener.onClick(DialogPlus.this, v);
}
});
} | java | private void setClickListener(View view) {
if (view.getId() == INVALID) {
return;
}
//adapterview does not support click listener
if (view instanceof AdapterView) {
return;
}
view.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
if (onClickListener == null) {
return;
}
onClickListener.onClick(DialogPlus.this, v);
}
});
} | [
"private",
"void",
"setClickListener",
"(",
"View",
"view",
")",
"{",
"if",
"(",
"view",
".",
"getId",
"(",
")",
"==",
"INVALID",
")",
"{",
"return",
";",
"}",
"//adapterview does not support click listener",
"if",
"(",
"view",
"instanceof",
"AdapterView",
")"... | It is used to setListener on view that have a valid id associated | [
"It",
"is",
"used",
"to",
"setListener",
"on",
"view",
"that",
"have",
"a",
"valid",
"id",
"associated"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L319-L336 |
31,330 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/Utils.java | Utils.getView | @Nullable static View getView(Context context, int resourceId, View view) {
LayoutInflater inflater = LayoutInflater.from(context);
if (view != null) {
return view;
}
if (resourceId != INVALID) {
view = inflater.inflate(resourceId, null);
}
return view;
} | java | @Nullable static View getView(Context context, int resourceId, View view) {
LayoutInflater inflater = LayoutInflater.from(context);
if (view != null) {
return view;
}
if (resourceId != INVALID) {
view = inflater.inflate(resourceId, null);
}
return view;
} | [
"@",
"Nullable",
"static",
"View",
"getView",
"(",
"Context",
"context",
",",
"int",
"resourceId",
",",
"View",
"view",
")",
"{",
"LayoutInflater",
"inflater",
"=",
"LayoutInflater",
".",
"from",
"(",
"context",
")",
";",
"if",
"(",
"view",
"!=",
"null",
... | This will be called in order to create view, if the given view is not null,
it will be used directly, otherwise it will check the resourceId
@return null if both resourceId and view is not set | [
"This",
"will",
"be",
"called",
"in",
"order",
"to",
"create",
"view",
"if",
"the",
"given",
"view",
"is",
"not",
"null",
"it",
"will",
"be",
"used",
"directly",
"otherwise",
"it",
"will",
"check",
"the",
"resourceId"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/Utils.java#L45-L54 |
31,331 | orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/Utils.java | Utils.getAnimationResource | static int getAnimationResource(int gravity, boolean isInAnimation) {
if ((gravity & Gravity.TOP) == Gravity.TOP) {
return isInAnimation ? R.anim.slide_in_top : R.anim.slide_out_top;
}
if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
return isInAnimation ? R.anim.slide_in_bottom : R.anim.slide_out_bottom;
}
if ((gravity & Gravity.CENTER) == Gravity.CENTER) {
return isInAnimation ? R.anim.fade_in_center : R.anim.fade_out_center;
}
return INVALID;
} | java | static int getAnimationResource(int gravity, boolean isInAnimation) {
if ((gravity & Gravity.TOP) == Gravity.TOP) {
return isInAnimation ? R.anim.slide_in_top : R.anim.slide_out_top;
}
if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
return isInAnimation ? R.anim.slide_in_bottom : R.anim.slide_out_bottom;
}
if ((gravity & Gravity.CENTER) == Gravity.CENTER) {
return isInAnimation ? R.anim.fade_in_center : R.anim.fade_out_center;
}
return INVALID;
} | [
"static",
"int",
"getAnimationResource",
"(",
"int",
"gravity",
",",
"boolean",
"isInAnimation",
")",
"{",
"if",
"(",
"(",
"gravity",
"&",
"Gravity",
".",
"TOP",
")",
"==",
"Gravity",
".",
"TOP",
")",
"{",
"return",
"isInAnimation",
"?",
"R",
".",
"anim"... | Get default animation resource when not defined by the user
@param gravity the gravity of the dialog
@param isInAnimation determine if is in or out animation. true when is is
@return the id of the animation resource | [
"Get",
"default",
"animation",
"resource",
"when",
"not",
"defined",
"by",
"the",
"user"
] | 291bf4daaa3c81bf5537125f547913beb8ee2c17 | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/Utils.java#L63-L74 |
31,332 | vanniktech/Emoji | emoji/src/main/java/com/vanniktech/emoji/EmojiManager.java | EmojiManager.install | public static void install(@NonNull final EmojiProvider provider) {
INSTANCE.categories = checkNotNull(provider.getCategories(), "categories == null");
INSTANCE.emojiMap.clear();
INSTANCE.emojiReplacer = provider instanceof EmojiReplacer ? (EmojiReplacer) provider : DEFAULT_EMOJI_REPLACER;
final List<String> unicodesForPattern = new ArrayList<>(GUESSED_UNICODE_AMOUNT);
final int categoriesSize = INSTANCE.categories.length;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < categoriesSize; i++) {
final Emoji[] emojis = checkNotNull(INSTANCE.categories[i].getEmojis(), "emojies == null");
final int emojisSize = emojis.length;
//noinspection ForLoopReplaceableByForEach
for (int j = 0; j < emojisSize; j++) {
final Emoji emoji = emojis[j];
final String unicode = emoji.getUnicode();
final List<Emoji> variants = emoji.getVariants();
INSTANCE.emojiMap.put(unicode, emoji);
unicodesForPattern.add(unicode);
//noinspection ForLoopReplaceableByForEach
for (int k = 0; k < variants.size(); k++) {
final Emoji variant = variants.get(k);
final String variantUnicode = variant.getUnicode();
INSTANCE.emojiMap.put(variantUnicode, variant);
unicodesForPattern.add(variantUnicode);
}
}
}
if (unicodesForPattern.isEmpty()) {
throw new IllegalArgumentException("Your EmojiProvider must at least have one category with at least one emoji.");
}
// We need to sort the unicodes by length so the longest one gets matched first.
Collections.sort(unicodesForPattern, STRING_LENGTH_COMPARATOR);
final StringBuilder patternBuilder = new StringBuilder(GUESSED_TOTAL_PATTERN_LENGTH);
final int unicodesForPatternSize = unicodesForPattern.size();
for (int i = 0; i < unicodesForPatternSize; i++) {
patternBuilder.append(Pattern.quote(unicodesForPattern.get(i))).append('|');
}
final String regex = patternBuilder.deleteCharAt(patternBuilder.length() - 1).toString();
INSTANCE.emojiPattern = Pattern.compile(regex);
INSTANCE.emojiRepetitivePattern = Pattern.compile('(' + regex + ")+");
} | java | public static void install(@NonNull final EmojiProvider provider) {
INSTANCE.categories = checkNotNull(provider.getCategories(), "categories == null");
INSTANCE.emojiMap.clear();
INSTANCE.emojiReplacer = provider instanceof EmojiReplacer ? (EmojiReplacer) provider : DEFAULT_EMOJI_REPLACER;
final List<String> unicodesForPattern = new ArrayList<>(GUESSED_UNICODE_AMOUNT);
final int categoriesSize = INSTANCE.categories.length;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < categoriesSize; i++) {
final Emoji[] emojis = checkNotNull(INSTANCE.categories[i].getEmojis(), "emojies == null");
final int emojisSize = emojis.length;
//noinspection ForLoopReplaceableByForEach
for (int j = 0; j < emojisSize; j++) {
final Emoji emoji = emojis[j];
final String unicode = emoji.getUnicode();
final List<Emoji> variants = emoji.getVariants();
INSTANCE.emojiMap.put(unicode, emoji);
unicodesForPattern.add(unicode);
//noinspection ForLoopReplaceableByForEach
for (int k = 0; k < variants.size(); k++) {
final Emoji variant = variants.get(k);
final String variantUnicode = variant.getUnicode();
INSTANCE.emojiMap.put(variantUnicode, variant);
unicodesForPattern.add(variantUnicode);
}
}
}
if (unicodesForPattern.isEmpty()) {
throw new IllegalArgumentException("Your EmojiProvider must at least have one category with at least one emoji.");
}
// We need to sort the unicodes by length so the longest one gets matched first.
Collections.sort(unicodesForPattern, STRING_LENGTH_COMPARATOR);
final StringBuilder patternBuilder = new StringBuilder(GUESSED_TOTAL_PATTERN_LENGTH);
final int unicodesForPatternSize = unicodesForPattern.size();
for (int i = 0; i < unicodesForPatternSize; i++) {
patternBuilder.append(Pattern.quote(unicodesForPattern.get(i))).append('|');
}
final String regex = patternBuilder.deleteCharAt(patternBuilder.length() - 1).toString();
INSTANCE.emojiPattern = Pattern.compile(regex);
INSTANCE.emojiRepetitivePattern = Pattern.compile('(' + regex + ")+");
} | [
"public",
"static",
"void",
"install",
"(",
"@",
"NonNull",
"final",
"EmojiProvider",
"provider",
")",
"{",
"INSTANCE",
".",
"categories",
"=",
"checkNotNull",
"(",
"provider",
".",
"getCategories",
"(",
")",
",",
"\"categories == null\"",
")",
";",
"INSTANCE",
... | Installs the given EmojiProvider.
NOTE: That only one can be present at any time.
@param provider the provider that should be installed. | [
"Installs",
"the",
"given",
"EmojiProvider",
"."
] | 6d53773c1e018a4d19065b9dc1092de4308dd6f3 | https://github.com/vanniktech/Emoji/blob/6d53773c1e018a4d19065b9dc1092de4308dd6f3/emoji/src/main/java/com/vanniktech/emoji/EmojiManager.java#L85-L135 |
31,333 | vanniktech/Emoji | emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java | EmojiUtils.isOnlyEmojis | public static boolean isOnlyEmojis(@Nullable final String text) {
if (!TextUtils.isEmpty(text)) {
final String inputWithoutSpaces = SPACE_REMOVAL.matcher(text).replaceAll(Matcher.quoteReplacement(""));
return EmojiManager.getInstance()
.getEmojiRepetitivePattern()
.matcher(inputWithoutSpaces)
.matches();
}
return false;
} | java | public static boolean isOnlyEmojis(@Nullable final String text) {
if (!TextUtils.isEmpty(text)) {
final String inputWithoutSpaces = SPACE_REMOVAL.matcher(text).replaceAll(Matcher.quoteReplacement(""));
return EmojiManager.getInstance()
.getEmojiRepetitivePattern()
.matcher(inputWithoutSpaces)
.matches();
}
return false;
} | [
"public",
"static",
"boolean",
"isOnlyEmojis",
"(",
"@",
"Nullable",
"final",
"String",
"text",
")",
"{",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"text",
")",
")",
"{",
"final",
"String",
"inputWithoutSpaces",
"=",
"SPACE_REMOVAL",
".",
"matcher",
... | returns true when the string contains only emojis. Note that whitespace will be filtered out. | [
"returns",
"true",
"when",
"the",
"string",
"contains",
"only",
"emojis",
".",
"Note",
"that",
"whitespace",
"will",
"be",
"filtered",
"out",
"."
] | 6d53773c1e018a4d19065b9dc1092de4308dd6f3 | https://github.com/vanniktech/Emoji/blob/6d53773c1e018a4d19065b9dc1092de4308dd6f3/emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java#L15-L26 |
31,334 | vanniktech/Emoji | emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java | EmojiUtils.emojis | @NonNull public static List<EmojiRange> emojis(@Nullable final String text) {
return EmojiManager.getInstance().findAllEmojis(text);
} | java | @NonNull public static List<EmojiRange> emojis(@Nullable final String text) {
return EmojiManager.getInstance().findAllEmojis(text);
} | [
"@",
"NonNull",
"public",
"static",
"List",
"<",
"EmojiRange",
">",
"emojis",
"(",
"@",
"Nullable",
"final",
"String",
"text",
")",
"{",
"return",
"EmojiManager",
".",
"getInstance",
"(",
")",
".",
"findAllEmojis",
"(",
"text",
")",
";",
"}"
] | returns the emojis that were found in the given text | [
"returns",
"the",
"emojis",
"that",
"were",
"found",
"in",
"the",
"given",
"text"
] | 6d53773c1e018a4d19065b9dc1092de4308dd6f3 | https://github.com/vanniktech/Emoji/blob/6d53773c1e018a4d19065b9dc1092de4308dd6f3/emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java#L29-L31 |
31,335 | vanniktech/Emoji | emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java | EmojiUtils.emojiInformation | @NonNull public static EmojiInformation emojiInformation(@Nullable final String text) {
final List<EmojiRange> emojis = EmojiManager.getInstance().findAllEmojis(text);
final boolean isOnlyEmojis = isOnlyEmojis(text);
return new EmojiInformation(isOnlyEmojis, emojis);
} | java | @NonNull public static EmojiInformation emojiInformation(@Nullable final String text) {
final List<EmojiRange> emojis = EmojiManager.getInstance().findAllEmojis(text);
final boolean isOnlyEmojis = isOnlyEmojis(text);
return new EmojiInformation(isOnlyEmojis, emojis);
} | [
"@",
"NonNull",
"public",
"static",
"EmojiInformation",
"emojiInformation",
"(",
"@",
"Nullable",
"final",
"String",
"text",
")",
"{",
"final",
"List",
"<",
"EmojiRange",
">",
"emojis",
"=",
"EmojiManager",
".",
"getInstance",
"(",
")",
".",
"findAllEmojis",
"... | returns a class that contains all of the emoji information that was found in the given text | [
"returns",
"a",
"class",
"that",
"contains",
"all",
"of",
"the",
"emoji",
"information",
"that",
"was",
"found",
"in",
"the",
"given",
"text"
] | 6d53773c1e018a4d19065b9dc1092de4308dd6f3 | https://github.com/vanniktech/Emoji/blob/6d53773c1e018a4d19065b9dc1092de4308dd6f3/emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java#L39-L43 |
31,336 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/ElevationApi.java | ElevationApi.getByPoints | public static PendingResult<ElevationResult[]> getByPoints(
GeoApiContext context, LatLng... points) {
return context.get(API_CONFIG, MultiResponse.class, "locations", shortestParam(points));
} | java | public static PendingResult<ElevationResult[]> getByPoints(
GeoApiContext context, LatLng... points) {
return context.get(API_CONFIG, MultiResponse.class, "locations", shortestParam(points));
} | [
"public",
"static",
"PendingResult",
"<",
"ElevationResult",
"[",
"]",
">",
"getByPoints",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"...",
"points",
")",
"{",
"return",
"context",
".",
"get",
"(",
"API_CONFIG",
",",
"MultiResponse",
".",
"class",
",",
... | Gets a list of elevations for a list of points.
@param context The {@link GeoApiContext} to make requests through.
@param points The points to retrieve elevations for.
@return The elevations as a {@link PendingResult}. | [
"Gets",
"a",
"list",
"of",
"elevations",
"for",
"a",
"list",
"of",
"points",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/ElevationApi.java#L48-L51 |
31,337 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/ElevationApi.java | ElevationApi.getByPoint | public static PendingResult<ElevationResult> getByPoint(GeoApiContext context, LatLng location) {
return context.get(API_CONFIG, SingularResponse.class, "locations", location.toString());
} | java | public static PendingResult<ElevationResult> getByPoint(GeoApiContext context, LatLng location) {
return context.get(API_CONFIG, SingularResponse.class, "locations", location.toString());
} | [
"public",
"static",
"PendingResult",
"<",
"ElevationResult",
">",
"getByPoint",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"location",
")",
"{",
"return",
"context",
".",
"get",
"(",
"API_CONFIG",
",",
"SingularResponse",
".",
"class",
",",
"\"locations\"",
... | Retrieves the elevation of a single location.
@param context The {@link GeoApiContext} to make requests through.
@param location The location to retrieve the elevation for.
@return The elevation as a {@link PendingResult}. | [
"Retrieves",
"the",
"elevation",
"of",
"a",
"single",
"location",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/ElevationApi.java#L109-L111 |
31,338 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/ElevationApi.java | ElevationApi.getByPoints | public static PendingResult<ElevationResult[]> getByPoints(
GeoApiContext context, EncodedPolyline encodedPolyline) {
return context.get(
API_CONFIG, MultiResponse.class, "locations", "enc:" + encodedPolyline.getEncodedPath());
} | java | public static PendingResult<ElevationResult[]> getByPoints(
GeoApiContext context, EncodedPolyline encodedPolyline) {
return context.get(
API_CONFIG, MultiResponse.class, "locations", "enc:" + encodedPolyline.getEncodedPath());
} | [
"public",
"static",
"PendingResult",
"<",
"ElevationResult",
"[",
"]",
">",
"getByPoints",
"(",
"GeoApiContext",
"context",
",",
"EncodedPolyline",
"encodedPolyline",
")",
"{",
"return",
"context",
".",
"get",
"(",
"API_CONFIG",
",",
"MultiResponse",
".",
"class",... | Retrieves the elevations of an encoded polyline path.
@param context The {@link GeoApiContext} to make requests through.
@param encodedPolyline The encoded polyline to retrieve elevations for.
@return The elevations as a {@link PendingResult}. | [
"Retrieves",
"the",
"elevations",
"of",
"an",
"encoded",
"polyline",
"path",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/ElevationApi.java#L144-L148 |
31,339 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/GeocodingApiRequest.java | GeocodingApiRequest.bounds | public GeocodingApiRequest bounds(LatLng southWestBound, LatLng northEastBound) {
return param("bounds", join('|', southWestBound, northEastBound));
} | java | public GeocodingApiRequest bounds(LatLng southWestBound, LatLng northEastBound) {
return param("bounds", join('|', southWestBound, northEastBound));
} | [
"public",
"GeocodingApiRequest",
"bounds",
"(",
"LatLng",
"southWestBound",
",",
"LatLng",
"northEastBound",
")",
"{",
"return",
"param",
"(",
"\"bounds\"",
",",
"join",
"(",
"'",
"'",
",",
"southWestBound",
",",
"northEastBound",
")",
")",
";",
"}"
] | Sets the bounding box of the viewport within which to bias geocode results more prominently.
This parameter will only influence, not fully restrict, results from the geocoder.
<p>For more information see <a
href="https://developers.google.com/maps/documentation/geocoding/intro?hl=pl#Viewports">
Viewport Biasing</a>.
@param southWestBound The South West bound of the bounding box.
@param northEastBound The North East bound of the bounding box.
@return Returns this {@code GeocodingApiRequest} for call chaining. | [
"Sets",
"the",
"bounding",
"box",
"of",
"the",
"viewport",
"within",
"which",
"to",
"bias",
"geocode",
"results",
"more",
"prominently",
".",
"This",
"parameter",
"will",
"only",
"influence",
"not",
"fully",
"restrict",
"results",
"from",
"the",
"geocoder",
".... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/GeocodingApiRequest.java#L99-L101 |
31,340 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/DistanceMatrixApiRequest.java | DistanceMatrixApiRequest.mode | public DistanceMatrixApiRequest mode(TravelMode mode) {
if (TravelMode.DRIVING.equals(mode)
|| TravelMode.WALKING.equals(mode)
|| TravelMode.BICYCLING.equals(mode)
|| TravelMode.TRANSIT.equals(mode)) {
return param("mode", mode);
}
throw new IllegalArgumentException(
"Distance Matrix API travel modes must be Driving, Transit, Walking or Bicycling");
} | java | public DistanceMatrixApiRequest mode(TravelMode mode) {
if (TravelMode.DRIVING.equals(mode)
|| TravelMode.WALKING.equals(mode)
|| TravelMode.BICYCLING.equals(mode)
|| TravelMode.TRANSIT.equals(mode)) {
return param("mode", mode);
}
throw new IllegalArgumentException(
"Distance Matrix API travel modes must be Driving, Transit, Walking or Bicycling");
} | [
"public",
"DistanceMatrixApiRequest",
"mode",
"(",
"TravelMode",
"mode",
")",
"{",
"if",
"(",
"TravelMode",
".",
"DRIVING",
".",
"equals",
"(",
"mode",
")",
"||",
"TravelMode",
".",
"WALKING",
".",
"equals",
"(",
"mode",
")",
"||",
"TravelMode",
".",
"BICY... | Specifies the mode of transport to use when calculating directions.
<p>Note that Distance Matrix requests only support {@link TravelMode#DRIVING}, {@link
TravelMode#WALKING} and {@link TravelMode#BICYCLING}.
@param mode One of the travel modes supported by the Distance Matrix API.
@return Returns this {@code DistanceMatrixApiRequest} for call chaining. | [
"Specifies",
"the",
"mode",
"of",
"transport",
"to",
"use",
"when",
"calculating",
"directions",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/DistanceMatrixApiRequest.java#L104-L113 |
31,341 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/DirectionsApiRequest.java | DirectionsApiRequest.waypointsFromPlaceIds | public DirectionsApiRequest waypointsFromPlaceIds(String... waypoints) {
Waypoint[] objWaypoints = new Waypoint[waypoints.length];
for (int i = 0; i < waypoints.length; i++) {
objWaypoints[i] = new Waypoint(prefixPlaceId(waypoints[i]));
}
return waypoints(objWaypoints);
} | java | public DirectionsApiRequest waypointsFromPlaceIds(String... waypoints) {
Waypoint[] objWaypoints = new Waypoint[waypoints.length];
for (int i = 0; i < waypoints.length; i++) {
objWaypoints[i] = new Waypoint(prefixPlaceId(waypoints[i]));
}
return waypoints(objWaypoints);
} | [
"public",
"DirectionsApiRequest",
"waypointsFromPlaceIds",
"(",
"String",
"...",
"waypoints",
")",
"{",
"Waypoint",
"[",
"]",
"objWaypoints",
"=",
"new",
"Waypoint",
"[",
"waypoints",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<"... | Specifies the list of waypoints as Plade ID Strings, prefixing them as required by the API.
<p>See {@link #prefixPlaceId(String)}.
<p>See {@link #waypoints(Waypoint...)}.
@param waypoints The waypoints to add to this directions request.
@return Returns this {@code DirectionsApiRequest} for call chaining. | [
"Specifies",
"the",
"list",
"of",
"waypoints",
"as",
"Plade",
"ID",
"Strings",
"prefixing",
"them",
"as",
"required",
"by",
"the",
"API",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/DirectionsApiRequest.java#L258-L264 |
31,342 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/internal/LatLngAdapter.java | LatLngAdapter.read | @Override
public LatLng read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
double lat = 0;
double lng = 0;
boolean hasLat = false;
boolean hasLng = false;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if ("lat".equals(name) || "latitude".equals(name)) {
lat = reader.nextDouble();
hasLat = true;
} else if ("lng".equals(name) || "longitude".equals(name)) {
lng = reader.nextDouble();
hasLng = true;
}
}
reader.endObject();
if (hasLat && hasLng) {
return new LatLng(lat, lng);
} else {
return null;
}
} | java | @Override
public LatLng read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
double lat = 0;
double lng = 0;
boolean hasLat = false;
boolean hasLng = false;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if ("lat".equals(name) || "latitude".equals(name)) {
lat = reader.nextDouble();
hasLat = true;
} else if ("lng".equals(name) || "longitude".equals(name)) {
lng = reader.nextDouble();
hasLng = true;
}
}
reader.endObject();
if (hasLat && hasLng) {
return new LatLng(lat, lng);
} else {
return null;
}
} | [
"@",
"Override",
"public",
"LatLng",
"read",
"(",
"JsonReader",
"reader",
")",
"throws",
"IOException",
"{",
"if",
"(",
"reader",
".",
"peek",
"(",
")",
"==",
"JsonToken",
".",
"NULL",
")",
"{",
"reader",
".",
"nextNull",
"(",
")",
";",
"return",
"null... | Reads in a JSON object and try to create a LatLng in one of the following formats.
<pre>{
"lat" : -33.8353684,
"lng" : 140.8527069
}
{
"latitude": -33.865257570508334,
"longitude": 151.19287000481452
}</pre> | [
"Reads",
"in",
"a",
"JSON",
"object",
"and",
"try",
"to",
"create",
"a",
"LatLng",
"in",
"one",
"of",
"the",
"following",
"formats",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/internal/LatLngAdapter.java#L40-L70 |
31,343 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/DirectionsApi.java | DirectionsApi.getDirections | public static DirectionsApiRequest getDirections(
GeoApiContext context, String origin, String destination) {
return new DirectionsApiRequest(context).origin(origin).destination(destination);
} | java | public static DirectionsApiRequest getDirections(
GeoApiContext context, String origin, String destination) {
return new DirectionsApiRequest(context).origin(origin).destination(destination);
} | [
"public",
"static",
"DirectionsApiRequest",
"getDirections",
"(",
"GeoApiContext",
"context",
",",
"String",
"origin",
",",
"String",
"destination",
")",
"{",
"return",
"new",
"DirectionsApiRequest",
"(",
"context",
")",
".",
"origin",
"(",
"origin",
")",
".",
"... | Creates a new DirectionsApiRequest between the given origin and destination, using the defaults
for all other options.
@param context Context that the DirectionsApiRequest will be executed against
@param origin Origin address as text
@param destination Destination address as text
@return A newly constructed DirectionsApiRequest between the given points. | [
"Creates",
"a",
"new",
"DirectionsApiRequest",
"between",
"the",
"given",
"origin",
"and",
"destination",
"using",
"the",
"defaults",
"for",
"all",
"other",
"options",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/DirectionsApi.java#L61-L64 |
31,344 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/errors/ApiException.java | ApiException.from | public static ApiException from(String status, String errorMessage) {
// Classic Geo API error formats
if ("OK".equals(status)) {
return null;
} else if ("INVALID_REQUEST".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("MAX_ELEMENTS_EXCEEDED".equals(status)) {
return new MaxElementsExceededException(errorMessage);
} else if ("NOT_FOUND".equals(status)) {
return new NotFoundException(errorMessage);
} else if ("OVER_QUERY_LIMIT".equals(status)) {
if ("You have exceeded your daily request quota for this API."
.equalsIgnoreCase(errorMessage)) {
return new OverDailyLimitException(errorMessage);
}
return new OverQueryLimitException(errorMessage);
} else if ("REQUEST_DENIED".equals(status)) {
return new RequestDeniedException(errorMessage);
} else if ("UNKNOWN_ERROR".equals(status)) {
return new UnknownErrorException(errorMessage);
} else if ("ZERO_RESULTS".equals(status)) {
return new ZeroResultsException(errorMessage);
}
// New-style Geo API error formats
if ("ACCESS_NOT_CONFIGURED".equals(status)) {
return new AccessNotConfiguredException(errorMessage);
} else if ("INVALID_ARGUMENT".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("RESOURCE_EXHAUSTED".equals(status)) {
return new OverQueryLimitException(errorMessage);
} else if ("PERMISSION_DENIED".equals(status)) {
return new RequestDeniedException(errorMessage);
}
// Geolocation Errors
if ("keyInvalid".equals(status)) {
return new AccessNotConfiguredException(errorMessage);
} else if ("dailyLimitExceeded".equals(status)) {
return new OverDailyLimitException(errorMessage);
} else if ("userRateLimitExceeded".equals(status)) {
return new OverQueryLimitException(errorMessage);
} else if ("notFound".equals(status)) {
return new NotFoundException(errorMessage);
} else if ("parseError".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("invalid".equals(status)) {
return new InvalidRequestException(errorMessage);
}
// We've hit an unknown error. This is not a state we should hit,
// but we don't want to crash a user's application if we introduce a new error.
return new UnknownErrorException(
"An unexpected error occurred. Status: " + status + ", Message: " + errorMessage);
} | java | public static ApiException from(String status, String errorMessage) {
// Classic Geo API error formats
if ("OK".equals(status)) {
return null;
} else if ("INVALID_REQUEST".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("MAX_ELEMENTS_EXCEEDED".equals(status)) {
return new MaxElementsExceededException(errorMessage);
} else if ("NOT_FOUND".equals(status)) {
return new NotFoundException(errorMessage);
} else if ("OVER_QUERY_LIMIT".equals(status)) {
if ("You have exceeded your daily request quota for this API."
.equalsIgnoreCase(errorMessage)) {
return new OverDailyLimitException(errorMessage);
}
return new OverQueryLimitException(errorMessage);
} else if ("REQUEST_DENIED".equals(status)) {
return new RequestDeniedException(errorMessage);
} else if ("UNKNOWN_ERROR".equals(status)) {
return new UnknownErrorException(errorMessage);
} else if ("ZERO_RESULTS".equals(status)) {
return new ZeroResultsException(errorMessage);
}
// New-style Geo API error formats
if ("ACCESS_NOT_CONFIGURED".equals(status)) {
return new AccessNotConfiguredException(errorMessage);
} else if ("INVALID_ARGUMENT".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("RESOURCE_EXHAUSTED".equals(status)) {
return new OverQueryLimitException(errorMessage);
} else if ("PERMISSION_DENIED".equals(status)) {
return new RequestDeniedException(errorMessage);
}
// Geolocation Errors
if ("keyInvalid".equals(status)) {
return new AccessNotConfiguredException(errorMessage);
} else if ("dailyLimitExceeded".equals(status)) {
return new OverDailyLimitException(errorMessage);
} else if ("userRateLimitExceeded".equals(status)) {
return new OverQueryLimitException(errorMessage);
} else if ("notFound".equals(status)) {
return new NotFoundException(errorMessage);
} else if ("parseError".equals(status)) {
return new InvalidRequestException(errorMessage);
} else if ("invalid".equals(status)) {
return new InvalidRequestException(errorMessage);
}
// We've hit an unknown error. This is not a state we should hit,
// but we don't want to crash a user's application if we introduce a new error.
return new UnknownErrorException(
"An unexpected error occurred. Status: " + status + ", Message: " + errorMessage);
} | [
"public",
"static",
"ApiException",
"from",
"(",
"String",
"status",
",",
"String",
"errorMessage",
")",
"{",
"// Classic Geo API error formats",
"if",
"(",
"\"OK\"",
".",
"equals",
"(",
"status",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",... | Construct the appropriate ApiException from the response. If the response was successful, this
method will return null.
@param status The status field returned from the API
@param errorMessage The error message returned from the API
@return The appropriate ApiException based on the status or null if no error occurred. | [
"Construct",
"the",
"appropriate",
"ApiException",
"from",
"the",
"response",
".",
"If",
"the",
"response",
"was",
"successful",
"this",
"method",
"will",
"return",
"null",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/errors/ApiException.java#L37-L91 |
31,345 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/internal/PolylineEncoding.java | PolylineEncoding.decode | public static List<LatLng> decode(final String encodedPath) {
int len = encodedPath.length();
final List<LatLng> path = new ArrayList<>(len / 2);
int index = 0;
int lat = 0;
int lng = 0;
while (index < len) {
int result = 1;
int shift = 0;
int b;
do {
b = encodedPath.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lat += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
result = 1;
shift = 0;
do {
b = encodedPath.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
path.add(new LatLng(lat * 1e-5, lng * 1e-5));
}
return path;
} | java | public static List<LatLng> decode(final String encodedPath) {
int len = encodedPath.length();
final List<LatLng> path = new ArrayList<>(len / 2);
int index = 0;
int lat = 0;
int lng = 0;
while (index < len) {
int result = 1;
int shift = 0;
int b;
do {
b = encodedPath.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lat += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
result = 1;
shift = 0;
do {
b = encodedPath.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
path.add(new LatLng(lat * 1e-5, lng * 1e-5));
}
return path;
} | [
"public",
"static",
"List",
"<",
"LatLng",
">",
"decode",
"(",
"final",
"String",
"encodedPath",
")",
"{",
"int",
"len",
"=",
"encodedPath",
".",
"length",
"(",
")",
";",
"final",
"List",
"<",
"LatLng",
">",
"path",
"=",
"new",
"ArrayList",
"<>",
"(",
... | Decodes an encoded path string into a sequence of LatLngs. | [
"Decodes",
"an",
"encoded",
"path",
"string",
"into",
"a",
"sequence",
"of",
"LatLngs",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/internal/PolylineEncoding.java#L32-L65 |
31,346 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/internal/PolylineEncoding.java | PolylineEncoding.encode | public static String encode(final List<LatLng> path) {
long lastLat = 0;
long lastLng = 0;
final StringBuilder result = new StringBuilder();
for (final LatLng point : path) {
long lat = Math.round(point.lat * 1e5);
long lng = Math.round(point.lng * 1e5);
long dLat = lat - lastLat;
long dLng = lng - lastLng;
encode(dLat, result);
encode(dLng, result);
lastLat = lat;
lastLng = lng;
}
return result.toString();
} | java | public static String encode(final List<LatLng> path) {
long lastLat = 0;
long lastLng = 0;
final StringBuilder result = new StringBuilder();
for (final LatLng point : path) {
long lat = Math.round(point.lat * 1e5);
long lng = Math.round(point.lng * 1e5);
long dLat = lat - lastLat;
long dLng = lng - lastLng;
encode(dLat, result);
encode(dLng, result);
lastLat = lat;
lastLng = lng;
}
return result.toString();
} | [
"public",
"static",
"String",
"encode",
"(",
"final",
"List",
"<",
"LatLng",
">",
"path",
")",
"{",
"long",
"lastLat",
"=",
"0",
";",
"long",
"lastLng",
"=",
"0",
";",
"final",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for... | Encodes a sequence of LatLngs into an encoded path string. | [
"Encodes",
"a",
"sequence",
"of",
"LatLngs",
"into",
"an",
"encoded",
"path",
"string",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/internal/PolylineEncoding.java#L68-L88 |
31,347 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.nearbySearchQuery | public static NearbySearchRequest nearbySearchQuery(GeoApiContext context, LatLng location) {
NearbySearchRequest request = new NearbySearchRequest(context);
request.location(location);
return request;
} | java | public static NearbySearchRequest nearbySearchQuery(GeoApiContext context, LatLng location) {
NearbySearchRequest request = new NearbySearchRequest(context);
request.location(location);
return request;
} | [
"public",
"static",
"NearbySearchRequest",
"nearbySearchQuery",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"location",
")",
"{",
"NearbySearchRequest",
"request",
"=",
"new",
"NearbySearchRequest",
"(",
"context",
")",
";",
"request",
".",
"location",
"(",
"loc... | Performs a search for nearby Places.
@param context The context on which to make Geo API requests.
@param location The latitude/longitude around which to retrieve place information.
@return Returns a NearbySearchRequest that can be configured and executed. | [
"Performs",
"a",
"search",
"for",
"nearby",
"Places",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L40-L44 |
31,348 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.nearbySearchNextPage | public static NearbySearchRequest nearbySearchNextPage(
GeoApiContext context, String nextPageToken) {
NearbySearchRequest request = new NearbySearchRequest(context);
request.pageToken(nextPageToken);
return request;
} | java | public static NearbySearchRequest nearbySearchNextPage(
GeoApiContext context, String nextPageToken) {
NearbySearchRequest request = new NearbySearchRequest(context);
request.pageToken(nextPageToken);
return request;
} | [
"public",
"static",
"NearbySearchRequest",
"nearbySearchNextPage",
"(",
"GeoApiContext",
"context",
",",
"String",
"nextPageToken",
")",
"{",
"NearbySearchRequest",
"request",
"=",
"new",
"NearbySearchRequest",
"(",
"context",
")",
";",
"request",
".",
"pageToken",
"(... | Retrieves the next page of Nearby Search results. The nextPageToken, returned in a
PlacesSearchResponse when there are more pages of results, encodes all of the original Nearby
Search Request parameters, which are thus not required on this call.
@param context The context on which to make Geo API requests.
@param nextPageToken The nextPageToken returned as part of a PlacesSearchResponse.
@return Returns a NearbySearchRequest that can be executed. | [
"Retrieves",
"the",
"next",
"page",
"of",
"Nearby",
"Search",
"results",
".",
"The",
"nextPageToken",
"returned",
"in",
"a",
"PlacesSearchResponse",
"when",
"there",
"are",
"more",
"pages",
"of",
"results",
"encodes",
"all",
"of",
"the",
"original",
"Nearby",
... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L55-L60 |
31,349 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.textSearchQuery | public static TextSearchRequest textSearchQuery(GeoApiContext context, String query) {
TextSearchRequest request = new TextSearchRequest(context);
request.query(query);
return request;
} | java | public static TextSearchRequest textSearchQuery(GeoApiContext context, String query) {
TextSearchRequest request = new TextSearchRequest(context);
request.query(query);
return request;
} | [
"public",
"static",
"TextSearchRequest",
"textSearchQuery",
"(",
"GeoApiContext",
"context",
",",
"String",
"query",
")",
"{",
"TextSearchRequest",
"request",
"=",
"new",
"TextSearchRequest",
"(",
"context",
")",
";",
"request",
".",
"query",
"(",
"query",
")",
... | Performs a search for Places using a text query; for example, "pizza in New York" or "shoe
stores near Ottawa".
@param context The context on which to make Geo API requests.
@param query The text string on which to search, for example: "restaurant".
@return Returns a TextSearchRequest that can be configured and executed. | [
"Performs",
"a",
"search",
"for",
"Places",
"using",
"a",
"text",
"query",
";",
"for",
"example",
"pizza",
"in",
"New",
"York",
"or",
"shoe",
"stores",
"near",
"Ottawa",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L70-L74 |
31,350 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.textSearchNextPage | public static TextSearchRequest textSearchNextPage(GeoApiContext context, String nextPageToken) {
TextSearchRequest request = new TextSearchRequest(context);
request.pageToken(nextPageToken);
return request;
} | java | public static TextSearchRequest textSearchNextPage(GeoApiContext context, String nextPageToken) {
TextSearchRequest request = new TextSearchRequest(context);
request.pageToken(nextPageToken);
return request;
} | [
"public",
"static",
"TextSearchRequest",
"textSearchNextPage",
"(",
"GeoApiContext",
"context",
",",
"String",
"nextPageToken",
")",
"{",
"TextSearchRequest",
"request",
"=",
"new",
"TextSearchRequest",
"(",
"context",
")",
";",
"request",
".",
"pageToken",
"(",
"ne... | Retrieves the next page of Text Search results. The nextPageToken, returned in a
PlacesSearchResponse when there are more pages of results, encodes all of the original Text
Search Request parameters, which are thus not required on this call.
@param context The context on which to make Geo API requests.
@param nextPageToken The nextPageToken returned as part of a PlacesSearchResponse.
@return Returns a TextSearchRequest that can be executed. | [
"Retrieves",
"the",
"next",
"page",
"of",
"Text",
"Search",
"results",
".",
"The",
"nextPageToken",
"returned",
"in",
"a",
"PlacesSearchResponse",
"when",
"there",
"are",
"more",
"pages",
"of",
"results",
"encodes",
"all",
"of",
"the",
"original",
"Text",
"Sea... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L85-L89 |
31,351 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.photo | public static PhotoRequest photo(GeoApiContext context, String photoReference) {
PhotoRequest request = new PhotoRequest(context);
request.photoReference(photoReference);
return request;
} | java | public static PhotoRequest photo(GeoApiContext context, String photoReference) {
PhotoRequest request = new PhotoRequest(context);
request.photoReference(photoReference);
return request;
} | [
"public",
"static",
"PhotoRequest",
"photo",
"(",
"GeoApiContext",
"context",
",",
"String",
"photoReference",
")",
"{",
"PhotoRequest",
"request",
"=",
"new",
"PhotoRequest",
"(",
"context",
")",
";",
"request",
".",
"photoReference",
"(",
"photoReference",
")",
... | Requests a Photo from a PhotoReference.
<p>Note: If you want to use a Photo in a web browser, please retrieve the photos for a place
via our <a
href="https://developers.google.com/maps/documentation/javascript/places#places_photos">
JavaScript Places Library</a>. Likewise, on Android, Places Photos can be retrieved using the
<a href="https://developers.google.com/places/android-api/photos">Google Places API for
Android</a>.
@param context The context on which to make Geo API requests.
@param photoReference The reference to the photo to retrieve.
@return Returns a PhotoRequest that you can execute. | [
"Requests",
"a",
"Photo",
"from",
"a",
"PhotoReference",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L144-L148 |
31,352 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.placeAutocomplete | public static PlaceAutocompleteRequest placeAutocomplete(
GeoApiContext context, String input, PlaceAutocompleteRequest.SessionToken sessionToken) {
PlaceAutocompleteRequest request = new PlaceAutocompleteRequest(context);
request.input(input);
request.sessionToken(sessionToken);
return request;
} | java | public static PlaceAutocompleteRequest placeAutocomplete(
GeoApiContext context, String input, PlaceAutocompleteRequest.SessionToken sessionToken) {
PlaceAutocompleteRequest request = new PlaceAutocompleteRequest(context);
request.input(input);
request.sessionToken(sessionToken);
return request;
} | [
"public",
"static",
"PlaceAutocompleteRequest",
"placeAutocomplete",
"(",
"GeoApiContext",
"context",
",",
"String",
"input",
",",
"PlaceAutocompleteRequest",
".",
"SessionToken",
"sessionToken",
")",
"{",
"PlaceAutocompleteRequest",
"request",
"=",
"new",
"PlaceAutocomplet... | Creates a new Places Autocomplete request for a given input. The Place Autocomplete service can
match on full words as well as substrings. Applications can therefore send queries as the user
types, to provide on-the-fly place predictions.
@param context The context on which to make Geo API requests.
@param input input is the text string on which to search.
@param sessionToken Session token, to make sure requests are billed per session, instead of per
character.
@return Returns a PlaceAutocompleteRequest that you can configure and execute. | [
"Creates",
"a",
"new",
"Places",
"Autocomplete",
"request",
"for",
"a",
"given",
"input",
".",
"The",
"Place",
"Autocomplete",
"service",
"can",
"match",
"on",
"full",
"words",
"as",
"well",
"as",
"substrings",
".",
"Applications",
"can",
"therefore",
"send",
... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L161-L167 |
31,353 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.queryAutocomplete | public static QueryAutocompleteRequest queryAutocomplete(GeoApiContext context, String input) {
QueryAutocompleteRequest request = new QueryAutocompleteRequest(context);
request.input(input);
return request;
} | java | public static QueryAutocompleteRequest queryAutocomplete(GeoApiContext context, String input) {
QueryAutocompleteRequest request = new QueryAutocompleteRequest(context);
request.input(input);
return request;
} | [
"public",
"static",
"QueryAutocompleteRequest",
"queryAutocomplete",
"(",
"GeoApiContext",
"context",
",",
"String",
"input",
")",
"{",
"QueryAutocompleteRequest",
"request",
"=",
"new",
"QueryAutocompleteRequest",
"(",
"context",
")",
";",
"request",
".",
"input",
"(... | Allows you to add on-the-fly geographic query predictions to your application.
@param context The context on which to make Geo API requests.
@param input input is the text string on which to search.
@return Returns a QueryAutocompleteRequest that you can configure and execute. | [
"Allows",
"you",
"to",
"add",
"on",
"-",
"the",
"-",
"fly",
"geographic",
"query",
"predictions",
"to",
"your",
"application",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L176-L180 |
31,354 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.findPlaceFromText | public static FindPlaceFromTextRequest findPlaceFromText(
GeoApiContext context, String input, FindPlaceFromTextRequest.InputType inputType) {
FindPlaceFromTextRequest request = new FindPlaceFromTextRequest(context);
request.input(input).inputType(inputType);
return request;
} | java | public static FindPlaceFromTextRequest findPlaceFromText(
GeoApiContext context, String input, FindPlaceFromTextRequest.InputType inputType) {
FindPlaceFromTextRequest request = new FindPlaceFromTextRequest(context);
request.input(input).inputType(inputType);
return request;
} | [
"public",
"static",
"FindPlaceFromTextRequest",
"findPlaceFromText",
"(",
"GeoApiContext",
"context",
",",
"String",
"input",
",",
"FindPlaceFromTextRequest",
".",
"InputType",
"inputType",
")",
"{",
"FindPlaceFromTextRequest",
"request",
"=",
"new",
"FindPlaceFromTextReque... | Find places using either search text, or a phone number.
@param context The context on which to make Geo API requests.
@param input The input to search on.
@param inputType Whether the input is search text, or a phone number.
@return Returns a FindPlaceFromTextRequest that you can configure and execute. | [
"Find",
"places",
"using",
"either",
"search",
"text",
"or",
"a",
"phone",
"number",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L190-L195 |
31,355 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/internal/RateLimitExecutorService.java | RateLimitExecutorService.shutdownNow | @Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = delegate.shutdownNow();
// we need this to break out of queue.take()
execute(
new Runnable() {
@Override
public void run() {
// do nothing
}
});
return tasks;
} | java | @Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = delegate.shutdownNow();
// we need this to break out of queue.take()
execute(
new Runnable() {
@Override
public void run() {
// do nothing
}
});
return tasks;
} | [
"@",
"Override",
"public",
"List",
"<",
"Runnable",
">",
"shutdownNow",
"(",
")",
"{",
"List",
"<",
"Runnable",
">",
"tasks",
"=",
"delegate",
".",
"shutdownNow",
"(",
")",
";",
"// we need this to break out of queue.take()",
"execute",
"(",
"new",
"Runnable",
... | Everything below here is straight delegation. | [
"Everything",
"below",
"here",
"is",
"straight",
"delegation",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/internal/RateLimitExecutorService.java#L119-L131 |
31,356 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/internal/UrlSigner.java | UrlSigner.getSignature | public String getSignature(String path) {
byte[] digest = getMac().doFinal(path.getBytes(UTF_8));
return ByteString.of(digest).base64().replace('+', '-').replace('/', '_');
} | java | public String getSignature(String path) {
byte[] digest = getMac().doFinal(path.getBytes(UTF_8));
return ByteString.of(digest).base64().replace('+', '-').replace('/', '_');
} | [
"public",
"String",
"getSignature",
"(",
"String",
"path",
")",
"{",
"byte",
"[",
"]",
"digest",
"=",
"getMac",
"(",
")",
".",
"doFinal",
"(",
"path",
".",
"getBytes",
"(",
"UTF_8",
")",
")",
";",
"return",
"ByteString",
".",
"of",
"(",
"digest",
")"... | Generate url safe HmacSHA1 of a path. | [
"Generate",
"url",
"safe",
"HmacSHA1",
"of",
"a",
"path",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/internal/UrlSigner.java#L52-L55 |
31,357 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.snapToRoads | public static PendingResult<SnappedPoint[]> snapToRoads(GeoApiContext context, LatLng... path) {
return context.get(SNAP_TO_ROADS_API_CONFIG, RoadsResponse.class, "path", join('|', path));
} | java | public static PendingResult<SnappedPoint[]> snapToRoads(GeoApiContext context, LatLng... path) {
return context.get(SNAP_TO_ROADS_API_CONFIG, RoadsResponse.class, "path", join('|', path));
} | [
"public",
"static",
"PendingResult",
"<",
"SnappedPoint",
"[",
"]",
">",
"snapToRoads",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"...",
"path",
")",
"{",
"return",
"context",
".",
"get",
"(",
"SNAP_TO_ROADS_API_CONFIG",
",",
"RoadsResponse",
".",
"class",... | Takes up to 100 GPS points collected along a route, and returns a similar set of data with the
points snapped to the most likely roads the vehicle was traveling along.
@param context The {@link GeoApiContext} to make requests through.
@param path The collected GPS points as a path.
@return Returns the snapped points as a {@link PendingResult}. | [
"Takes",
"up",
"to",
"100",
"GPS",
"points",
"collected",
"along",
"a",
"route",
"and",
"returns",
"a",
"similar",
"set",
"of",
"data",
"with",
"the",
"points",
"snapped",
"to",
"the",
"most",
"likely",
"roads",
"the",
"vehicle",
"was",
"traveling",
"along... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L68-L70 |
31,358 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.snapToRoads | public static PendingResult<SnappedPoint[]> snapToRoads(
GeoApiContext context, boolean interpolate, LatLng... path) {
return context.get(
SNAP_TO_ROADS_API_CONFIG,
RoadsResponse.class,
"path",
join('|', path),
"interpolate",
String.valueOf(interpolate));
} | java | public static PendingResult<SnappedPoint[]> snapToRoads(
GeoApiContext context, boolean interpolate, LatLng... path) {
return context.get(
SNAP_TO_ROADS_API_CONFIG,
RoadsResponse.class,
"path",
join('|', path),
"interpolate",
String.valueOf(interpolate));
} | [
"public",
"static",
"PendingResult",
"<",
"SnappedPoint",
"[",
"]",
">",
"snapToRoads",
"(",
"GeoApiContext",
"context",
",",
"boolean",
"interpolate",
",",
"LatLng",
"...",
"path",
")",
"{",
"return",
"context",
".",
"get",
"(",
"SNAP_TO_ROADS_API_CONFIG",
",",... | Takes up to 100 GPS points collected along a route, and returns a similar set of data with the
points snapped to the most likely roads the vehicle was traveling along. Additionally, you can
request that the points be interpolated, resulting in a path that smoothly follows the geometry
of the road.
@param context The {@link GeoApiContext} to make requests through.
@param interpolate Whether to interpolate a path to include all points forming the full
road-geometry. When true, additional interpolated points will also be returned, resulting
in a path that smoothly follows the geometry of the road, even around corners and through
tunnels.
@param path The path to be snapped.
@return Returns the snapped points as a {@link PendingResult}. | [
"Takes",
"up",
"to",
"100",
"GPS",
"points",
"collected",
"along",
"a",
"route",
"and",
"returns",
"a",
"similar",
"set",
"of",
"data",
"with",
"the",
"points",
"snapped",
"to",
"the",
"most",
"likely",
"roads",
"the",
"vehicle",
"was",
"traveling",
"along... | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L86-L95 |
31,359 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.speedLimits | public static PendingResult<SpeedLimit[]> speedLimits(GeoApiContext context, LatLng... path) {
return context.get(SPEEDS_API_CONFIG, SpeedsResponse.class, "path", join('|', path));
} | java | public static PendingResult<SpeedLimit[]> speedLimits(GeoApiContext context, LatLng... path) {
return context.get(SPEEDS_API_CONFIG, SpeedsResponse.class, "path", join('|', path));
} | [
"public",
"static",
"PendingResult",
"<",
"SpeedLimit",
"[",
"]",
">",
"speedLimits",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"...",
"path",
")",
"{",
"return",
"context",
".",
"get",
"(",
"SPEEDS_API_CONFIG",
",",
"SpeedsResponse",
".",
"class",
",",
... | Returns the posted speed limit for given road segments. The provided LatLngs will first be
snapped to the most likely roads the vehicle was traveling along.
<p>Note: The accuracy of speed limit data returned by the Google Maps Roads API cannot be
guaranteed. Speed limit data provided is not real-time, and may be estimated, inaccurate,
incomplete, and/or outdated. Inaccuracies in our data may be reported through <a
href="https://www.localguidesconnect.com/t5/News-Updates/Exclusive-Edit-a-road-segment-in-Google-Maps/ba-p/149865">
Google Maps Feedback</a>.
@param context The {@link GeoApiContext} to make requests through.
@param path The collected GPS points as a path.
@return Returns the speed limits as a {@link PendingResult}. | [
"Returns",
"the",
"posted",
"speed",
"limit",
"for",
"given",
"road",
"segments",
".",
"The",
"provided",
"LatLngs",
"will",
"first",
"be",
"snapped",
"to",
"the",
"most",
"likely",
"roads",
"the",
"vehicle",
"was",
"traveling",
"along",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L111-L113 |
31,360 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.speedLimits | public static PendingResult<SpeedLimit[]> speedLimits(GeoApiContext context, String... placeIds) {
String[] placeParams = new String[2 * placeIds.length];
int i = 0;
for (String placeId : placeIds) {
placeParams[i++] = "placeId";
placeParams[i++] = placeId;
}
return context.get(SPEEDS_API_CONFIG, SpeedsResponse.class, placeParams);
} | java | public static PendingResult<SpeedLimit[]> speedLimits(GeoApiContext context, String... placeIds) {
String[] placeParams = new String[2 * placeIds.length];
int i = 0;
for (String placeId : placeIds) {
placeParams[i++] = "placeId";
placeParams[i++] = placeId;
}
return context.get(SPEEDS_API_CONFIG, SpeedsResponse.class, placeParams);
} | [
"public",
"static",
"PendingResult",
"<",
"SpeedLimit",
"[",
"]",
">",
"speedLimits",
"(",
"GeoApiContext",
"context",
",",
"String",
"...",
"placeIds",
")",
"{",
"String",
"[",
"]",
"placeParams",
"=",
"new",
"String",
"[",
"2",
"*",
"placeIds",
".",
"len... | Returns the posted speed limit for given road segments.
<p>Note: The accuracy of speed limit data returned by the Google Maps Roads API cannot be
guaranteed. Speed limit data provided is not real-time, and may be estimated, inaccurate,
incomplete, and/or outdated. Inaccuracies in our data may be reported through <a
href="https://www.localguidesconnect.com/t5/News-Updates/Exclusive-Edit-a-road-segment-in-Google-Maps/ba-p/149865">
Google Maps Feedback</a>.
@param context The {@link GeoApiContext} to make requests through.
@param placeIds The Place ID of the road segment. Place IDs are returned by the {@link
#snapToRoads(GeoApiContext, com.google.maps.model.LatLng...)} method. You can pass up to
100 placeIds with each request.
@return Returns the speed limits as a {@link PendingResult}. | [
"Returns",
"the",
"posted",
"speed",
"limit",
"for",
"given",
"road",
"segments",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L130-L139 |
31,361 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.snappedSpeedLimits | public static PendingResult<SnappedSpeedLimitResponse> snappedSpeedLimits(
GeoApiContext context, LatLng... path) {
return context.get(SPEEDS_API_CONFIG, CombinedResponse.class, "path", join('|', path));
} | java | public static PendingResult<SnappedSpeedLimitResponse> snappedSpeedLimits(
GeoApiContext context, LatLng... path) {
return context.get(SPEEDS_API_CONFIG, CombinedResponse.class, "path", join('|', path));
} | [
"public",
"static",
"PendingResult",
"<",
"SnappedSpeedLimitResponse",
">",
"snappedSpeedLimits",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"...",
"path",
")",
"{",
"return",
"context",
".",
"get",
"(",
"SPEEDS_API_CONFIG",
",",
"CombinedResponse",
".",
"class... | Returns the result of snapping the provided points to roads and retrieving the speed limits.
@param context The {@link GeoApiContext} to make requests through.
@param path The collected GPS points as a path.
@return Returns the snapped points and speed limits as a {@link PendingResult}. | [
"Returns",
"the",
"result",
"of",
"snapping",
"the",
"provided",
"points",
"to",
"roads",
"and",
"retrieving",
"the",
"speed",
"limits",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L148-L151 |
31,362 | googlemaps/google-maps-services-java | src/main/java/com/google/maps/RoadsApi.java | RoadsApi.nearestRoads | public static PendingResult<SnappedPoint[]> nearestRoads(
GeoApiContext context, LatLng... points) {
return context.get(NEAREST_ROADS_API_CONFIG, RoadsResponse.class, "points", join('|', points));
} | java | public static PendingResult<SnappedPoint[]> nearestRoads(
GeoApiContext context, LatLng... points) {
return context.get(NEAREST_ROADS_API_CONFIG, RoadsResponse.class, "points", join('|', points));
} | [
"public",
"static",
"PendingResult",
"<",
"SnappedPoint",
"[",
"]",
">",
"nearestRoads",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"...",
"points",
")",
"{",
"return",
"context",
".",
"get",
"(",
"NEAREST_ROADS_API_CONFIG",
",",
"RoadsResponse",
".",
"clas... | Takes up to 100 GPS points, and returns the closest road segment for each point. The points
passed do not need to be part of a continuous path.
@param context The {@link GeoApiContext} to make requests through.
@param points The sequence of points to be aligned to nearest roads
@return Returns the snapped points as a {@link PendingResult}. | [
"Takes",
"up",
"to",
"100",
"GPS",
"points",
"and",
"returns",
"the",
"closest",
"road",
"segment",
"for",
"each",
"point",
".",
"The",
"points",
"passed",
"do",
"not",
"need",
"to",
"be",
"part",
"of",
"a",
"continuous",
"path",
"."
] | 23d20d1930f80e310d856d2da51d72ee0db4476b | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/RoadsApi.java#L161-L164 |
31,363 | remkop/picocli | src/main/java/picocli/CommandLine.java | CommandLine.setInterpolateVariables | public CommandLine setInterpolateVariables(boolean interpolate) {
getCommandSpec().interpolateVariables(interpolate);
for (CommandLine command : getCommandSpec().subcommands().values()) {
command.setInterpolateVariables(interpolate);
}
return this;
} | java | public CommandLine setInterpolateVariables(boolean interpolate) {
getCommandSpec().interpolateVariables(interpolate);
for (CommandLine command : getCommandSpec().subcommands().values()) {
command.setInterpolateVariables(interpolate);
}
return this;
} | [
"public",
"CommandLine",
"setInterpolateVariables",
"(",
"boolean",
"interpolate",
")",
"{",
"getCommandSpec",
"(",
")",
".",
"interpolateVariables",
"(",
"interpolate",
")",
";",
"for",
"(",
"CommandLine",
"command",
":",
"getCommandSpec",
"(",
")",
".",
"subcomm... | Sets whether whether variables should be interpolated in String values.
@since 4.0 | [
"Sets",
"whether",
"whether",
"variables",
"should",
"be",
"interpolated",
"in",
"String",
"values",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/src/main/java/picocli/CommandLine.java#L507-L513 |
31,364 | remkop/picocli | src/main/java/picocli/CommandLine.java | CommandLine.setEndOfOptionsDelimiter | public CommandLine setEndOfOptionsDelimiter(String delimiter) {
getCommandSpec().parser().endOfOptionsDelimiter(delimiter);
for (CommandLine command : getCommandSpec().subcommands().values()) {
command.setEndOfOptionsDelimiter(delimiter);
}
return this;
} | java | public CommandLine setEndOfOptionsDelimiter(String delimiter) {
getCommandSpec().parser().endOfOptionsDelimiter(delimiter);
for (CommandLine command : getCommandSpec().subcommands().values()) {
command.setEndOfOptionsDelimiter(delimiter);
}
return this;
} | [
"public",
"CommandLine",
"setEndOfOptionsDelimiter",
"(",
"String",
"delimiter",
")",
"{",
"getCommandSpec",
"(",
")",
".",
"parser",
"(",
")",
".",
"endOfOptionsDelimiter",
"(",
"delimiter",
")",
";",
"for",
"(",
"CommandLine",
"command",
":",
"getCommandSpec",
... | Sets the end-of-options delimiter that signals that the remaining command line arguments should be treated as positional parameters.
@param delimiter the end-of-options delimiter; must not be {@code null}. The default is {@code "--"}.
@return this {@code CommandLine} object, to allow method chaining
@since 3.5 | [
"Sets",
"the",
"end",
"-",
"of",
"-",
"options",
"delimiter",
"that",
"signals",
"that",
"the",
"remaining",
"command",
"line",
"arguments",
"should",
"be",
"treated",
"as",
"positional",
"parameters",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/src/main/java/picocli/CommandLine.java#L652-L658 |
31,365 | remkop/picocli | src/main/java/picocli/CommandLine.java | CommandLine.getUnmatchedArguments | public List<String> getUnmatchedArguments() {
return interpreter.parseResultBuilder == null ? Collections.<String>emptyList() : UnmatchedArgumentException.stripErrorMessage(interpreter.parseResultBuilder.unmatched);
} | java | public List<String> getUnmatchedArguments() {
return interpreter.parseResultBuilder == null ? Collections.<String>emptyList() : UnmatchedArgumentException.stripErrorMessage(interpreter.parseResultBuilder.unmatched);
} | [
"public",
"List",
"<",
"String",
">",
"getUnmatchedArguments",
"(",
")",
"{",
"return",
"interpreter",
".",
"parseResultBuilder",
"==",
"null",
"?",
"Collections",
".",
"<",
"String",
">",
"emptyList",
"(",
")",
":",
"UnmatchedArgumentException",
".",
"stripErro... | Returns the list of unmatched command line arguments, if any.
@return the list of unmatched command line arguments or an empty list
@see #isUnmatchedArgumentsAllowed()
@since 0.9.7 | [
"Returns",
"the",
"list",
"of",
"unmatched",
"command",
"line",
"arguments",
"if",
"any",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/src/main/java/picocli/CommandLine.java#L816-L818 |
31,366 | remkop/picocli | src/main/java/picocli/CommandLine.java | CommandLine.setColorScheme | public CommandLine setColorScheme(Help.ColorScheme colorScheme) {
this.colorScheme = Assert.notNull(colorScheme, "colorScheme");
for (CommandLine sub : getSubcommands().values()) { sub.setColorScheme(colorScheme); }
return this;
} | java | public CommandLine setColorScheme(Help.ColorScheme colorScheme) {
this.colorScheme = Assert.notNull(colorScheme, "colorScheme");
for (CommandLine sub : getSubcommands().values()) { sub.setColorScheme(colorScheme); }
return this;
} | [
"public",
"CommandLine",
"setColorScheme",
"(",
"Help",
".",
"ColorScheme",
"colorScheme",
")",
"{",
"this",
".",
"colorScheme",
"=",
"Assert",
".",
"notNull",
"(",
"colorScheme",
",",
"\"colorScheme\"",
")",
";",
"for",
"(",
"CommandLine",
"sub",
":",
"getSub... | Sets the color scheme to use when printing help.
@param colorScheme the new color scheme
@see #execute(String...)
@see #usage(PrintStream)
@see #usage(PrintWriter)
@see #getUsageMessage()
@since 4.0 | [
"Sets",
"the",
"color",
"scheme",
"to",
"use",
"when",
"printing",
"help",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/src/main/java/picocli/CommandLine.java#L919-L923 |
31,367 | remkop/picocli | picocli-codegen/src/main/java/picocli/codegen/util/TypeImporter.java | TypeImporter.shouldImport | private boolean shouldImport(TypeName typeName) {
// don't import classes from the java.lang package
String pkg = typeName.getPackageName();
String simpleName = typeName.getSimpleName();
boolean exclude = (pkg.equals("java.lang") || pkg.equals("")) && getJavaDefaultTypes().contains(simpleName);
return !exclude;
} | java | private boolean shouldImport(TypeName typeName) {
// don't import classes from the java.lang package
String pkg = typeName.getPackageName();
String simpleName = typeName.getSimpleName();
boolean exclude = (pkg.equals("java.lang") || pkg.equals("")) && getJavaDefaultTypes().contains(simpleName);
return !exclude;
} | [
"private",
"boolean",
"shouldImport",
"(",
"TypeName",
"typeName",
")",
"{",
"// don't import classes from the java.lang package",
"String",
"pkg",
"=",
"typeName",
".",
"getPackageName",
"(",
")",
";",
"String",
"simpleName",
"=",
"typeName",
".",
"getSimpleName",
"(... | Determines whether the given non-wildcard import should be added.
By default, this returns false if the simple name is a built-in Java language type name. | [
"Determines",
"whether",
"the",
"given",
"non",
"-",
"wildcard",
"import",
"should",
"be",
"added",
".",
"By",
"default",
"this",
"returns",
"false",
"if",
"the",
"simple",
"name",
"is",
"a",
"built",
"-",
"in",
"Java",
"language",
"type",
"name",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/picocli-codegen/src/main/java/picocli/codegen/util/TypeImporter.java#L128-L134 |
31,368 | remkop/picocli | picocli-codegen/src/main/java/picocli/codegen/util/TypeImporter.java | TypeImporter.createImportDeclaration | public String createImportDeclaration(String lineDelimiter) {
StringBuilder result = new StringBuilder();
for (TypeName importName : getImports()) {
result.append(lineDelimiter + "import " + importName + ";");
}
return result.toString();
} | java | public String createImportDeclaration(String lineDelimiter) {
StringBuilder result = new StringBuilder();
for (TypeName importName : getImports()) {
result.append(lineDelimiter + "import " + importName + ";");
}
return result.toString();
} | [
"public",
"String",
"createImportDeclaration",
"(",
"String",
"lineDelimiter",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"TypeName",
"importName",
":",
"getImports",
"(",
")",
")",
"{",
"result",
".",
"append"... | Returns a string with the import declarations to add to the class,
using the specified line separator to separate import lines. | [
"Returns",
"a",
"string",
"with",
"the",
"import",
"declarations",
"to",
"add",
"to",
"the",
"class",
"using",
"the",
"specified",
"line",
"separator",
"to",
"separate",
"import",
"lines",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/picocli-codegen/src/main/java/picocli/codegen/util/TypeImporter.java#L269-L275 |
31,369 | remkop/picocli | picocli-codegen/src/main/java/picocli/codegen/util/Assert.java | Assert.notNull | public static <T> T notNull(T object, String description) {
if (object == null) {
throw new NullPointerException(description);
}
return object;
} | java | public static <T> T notNull(T object, String description) {
if (object == null) {
throw new NullPointerException(description);
}
return object;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"notNull",
"(",
"T",
"object",
",",
"String",
"description",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"description",
")",
";",
"}",
"return",
"object",
"... | Throws a NullPointerException if the specified object is null.
@param object the object to verify
@param description error message
@param <T> type of the object to check
@return the verified object | [
"Throws",
"a",
"NullPointerException",
"if",
"the",
"specified",
"object",
"is",
"null",
"."
] | 3c5384f0d12817401d1921c3013c1282e2edcab2 | https://github.com/remkop/picocli/blob/3c5384f0d12817401d1921c3013c1282e2edcab2/picocli-codegen/src/main/java/picocli/codegen/util/Assert.java#L14-L19 |
31,370 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/objects/date/StrftimeFormatter.java | StrftimeFormatter.toJavaDateTimeFormat | public static String toJavaDateTimeFormat(String strftime) {
if (!StringUtils.contains(strftime, '%')) {
return replaceL(strftime);
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < strftime.length(); i++) {
char c = strftime.charAt(i);
if (c == '%') {
c = strftime.charAt(++i);
boolean stripLeadingZero = false;
if (c == '-') {
stripLeadingZero = true;
c = strftime.charAt(++i);
}
if (stripLeadingZero) {
result.append(CONVERSIONS[c].substring(1));
} else {
result.append(CONVERSIONS[c]);
}
} else if (Character.isLetter(c)) {
result.append("'");
while (Character.isLetter(c)) {
result.append(c);
if (++i < strftime.length()) {
c = strftime.charAt(i);
} else {
c = 0;
}
}
result.append("'");
--i; // re-consume last char
} else {
result.append(c);
}
}
return replaceL(result.toString());
} | java | public static String toJavaDateTimeFormat(String strftime) {
if (!StringUtils.contains(strftime, '%')) {
return replaceL(strftime);
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < strftime.length(); i++) {
char c = strftime.charAt(i);
if (c == '%') {
c = strftime.charAt(++i);
boolean stripLeadingZero = false;
if (c == '-') {
stripLeadingZero = true;
c = strftime.charAt(++i);
}
if (stripLeadingZero) {
result.append(CONVERSIONS[c].substring(1));
} else {
result.append(CONVERSIONS[c]);
}
} else if (Character.isLetter(c)) {
result.append("'");
while (Character.isLetter(c)) {
result.append(c);
if (++i < strftime.length()) {
c = strftime.charAt(i);
} else {
c = 0;
}
}
result.append("'");
--i; // re-consume last char
} else {
result.append(c);
}
}
return replaceL(result.toString());
} | [
"public",
"static",
"String",
"toJavaDateTimeFormat",
"(",
"String",
"strftime",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"contains",
"(",
"strftime",
",",
"'",
"'",
")",
")",
"{",
"return",
"replaceL",
"(",
"strftime",
")",
";",
"}",
"StringBuilder",... | Parses a string in python strftime format, returning the equivalent string in java date time format.
@param strftime
@return date formatted as string | [
"Parses",
"a",
"string",
"in",
"python",
"strftime",
"format",
"returning",
"the",
"equivalent",
"string",
"in",
"java",
"date",
"time",
"format",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/objects/date/StrftimeFormatter.java#L60-L101 |
31,371 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/Jinjava.java | Jinjava.render | public String render(String template, Map<String, ?> bindings) {
RenderResult result = renderForResult(template, bindings);
List<TemplateError> fatalErrors = result.getErrors().stream()
.filter(error -> error.getSeverity() == ErrorType.FATAL)
.collect(Collectors.toList());
if (!fatalErrors.isEmpty()) {
throw new FatalTemplateErrorsException(template, fatalErrors);
}
return result.getOutput();
} | java | public String render(String template, Map<String, ?> bindings) {
RenderResult result = renderForResult(template, bindings);
List<TemplateError> fatalErrors = result.getErrors().stream()
.filter(error -> error.getSeverity() == ErrorType.FATAL)
.collect(Collectors.toList());
if (!fatalErrors.isEmpty()) {
throw new FatalTemplateErrorsException(template, fatalErrors);
}
return result.getOutput();
} | [
"public",
"String",
"render",
"(",
"String",
"template",
",",
"Map",
"<",
"String",
",",
"?",
">",
"bindings",
")",
"{",
"RenderResult",
"result",
"=",
"renderForResult",
"(",
"template",
",",
"bindings",
")",
";",
"List",
"<",
"TemplateError",
">",
"fatal... | Render the given template using the given context bindings.
@param template
jinja source template
@param bindings
map of objects to put into scope for this rendering action
@return the rendered template
@throws InterpretException
if any syntax errors were encountered during rendering | [
"Render",
"the",
"given",
"template",
"using",
"the",
"given",
"context",
"bindings",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/Jinjava.java#L149-L161 |
31,372 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/interpret/Context.java | Context.addResolvedFrom | public void addResolvedFrom(Context context) {
context.getResolvedExpressions().forEach(this::addResolvedExpression);
context.getResolvedFunctions().forEach(this::addResolvedFunction);
context.getResolvedValues().forEach(this::addResolvedValue);
} | java | public void addResolvedFrom(Context context) {
context.getResolvedExpressions().forEach(this::addResolvedExpression);
context.getResolvedFunctions().forEach(this::addResolvedFunction);
context.getResolvedValues().forEach(this::addResolvedValue);
} | [
"public",
"void",
"addResolvedFrom",
"(",
"Context",
"context",
")",
"{",
"context",
".",
"getResolvedExpressions",
"(",
")",
".",
"forEach",
"(",
"this",
"::",
"addResolvedExpression",
")",
";",
"context",
".",
"getResolvedFunctions",
"(",
")",
".",
"forEach",
... | Take all resolved strings from a context object and apply them to this context.
Useful for passing resolved values up a tag hierarchy.
@param context - context object to apply resolved values from. | [
"Take",
"all",
"resolved",
"strings",
"from",
"a",
"context",
"object",
"and",
"apply",
"them",
"to",
"this",
"context",
".",
"Useful",
"for",
"passing",
"resolved",
"values",
"up",
"a",
"tag",
"hierarchy",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/interpret/Context.java#L268-L272 |
31,373 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java | JinjavaInterpreter.renderFlat | public String renderFlat(String template) {
int depth = context.getRenderDepth();
try {
if (depth > config.getMaxRenderDepth()) {
ENGINE_LOG.warn("Max render depth exceeded: {}", Integer.toString(depth));
return template;
} else {
context.setRenderDepth(depth + 1);
return render(parse(template), false);
}
} finally {
context.setRenderDepth(depth);
}
} | java | public String renderFlat(String template) {
int depth = context.getRenderDepth();
try {
if (depth > config.getMaxRenderDepth()) {
ENGINE_LOG.warn("Max render depth exceeded: {}", Integer.toString(depth));
return template;
} else {
context.setRenderDepth(depth + 1);
return render(parse(template), false);
}
} finally {
context.setRenderDepth(depth);
}
} | [
"public",
"String",
"renderFlat",
"(",
"String",
"template",
")",
"{",
"int",
"depth",
"=",
"context",
".",
"getRenderDepth",
"(",
")",
";",
"try",
"{",
"if",
"(",
"depth",
">",
"config",
".",
"getMaxRenderDepth",
"(",
")",
")",
"{",
"ENGINE_LOG",
".",
... | Parse the given string into a root Node, and then render it without processing any extend parents.
This method should be used when the template is known to not have any extends or block tags.
@param template
string to parse
@return rendered result | [
"Parse",
"the",
"given",
"string",
"into",
"a",
"root",
"Node",
"and",
"then",
"render",
"it",
"without",
"processing",
"any",
"extend",
"parents",
".",
"This",
"method",
"should",
"be",
"used",
"when",
"the",
"template",
"is",
"known",
"to",
"not",
"have"... | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java#L181-L195 |
31,374 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java | JinjavaInterpreter.render | public String render(String template) {
ENGINE_LOG.debug(template);
return render(parse(template), true);
} | java | public String render(String template) {
ENGINE_LOG.debug(template);
return render(parse(template), true);
} | [
"public",
"String",
"render",
"(",
"String",
"template",
")",
"{",
"ENGINE_LOG",
".",
"debug",
"(",
"template",
")",
";",
"return",
"render",
"(",
"parse",
"(",
"template",
")",
",",
"true",
")",
";",
"}"
] | Parse the given string into a root Node, and then renders it processing extend parents.
@param template
string to parse
@return rendered result | [
"Parse",
"the",
"given",
"string",
"into",
"a",
"root",
"Node",
"and",
"then",
"renders",
"it",
"processing",
"extend",
"parents",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java#L204-L207 |
31,375 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java | JinjavaInterpreter.render | public String render(Node root, boolean processExtendRoots) {
OutputList output = new OutputList(config.getMaxOutputSize());
for (Node node : root.getChildren()) {
lineNumber = node.getLineNumber();
position = node.getStartPosition();
String renderStr = node.getMaster().getImage();
if (context.doesRenderStackContain(renderStr)) {
// This is a circular rendering. Stop rendering it here.
addError(new TemplateError(ErrorType.WARNING, ErrorReason.EXCEPTION, ErrorItem.TAG,
"Rendering cycle detected: '" + renderStr + "'", null, getLineNumber(), node.getStartPosition(),
null, BasicTemplateErrorCategory.IMPORT_CYCLE_DETECTED, ImmutableMap.of("string", renderStr)));
output.addNode(new RenderedOutputNode(renderStr));
} else {
OutputNode out;
context.pushRenderStack(renderStr);
try {
out = node.render(this);
} catch (DeferredValueException e) {
out = new RenderedOutputNode(node.getMaster().getImage());
}
context.popRenderStack();
output.addNode(out);
}
}
// render all extend parents, keeping the last as the root output
if (processExtendRoots) {
while (!extendParentRoots.isEmpty()) {
context.getCurrentPathStack().push(context.getExtendPathStack().peek().orElse(""), lineNumber, position);
Node parentRoot = extendParentRoots.removeFirst();
output = new OutputList(config.getMaxOutputSize());
for (Node node : parentRoot.getChildren()) {
OutputNode out = node.render(this);
output.addNode(out);
}
context.getExtendPathStack().pop();
context.getCurrentPathStack().pop();
}
}
resolveBlockStubs(output);
return output.getValue();
} | java | public String render(Node root, boolean processExtendRoots) {
OutputList output = new OutputList(config.getMaxOutputSize());
for (Node node : root.getChildren()) {
lineNumber = node.getLineNumber();
position = node.getStartPosition();
String renderStr = node.getMaster().getImage();
if (context.doesRenderStackContain(renderStr)) {
// This is a circular rendering. Stop rendering it here.
addError(new TemplateError(ErrorType.WARNING, ErrorReason.EXCEPTION, ErrorItem.TAG,
"Rendering cycle detected: '" + renderStr + "'", null, getLineNumber(), node.getStartPosition(),
null, BasicTemplateErrorCategory.IMPORT_CYCLE_DETECTED, ImmutableMap.of("string", renderStr)));
output.addNode(new RenderedOutputNode(renderStr));
} else {
OutputNode out;
context.pushRenderStack(renderStr);
try {
out = node.render(this);
} catch (DeferredValueException e) {
out = new RenderedOutputNode(node.getMaster().getImage());
}
context.popRenderStack();
output.addNode(out);
}
}
// render all extend parents, keeping the last as the root output
if (processExtendRoots) {
while (!extendParentRoots.isEmpty()) {
context.getCurrentPathStack().push(context.getExtendPathStack().peek().orElse(""), lineNumber, position);
Node parentRoot = extendParentRoots.removeFirst();
output = new OutputList(config.getMaxOutputSize());
for (Node node : parentRoot.getChildren()) {
OutputNode out = node.render(this);
output.addNode(out);
}
context.getExtendPathStack().pop();
context.getCurrentPathStack().pop();
}
}
resolveBlockStubs(output);
return output.getValue();
} | [
"public",
"String",
"render",
"(",
"Node",
"root",
",",
"boolean",
"processExtendRoots",
")",
"{",
"OutputList",
"output",
"=",
"new",
"OutputList",
"(",
"config",
".",
"getMaxOutputSize",
"(",
")",
")",
";",
"for",
"(",
"Node",
"node",
":",
"root",
".",
... | Render the given root node using this interpreter's current context
@param root
node to render
@param processExtendRoots
if true, also render all extend parents
@return rendered result | [
"Render",
"the",
"given",
"root",
"node",
"using",
"this",
"interpreter",
"s",
"current",
"context"
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java#L229-L275 |
31,376 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java | JinjavaInterpreter.retraceVariable | public Object retraceVariable(String variable, int lineNumber, int startPosition) {
if (StringUtils.isBlank(variable)) {
return "";
}
Variable var = new Variable(this, variable);
String varName = var.getName();
Object obj = context.get(varName);
if (obj != null) {
if (obj instanceof DeferredValue) {
throw new DeferredValueException(variable, lineNumber, startPosition);
}
obj = var.resolve(obj);
} else if (getConfig().isFailOnUnknownTokens()) {
throw new UnknownTokenException(variable, lineNumber, startPosition);
}
return obj;
} | java | public Object retraceVariable(String variable, int lineNumber, int startPosition) {
if (StringUtils.isBlank(variable)) {
return "";
}
Variable var = new Variable(this, variable);
String varName = var.getName();
Object obj = context.get(varName);
if (obj != null) {
if (obj instanceof DeferredValue) {
throw new DeferredValueException(variable, lineNumber, startPosition);
}
obj = var.resolve(obj);
} else if (getConfig().isFailOnUnknownTokens()) {
throw new UnknownTokenException(variable, lineNumber, startPosition);
}
return obj;
} | [
"public",
"Object",
"retraceVariable",
"(",
"String",
"variable",
",",
"int",
"lineNumber",
",",
"int",
"startPosition",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"variable",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"Variable",
"var",
"=",... | Resolve a variable from the interpreter context, returning null if not found. This method updates the template error accumulators when a variable is not found.
@param variable
name of variable in context
@param lineNumber
current line number, for error reporting
@param startPosition
current line position, for error reporting
@return resolved value for variable | [
"Resolve",
"a",
"variable",
"from",
"the",
"interpreter",
"context",
"returning",
"null",
"if",
"not",
"found",
".",
"This",
"method",
"updates",
"the",
"template",
"error",
"accumulators",
"when",
"a",
"variable",
"is",
"not",
"found",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java#L325-L341 |
31,377 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java | TagToken.parse | @Override
protected void parse() {
if (image.length() < 4) {
throw new TemplateSyntaxException(image, "Malformed tag token", getLineNumber(), getStartPosition());
}
content = image.substring(2, image.length() - 2);
if (WhitespaceUtils.startsWith(content, "-")) {
setLeftTrim(true);
content = WhitespaceUtils.unwrap(content, "-", "");
}
if (WhitespaceUtils.endsWith(content, "-")) {
setRightTrim(true);
content = WhitespaceUtils.unwrap(content, "", "-");
}
int nameStart = -1, pos = 0, len = content.length();
for (; pos < len; pos++) {
char c = content.charAt(pos);
if (nameStart == -1 && Character.isJavaIdentifierStart(c)) {
nameStart = pos;
}
else if (nameStart != -1 && !Character.isJavaIdentifierPart(c)) {
break;
}
}
if (pos < content.length()) {
rawTagName = content.substring(nameStart, pos);
helpers = content.substring(pos);
} else {
rawTagName = content.trim();
helpers = "";
}
tagName = rawTagName.toLowerCase();
} | java | @Override
protected void parse() {
if (image.length() < 4) {
throw new TemplateSyntaxException(image, "Malformed tag token", getLineNumber(), getStartPosition());
}
content = image.substring(2, image.length() - 2);
if (WhitespaceUtils.startsWith(content, "-")) {
setLeftTrim(true);
content = WhitespaceUtils.unwrap(content, "-", "");
}
if (WhitespaceUtils.endsWith(content, "-")) {
setRightTrim(true);
content = WhitespaceUtils.unwrap(content, "", "-");
}
int nameStart = -1, pos = 0, len = content.length();
for (; pos < len; pos++) {
char c = content.charAt(pos);
if (nameStart == -1 && Character.isJavaIdentifierStart(c)) {
nameStart = pos;
}
else if (nameStart != -1 && !Character.isJavaIdentifierPart(c)) {
break;
}
}
if (pos < content.length()) {
rawTagName = content.substring(nameStart, pos);
helpers = content.substring(pos);
} else {
rawTagName = content.trim();
helpers = "";
}
tagName = rawTagName.toLowerCase();
} | [
"@",
"Override",
"protected",
"void",
"parse",
"(",
")",
"{",
"if",
"(",
"image",
".",
"length",
"(",
")",
"<",
"4",
")",
"{",
"throw",
"new",
"TemplateSyntaxException",
"(",
"image",
",",
"\"Malformed tag token\"",
",",
"getLineNumber",
"(",
")",
",",
"... | Get tag name | [
"Get",
"tag",
"name"
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java#L43-L80 |
31,378 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/el/ext/JinjavaBeanELResolver.java | JinjavaBeanELResolver.transformPropertyName | private String transformPropertyName(Object property) {
if (property == null) {
return null;
}
String propertyStr = property.toString();
if (propertyStr.indexOf('_') == -1) {
return propertyStr;
}
return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, propertyStr);
} | java | private String transformPropertyName(Object property) {
if (property == null) {
return null;
}
String propertyStr = property.toString();
if (propertyStr.indexOf('_') == -1) {
return propertyStr;
}
return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, propertyStr);
} | [
"private",
"String",
"transformPropertyName",
"(",
"Object",
"property",
")",
"{",
"if",
"(",
"property",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"propertyStr",
"=",
"property",
".",
"toString",
"(",
")",
";",
"if",
"(",
"propertyStr"... | Transform snake case to property name. | [
"Transform",
"snake",
"case",
"to",
"property",
"name",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/el/ext/JinjavaBeanELResolver.java#L93-L103 |
31,379 | HubSpot/jinjava | src/main/java/com/hubspot/jinjava/el/ext/JinjavaListELResolver.java | JinjavaListELResolver.toIndex | private static int toIndex(Object property) {
int index = 0;
if (property instanceof Number) {
index = ((Number) property).intValue();
} else if (property instanceof String) {
try {
// ListELResolver uses valueOf, but findbugs complains.
index = Integer.parseInt((String) property);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Cannot parse list index: " + property);
}
} else if (property instanceof Character) {
index = ((Character) property).charValue();
} else if (property instanceof Boolean) {
index = ((Boolean) property).booleanValue() ? 1 : 0;
} else {
throw new IllegalArgumentException("Cannot coerce property to list index: " + property);
}
return index;
} | java | private static int toIndex(Object property) {
int index = 0;
if (property instanceof Number) {
index = ((Number) property).intValue();
} else if (property instanceof String) {
try {
// ListELResolver uses valueOf, but findbugs complains.
index = Integer.parseInt((String) property);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Cannot parse list index: " + property);
}
} else if (property instanceof Character) {
index = ((Character) property).charValue();
} else if (property instanceof Boolean) {
index = ((Boolean) property).booleanValue() ? 1 : 0;
} else {
throw new IllegalArgumentException("Cannot coerce property to list index: " + property);
}
return index;
} | [
"private",
"static",
"int",
"toIndex",
"(",
"Object",
"property",
")",
"{",
"int",
"index",
"=",
"0",
";",
"if",
"(",
"property",
"instanceof",
"Number",
")",
"{",
"index",
"=",
"(",
"(",
"Number",
")",
"property",
")",
".",
"intValue",
"(",
")",
";"... | Convert the given property to an index. Inspired by
ListELResolver.toIndex, but without the base param since we only use it for
getValue where base is null.
@param property
The name of the property to analyze. Will be coerced to a String.
@return The index of property in base.
@throws IllegalArgumentException
if property cannot be coerced to an integer. | [
"Convert",
"the",
"given",
"property",
"to",
"an",
"index",
".",
"Inspired",
"by",
"ListELResolver",
".",
"toIndex",
"but",
"without",
"the",
"base",
"param",
"since",
"we",
"only",
"use",
"it",
"for",
"getValue",
"where",
"base",
"is",
"null",
"."
] | ce570935630f49c666170d2330b0b9ba4eddb955 | https://github.com/HubSpot/jinjava/blob/ce570935630f49c666170d2330b0b9ba4eddb955/src/main/java/com/hubspot/jinjava/el/ext/JinjavaListELResolver.java#L66-L85 |
31,380 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/BinaryUploadRequest.java | BinaryUploadRequest.setFileToUpload | public BinaryUploadRequest setFileToUpload(String path) throws FileNotFoundException {
params.files.clear();
params.files.add(new UploadFile(path));
return this;
} | java | public BinaryUploadRequest setFileToUpload(String path) throws FileNotFoundException {
params.files.clear();
params.files.add(new UploadFile(path));
return this;
} | [
"public",
"BinaryUploadRequest",
"setFileToUpload",
"(",
"String",
"path",
")",
"throws",
"FileNotFoundException",
"{",
"params",
".",
"files",
".",
"clear",
"(",
")",
";",
"params",
".",
"files",
".",
"add",
"(",
"new",
"UploadFile",
"(",
"path",
")",
")",
... | Sets the file used as raw body of the upload request.
@param path path to the file that you want to upload
@throws FileNotFoundException if the file to upload does not exist
@return {@link BinaryUploadRequest} | [
"Sets",
"the",
"file",
"used",
"as",
"raw",
"body",
"of",
"the",
"upload",
"request",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/BinaryUploadRequest.java#L65-L69 |
31,381 | gotev/android-upload-service | examples/app/demoapp/src/main/java/net/gotev/uploadservicedemo/utils/AndroidPermissions.java | AndroidPermissions.checkPermissions | public boolean checkPermissions() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1)
return true;
for (String permission : mRequiredPermissions) {
if (ContextCompat.checkSelfPermission(mContext, permission) != PackageManager.PERMISSION_GRANTED) {
mPermissionsToRequest.add(permission);
}
}
if (mPermissionsToRequest.isEmpty()) {
return true;
}
return false;
} | java | public boolean checkPermissions() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1)
return true;
for (String permission : mRequiredPermissions) {
if (ContextCompat.checkSelfPermission(mContext, permission) != PackageManager.PERMISSION_GRANTED) {
mPermissionsToRequest.add(permission);
}
}
if (mPermissionsToRequest.isEmpty()) {
return true;
}
return false;
} | [
"public",
"boolean",
"checkPermissions",
"(",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<=",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP_MR1",
")",
"return",
"true",
";",
"for",
"(",
"String",
"permission",
":",
"mRequiredPermissions",
... | Checks if all the required permissions are granted.
@return true if all the required permissions are granted, otherwise false | [
"Checks",
"if",
"all",
"the",
"required",
"permissions",
"are",
"granted",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/examples/app/demoapp/src/main/java/net/gotev/uploadservicedemo/utils/AndroidPermissions.java#L34-L49 |
31,382 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/MultipartUploadRequest.java | MultipartUploadRequest.addFileToUpload | public MultipartUploadRequest addFileToUpload(String filePath,
String parameterName,
String fileName, String contentType)
throws FileNotFoundException, IllegalArgumentException {
UploadFile file = new UploadFile(filePath);
filePath = file.getPath();
if (parameterName == null || "".equals(parameterName)) {
throw new IllegalArgumentException("Please specify parameterName value for file: "
+ filePath);
}
file.setProperty(MultipartUploadTask.PROPERTY_PARAM_NAME, parameterName);
if (contentType == null || contentType.isEmpty()) {
contentType = file.getContentType(context);
Logger.debug(LOG_TAG, "Auto-detected MIME type for " + filePath
+ " is: " + contentType);
} else {
Logger.debug(LOG_TAG, "Content Type set for " + filePath
+ " is: " + contentType);
}
file.setProperty(MultipartUploadTask.PROPERTY_CONTENT_TYPE, contentType);
if (fileName == null || "".equals(fileName)) {
fileName = file.getName(context);
Logger.debug(LOG_TAG, "Using original file name: " + fileName);
} else {
Logger.debug(LOG_TAG, "Using custom file name: " + fileName);
}
file.setProperty(MultipartUploadTask.PROPERTY_REMOTE_FILE_NAME, fileName);
params.files.add(file);
return this;
} | java | public MultipartUploadRequest addFileToUpload(String filePath,
String parameterName,
String fileName, String contentType)
throws FileNotFoundException, IllegalArgumentException {
UploadFile file = new UploadFile(filePath);
filePath = file.getPath();
if (parameterName == null || "".equals(parameterName)) {
throw new IllegalArgumentException("Please specify parameterName value for file: "
+ filePath);
}
file.setProperty(MultipartUploadTask.PROPERTY_PARAM_NAME, parameterName);
if (contentType == null || contentType.isEmpty()) {
contentType = file.getContentType(context);
Logger.debug(LOG_TAG, "Auto-detected MIME type for " + filePath
+ " is: " + contentType);
} else {
Logger.debug(LOG_TAG, "Content Type set for " + filePath
+ " is: " + contentType);
}
file.setProperty(MultipartUploadTask.PROPERTY_CONTENT_TYPE, contentType);
if (fileName == null || "".equals(fileName)) {
fileName = file.getName(context);
Logger.debug(LOG_TAG, "Using original file name: " + fileName);
} else {
Logger.debug(LOG_TAG, "Using custom file name: " + fileName);
}
file.setProperty(MultipartUploadTask.PROPERTY_REMOTE_FILE_NAME, fileName);
params.files.add(file);
return this;
} | [
"public",
"MultipartUploadRequest",
"addFileToUpload",
"(",
"String",
"filePath",
",",
"String",
"parameterName",
",",
"String",
"fileName",
",",
"String",
"contentType",
")",
"throws",
"FileNotFoundException",
",",
"IllegalArgumentException",
"{",
"UploadFile",
"file",
... | Adds a file to this upload request.
@param filePath path to the file that you want to upload
@param parameterName Name of the form parameter that will contain file's data
@param fileName File name seen by the server side script. If null, the original file name
will be used
@param contentType Content type of the file. You can use constants defined in
{@link ContentType} class. Set this to null or empty string to try to
automatically detect the mime type from the file. If the mime type can't
be detected, {@code application/octet-stream} will be used by default
@throws FileNotFoundException if the file does not exist at the specified path
@throws IllegalArgumentException if one or more parameters are not valid
@return {@link MultipartUploadRequest} | [
"Adds",
"a",
"file",
"to",
"this",
"upload",
"request",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/MultipartUploadRequest.java#L84-L121 |
31,383 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java | UploadNotificationConfig.setTitleForAllStatuses | public final UploadNotificationConfig setTitleForAllStatuses(String title) {
progress.title = title;
completed.title = title;
error.title = title;
cancelled.title = title;
return this;
} | java | public final UploadNotificationConfig setTitleForAllStatuses(String title) {
progress.title = title;
completed.title = title;
error.title = title;
cancelled.title = title;
return this;
} | [
"public",
"final",
"UploadNotificationConfig",
"setTitleForAllStatuses",
"(",
"String",
"title",
")",
"{",
"progress",
".",
"title",
"=",
"title",
";",
"completed",
".",
"title",
"=",
"title",
";",
"error",
".",
"title",
"=",
"title",
";",
"cancelled",
".",
... | Sets the notification title for all the notification statuses.
@param title Title to show in the notification icon
@return {@link UploadNotificationConfig} | [
"Sets",
"the",
"notification",
"title",
"for",
"all",
"the",
"notification",
"statuses",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java#L70-L76 |
31,384 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java | UploadNotificationConfig.setLargeIconForAllStatuses | public final UploadNotificationConfig setLargeIconForAllStatuses(Bitmap largeIcon) {
progress.largeIcon = largeIcon;
completed.largeIcon = largeIcon;
error.largeIcon = largeIcon;
cancelled.largeIcon = largeIcon;
return this;
} | java | public final UploadNotificationConfig setLargeIconForAllStatuses(Bitmap largeIcon) {
progress.largeIcon = largeIcon;
completed.largeIcon = largeIcon;
error.largeIcon = largeIcon;
cancelled.largeIcon = largeIcon;
return this;
} | [
"public",
"final",
"UploadNotificationConfig",
"setLargeIconForAllStatuses",
"(",
"Bitmap",
"largeIcon",
")",
"{",
"progress",
".",
"largeIcon",
"=",
"largeIcon",
";",
"completed",
".",
"largeIcon",
"=",
"largeIcon",
";",
"error",
".",
"largeIcon",
"=",
"largeIcon",... | Sets the same large notification icon for all the notification statuses.
@param largeIcon Bitmap of the icon to use
@return {@link UploadNotificationConfig} | [
"Sets",
"the",
"same",
"large",
"notification",
"icon",
"for",
"all",
"the",
"notification",
"statuses",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java#L112-L118 |
31,385 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java | UploadNotificationConfig.setClickIntentForAllStatuses | public final UploadNotificationConfig setClickIntentForAllStatuses(PendingIntent clickIntent) {
progress.clickIntent = clickIntent;
completed.clickIntent = clickIntent;
error.clickIntent = clickIntent;
cancelled.clickIntent = clickIntent;
return this;
} | java | public final UploadNotificationConfig setClickIntentForAllStatuses(PendingIntent clickIntent) {
progress.clickIntent = clickIntent;
completed.clickIntent = clickIntent;
error.clickIntent = clickIntent;
cancelled.clickIntent = clickIntent;
return this;
} | [
"public",
"final",
"UploadNotificationConfig",
"setClickIntentForAllStatuses",
"(",
"PendingIntent",
"clickIntent",
")",
"{",
"progress",
".",
"clickIntent",
"=",
"clickIntent",
";",
"completed",
".",
"clickIntent",
"=",
"clickIntent",
";",
"error",
".",
"clickIntent",
... | Sets the same intent to be executed when the user taps on the notification
for all the notification statuses.
@param clickIntent {@link android.app.PendingIntent} containing the user's action
@return {@link UploadNotificationConfig} | [
"Sets",
"the",
"same",
"intent",
"to",
"be",
"executed",
"when",
"the",
"user",
"taps",
"on",
"the",
"notification",
"for",
"all",
"the",
"notification",
"statuses",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java#L127-L133 |
31,386 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java | UploadNotificationConfig.addActionForAllStatuses | public final UploadNotificationConfig addActionForAllStatuses(UploadNotificationAction action) {
progress.actions.add(action);
completed.actions.add(action);
error.actions.add(action);
cancelled.actions.add(action);
return this;
} | java | public final UploadNotificationConfig addActionForAllStatuses(UploadNotificationAction action) {
progress.actions.add(action);
completed.actions.add(action);
error.actions.add(action);
cancelled.actions.add(action);
return this;
} | [
"public",
"final",
"UploadNotificationConfig",
"addActionForAllStatuses",
"(",
"UploadNotificationAction",
"action",
")",
"{",
"progress",
".",
"actions",
".",
"add",
"(",
"action",
")",
";",
"completed",
".",
"actions",
".",
"add",
"(",
"action",
")",
";",
"err... | Adds the same notification action for all the notification statuses.
So for example, if you want to have the same action while the notification is in progress,
cancelled, completed or with an error, this method will save you lines of code.
@param action {@link UploadNotificationAction} action to add
@return {@link UploadNotificationConfig} | [
"Adds",
"the",
"same",
"notification",
"action",
"for",
"all",
"the",
"notification",
"statuses",
".",
"So",
"for",
"example",
"if",
"you",
"want",
"to",
"have",
"the",
"same",
"action",
"while",
"the",
"notification",
"is",
"in",
"progress",
"cancelled",
"c... | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationConfig.java#L143-L149 |
31,387 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java | HttpUploadRequest.addHeader | public B addHeader(final String headerName, final String headerValue) {
httpParams.addHeader(headerName, headerValue);
return self();
} | java | public B addHeader(final String headerName, final String headerValue) {
httpParams.addHeader(headerName, headerValue);
return self();
} | [
"public",
"B",
"addHeader",
"(",
"final",
"String",
"headerName",
",",
"final",
"String",
"headerValue",
")",
"{",
"httpParams",
".",
"addHeader",
"(",
"headerName",
",",
"headerValue",
")",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Adds a header to this upload request.
@param headerName header name
@param headerValue header value
@return self instance | [
"Adds",
"a",
"header",
"to",
"this",
"upload",
"request",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java#L61-L64 |
31,388 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java | HttpUploadRequest.setBasicAuth | public B setBasicAuth(final String username, final String password) {
String auth = Base64.encodeToString((username + ":" + password).getBytes(), Base64.NO_WRAP);
httpParams.addHeader("Authorization", "Basic " + auth);
return self();
} | java | public B setBasicAuth(final String username, final String password) {
String auth = Base64.encodeToString((username + ":" + password).getBytes(), Base64.NO_WRAP);
httpParams.addHeader("Authorization", "Basic " + auth);
return self();
} | [
"public",
"B",
"setBasicAuth",
"(",
"final",
"String",
"username",
",",
"final",
"String",
"password",
")",
"{",
"String",
"auth",
"=",
"Base64",
".",
"encodeToString",
"(",
"(",
"username",
"+",
"\":\"",
"+",
"password",
")",
".",
"getBytes",
"(",
")",
... | Sets the HTTP Basic Authentication header.
@param username HTTP Basic Auth username
@param password HTTP Basic Auth password
@return self instance | [
"Sets",
"the",
"HTTP",
"Basic",
"Authentication",
"header",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java#L72-L76 |
31,389 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java | HttpUploadRequest.addParameter | public B addParameter(final String paramName, final String paramValue) {
httpParams.addParameter(paramName, paramValue);
return self();
} | java | public B addParameter(final String paramName, final String paramValue) {
httpParams.addParameter(paramName, paramValue);
return self();
} | [
"public",
"B",
"addParameter",
"(",
"final",
"String",
"paramName",
",",
"final",
"String",
"paramValue",
")",
"{",
"httpParams",
".",
"addParameter",
"(",
"paramName",
",",
"paramValue",
")",
";",
"return",
"self",
"(",
")",
";",
"}"
] | Adds a parameter to this upload request.
@param paramName parameter name
@param paramValue parameter value
@return self instance | [
"Adds",
"a",
"parameter",
"to",
"this",
"upload",
"request",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java#L85-L88 |
31,390 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java | HttpUploadRequest.setCustomUserAgent | public B setCustomUserAgent(String customUserAgent) {
if (customUserAgent != null && !customUserAgent.isEmpty()) {
httpParams.customUserAgent = customUserAgent;
}
return self();
} | java | public B setCustomUserAgent(String customUserAgent) {
if (customUserAgent != null && !customUserAgent.isEmpty()) {
httpParams.customUserAgent = customUserAgent;
}
return self();
} | [
"public",
"B",
"setCustomUserAgent",
"(",
"String",
"customUserAgent",
")",
"{",
"if",
"(",
"customUserAgent",
"!=",
"null",
"&&",
"!",
"customUserAgent",
".",
"isEmpty",
"(",
")",
")",
"{",
"httpParams",
".",
"customUserAgent",
"=",
"customUserAgent",
";",
"}... | Sets the custom user agent to use for this upload request.
Note! If you set the "User-Agent" header by using the "addHeader" method,
that setting will be overwritten by the value set with this method.
@param customUserAgent custom user agent string
@return self instance | [
"Sets",
"the",
"custom",
"user",
"agent",
"to",
"use",
"for",
"this",
"upload",
"request",
".",
"Note!",
"If",
"you",
"set",
"the",
"User",
"-",
"Agent",
"header",
"by",
"using",
"the",
"addHeader",
"method",
"that",
"setting",
"will",
"be",
"overwritten",... | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/HttpUploadRequest.java#L137-L142 |
31,391 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.stopUpload | public static synchronized void stopUpload(final String uploadId) {
UploadTask removedTask = uploadTasksMap.get(uploadId);
if (removedTask != null) {
removedTask.cancel();
}
} | java | public static synchronized void stopUpload(final String uploadId) {
UploadTask removedTask = uploadTasksMap.get(uploadId);
if (removedTask != null) {
removedTask.cancel();
}
} | [
"public",
"static",
"synchronized",
"void",
"stopUpload",
"(",
"final",
"String",
"uploadId",
")",
"{",
"UploadTask",
"removedTask",
"=",
"uploadTasksMap",
".",
"get",
"(",
"uploadId",
")",
";",
"if",
"(",
"removedTask",
"!=",
"null",
")",
"{",
"removedTask",
... | Stops the upload task with the given uploadId.
@param uploadId The unique upload id | [
"Stops",
"the",
"upload",
"task",
"with",
"the",
"given",
"uploadId",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L154-L159 |
31,392 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.getTaskList | public static synchronized List<String> getTaskList() {
List<String> tasks;
if (uploadTasksMap.isEmpty()) {
tasks = new ArrayList<>(1);
} else {
tasks = new ArrayList<>(uploadTasksMap.size());
tasks.addAll(uploadTasksMap.keySet());
}
return tasks;
} | java | public static synchronized List<String> getTaskList() {
List<String> tasks;
if (uploadTasksMap.isEmpty()) {
tasks = new ArrayList<>(1);
} else {
tasks = new ArrayList<>(uploadTasksMap.size());
tasks.addAll(uploadTasksMap.keySet());
}
return tasks;
} | [
"public",
"static",
"synchronized",
"List",
"<",
"String",
">",
"getTaskList",
"(",
")",
"{",
"List",
"<",
"String",
">",
"tasks",
";",
"if",
"(",
"uploadTasksMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"tasks",
"=",
"new",
"ArrayList",
"<>",
"(",
"1",
... | Gets the list of the currently active upload tasks.
@return list of uploadIDs or an empty list if no tasks are currently running | [
"Gets",
"the",
"list",
"of",
"the",
"currently",
"active",
"upload",
"tasks",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L165-L176 |
31,393 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.stopAllUploads | public static synchronized void stopAllUploads() {
if (uploadTasksMap.isEmpty()) {
return;
}
// using iterator instead for each loop, because it's faster on Android
Iterator<String> iterator = uploadTasksMap.keySet().iterator();
while (iterator.hasNext()) {
UploadTask taskToCancel = uploadTasksMap.get(iterator.next());
taskToCancel.cancel();
}
} | java | public static synchronized void stopAllUploads() {
if (uploadTasksMap.isEmpty()) {
return;
}
// using iterator instead for each loop, because it's faster on Android
Iterator<String> iterator = uploadTasksMap.keySet().iterator();
while (iterator.hasNext()) {
UploadTask taskToCancel = uploadTasksMap.get(iterator.next());
taskToCancel.cancel();
}
} | [
"public",
"static",
"synchronized",
"void",
"stopAllUploads",
"(",
")",
"{",
"if",
"(",
"uploadTasksMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"// using iterator instead for each loop, because it's faster on Android",
"Iterator",
"<",
"String",
">",... | Stop all the active uploads. | [
"Stop",
"all",
"the",
"active",
"uploads",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L181-L193 |
31,394 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.getTask | UploadTask getTask(Intent intent) {
String taskClass = intent.getStringExtra(PARAM_TASK_CLASS);
if (taskClass == null) {
return null;
}
UploadTask uploadTask = null;
try {
Class<?> task = Class.forName(taskClass);
if (UploadTask.class.isAssignableFrom(task)) {
uploadTask = UploadTask.class.cast(task.newInstance());
uploadTask.init(this, intent);
} else {
Logger.error(TAG, taskClass + " does not extend UploadTask!");
}
Logger.debug(TAG, "Successfully created new task with class: " + taskClass);
} catch (Exception exc) {
Logger.error(TAG, "Error while instantiating new task", exc);
}
return uploadTask;
} | java | UploadTask getTask(Intent intent) {
String taskClass = intent.getStringExtra(PARAM_TASK_CLASS);
if (taskClass == null) {
return null;
}
UploadTask uploadTask = null;
try {
Class<?> task = Class.forName(taskClass);
if (UploadTask.class.isAssignableFrom(task)) {
uploadTask = UploadTask.class.cast(task.newInstance());
uploadTask.init(this, intent);
} else {
Logger.error(TAG, taskClass + " does not extend UploadTask!");
}
Logger.debug(TAG, "Successfully created new task with class: " + taskClass);
} catch (Exception exc) {
Logger.error(TAG, "Error while instantiating new task", exc);
}
return uploadTask;
} | [
"UploadTask",
"getTask",
"(",
"Intent",
"intent",
")",
"{",
"String",
"taskClass",
"=",
"intent",
".",
"getStringExtra",
"(",
"PARAM_TASK_CLASS",
")",
";",
"if",
"(",
"taskClass",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"UploadTask",
"uploadTask"... | Creates a new task instance based on the requested task class in the intent.
@param intent intent passed to the service
@return task instance or null if the task class is not supported or invalid | [
"Creates",
"a",
"new",
"task",
"instance",
"based",
"on",
"the",
"requested",
"task",
"class",
"in",
"the",
"intent",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L346-L372 |
31,395 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.holdForegroundNotification | protected synchronized boolean holdForegroundNotification(String uploadId, Notification notification) {
if (!isExecuteInForeground()) return false;
if (foregroundUploadId == null) {
foregroundUploadId = uploadId;
Logger.debug(TAG, uploadId + " now holds the foreground notification");
}
if (uploadId.equals(foregroundUploadId)) {
startForeground(UPLOAD_NOTIFICATION_BASE_ID, notification);
return true;
}
return false;
} | java | protected synchronized boolean holdForegroundNotification(String uploadId, Notification notification) {
if (!isExecuteInForeground()) return false;
if (foregroundUploadId == null) {
foregroundUploadId = uploadId;
Logger.debug(TAG, uploadId + " now holds the foreground notification");
}
if (uploadId.equals(foregroundUploadId)) {
startForeground(UPLOAD_NOTIFICATION_BASE_ID, notification);
return true;
}
return false;
} | [
"protected",
"synchronized",
"boolean",
"holdForegroundNotification",
"(",
"String",
"uploadId",
",",
"Notification",
"notification",
")",
"{",
"if",
"(",
"!",
"isExecuteInForeground",
"(",
")",
")",
"return",
"false",
";",
"if",
"(",
"foregroundUploadId",
"==",
"... | Check if the task is currently the one shown in the foreground notification.
@param uploadId ID of the upload
@return true if the current upload task holds the foreground notification, otherwise false | [
"Check",
"if",
"the",
"task",
"is",
"currently",
"the",
"one",
"shown",
"in",
"the",
"foreground",
"notification",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L379-L393 |
31,396 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.setUploadStatusDelegate | protected static void setUploadStatusDelegate(String uploadId, UploadStatusDelegate delegate) {
if (delegate == null)
return;
uploadDelegates.put(uploadId, new WeakReference<>(delegate));
} | java | protected static void setUploadStatusDelegate(String uploadId, UploadStatusDelegate delegate) {
if (delegate == null)
return;
uploadDelegates.put(uploadId, new WeakReference<>(delegate));
} | [
"protected",
"static",
"void",
"setUploadStatusDelegate",
"(",
"String",
"uploadId",
",",
"UploadStatusDelegate",
"delegate",
")",
"{",
"if",
"(",
"delegate",
"==",
"null",
")",
"return",
";",
"uploadDelegates",
".",
"put",
"(",
"uploadId",
",",
"new",
"WeakRefe... | Sets the delegate which will receive the events for the given upload request.
Those events will not be sent in broadcast, but only to the delegate.
@param uploadId uploadID of the upload request
@param delegate the delegate instance | [
"Sets",
"the",
"delegate",
"which",
"will",
"receive",
"the",
"events",
"for",
"the",
"given",
"upload",
"request",
".",
"Those",
"events",
"will",
"not",
"be",
"sent",
"in",
"broadcast",
"but",
"only",
"to",
"the",
"delegate",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L423-L428 |
31,397 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java | UploadService.getUploadStatusDelegate | protected static UploadStatusDelegate getUploadStatusDelegate(String uploadId) {
WeakReference<UploadStatusDelegate> reference = uploadDelegates.get(uploadId);
if (reference == null)
return null;
UploadStatusDelegate delegate = reference.get();
if (delegate == null) {
uploadDelegates.remove(uploadId);
Logger.info(TAG, "\n\n\nUpload delegate for upload with Id " + uploadId + " is gone!\n" +
"Probably you have set it in an activity and the user navigated away from it\n" +
"before the upload was completed. From now on, the events will be dispatched\n" +
"with broadcast intents. If you see this message, consider switching to the\n" +
"UploadServiceBroadcastReceiver registered globally in your manifest.\n" +
"Read this:\n" +
"https://github.com/gotev/android-upload-service/wiki/Monitoring-upload-status\n");
}
return delegate;
} | java | protected static UploadStatusDelegate getUploadStatusDelegate(String uploadId) {
WeakReference<UploadStatusDelegate> reference = uploadDelegates.get(uploadId);
if (reference == null)
return null;
UploadStatusDelegate delegate = reference.get();
if (delegate == null) {
uploadDelegates.remove(uploadId);
Logger.info(TAG, "\n\n\nUpload delegate for upload with Id " + uploadId + " is gone!\n" +
"Probably you have set it in an activity and the user navigated away from it\n" +
"before the upload was completed. From now on, the events will be dispatched\n" +
"with broadcast intents. If you see this message, consider switching to the\n" +
"UploadServiceBroadcastReceiver registered globally in your manifest.\n" +
"Read this:\n" +
"https://github.com/gotev/android-upload-service/wiki/Monitoring-upload-status\n");
}
return delegate;
} | [
"protected",
"static",
"UploadStatusDelegate",
"getUploadStatusDelegate",
"(",
"String",
"uploadId",
")",
"{",
"WeakReference",
"<",
"UploadStatusDelegate",
">",
"reference",
"=",
"uploadDelegates",
".",
"get",
"(",
"uploadId",
")",
";",
"if",
"(",
"reference",
"=="... | Gets the delegate for an upload request.
@param uploadId uploadID of the upload request
@return {@link UploadStatusDelegate} or null if no delegate has been set for the given
uploadId | [
"Gets",
"the",
"delegate",
"for",
"an",
"upload",
"request",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadService.java#L436-L456 |
31,398 | gotev/android-upload-service | uploadservice/src/main/java/net/gotev/uploadservice/UploadRequest.java | UploadRequest.startUpload | public String startUpload() {
UploadService.setUploadStatusDelegate(params.id, delegate);
final Intent intent = new Intent(context, UploadService.class);
this.initializeIntent(intent);
intent.setAction(UploadService.getActionUpload());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (params.notificationConfig == null) {
throw new IllegalArgumentException("Android Oreo requires a notification configuration for the service to run. https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)");
}
context.startForegroundService(intent);
} else {
context.startService(intent);
}
return params.id;
} | java | public String startUpload() {
UploadService.setUploadStatusDelegate(params.id, delegate);
final Intent intent = new Intent(context, UploadService.class);
this.initializeIntent(intent);
intent.setAction(UploadService.getActionUpload());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (params.notificationConfig == null) {
throw new IllegalArgumentException("Android Oreo requires a notification configuration for the service to run. https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)");
}
context.startForegroundService(intent);
} else {
context.startService(intent);
}
return params.id;
} | [
"public",
"String",
"startUpload",
"(",
")",
"{",
"UploadService",
".",
"setUploadStatusDelegate",
"(",
"params",
".",
"id",
",",
"delegate",
")",
";",
"final",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"context",
",",
"UploadService",
".",
"class",
")"... | Start the background file upload service.
@return the uploadId string. If you have passed your own uploadId in the constructor, this
method will return that same uploadId, otherwise it will return the automatically
generated uploadId | [
"Start",
"the",
"background",
"file",
"upload",
"service",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadRequest.java#L63-L80 |
31,399 | gotev/android-upload-service | examples/app/demoapp/src/main/java/net/gotev/uploadservicedemo/utils/BackHandlingFilePickerFragment.java | BackHandlingFilePickerFragment.goUp | public void goUp() {
mCurrentPath = getParent(mCurrentPath);
mCheckedItems.clear();
mCheckedVisibleViewHolders.clear();
refresh(mCurrentPath);
} | java | public void goUp() {
mCurrentPath = getParent(mCurrentPath);
mCheckedItems.clear();
mCheckedVisibleViewHolders.clear();
refresh(mCurrentPath);
} | [
"public",
"void",
"goUp",
"(",
")",
"{",
"mCurrentPath",
"=",
"getParent",
"(",
"mCurrentPath",
")",
";",
"mCheckedItems",
".",
"clear",
"(",
")",
";",
"mCheckedVisibleViewHolders",
".",
"clear",
"(",
")",
";",
"refresh",
"(",
"mCurrentPath",
")",
";",
"}"... | Go up on level, same as pressing on "..". | [
"Go",
"up",
"on",
"level",
"same",
"as",
"pressing",
"on",
"..",
"."
] | 0952fcbe4b32c100150ffd0a237de3be4942e0a8 | https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/examples/app/demoapp/src/main/java/net/gotev/uploadservicedemo/utils/BackHandlingFilePickerFragment.java#L40-L45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.