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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
161,500 | actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToTagged | public WebSocketContext sendToTagged(String message, String tag) {
return sendToTagged(message, tag, false);
} | java | public WebSocketContext sendToTagged(String message, String tag) {
return sendToTagged(message, tag, false);
} | [
"public",
"WebSocketContext",
"sendToTagged",
"(",
"String",
"message",
",",
"String",
"tag",
")",
"{",
"return",
"sendToTagged",
"(",
"message",
",",
"tag",
",",
"false",
")",
";",
"}"
] | Send message to all connections labeled with tag specified
with self connection excluded
@param message the message to be sent
@param tag the string that tag the connections to be sent
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"labeled",
"with",
"tag",
"specified",
"with",
"self",
"connection",
"excluded"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L220-L222 |
161,501 | actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToTagged | public WebSocketContext sendToTagged(String message, String tag, boolean excludeSelf) {
return sendToConnections(message, tag, manager.tagRegistry(), excludeSelf);
} | java | public WebSocketContext sendToTagged(String message, String tag, boolean excludeSelf) {
return sendToConnections(message, tag, manager.tagRegistry(), excludeSelf);
} | [
"public",
"WebSocketContext",
"sendToTagged",
"(",
"String",
"message",
",",
"String",
"tag",
",",
"boolean",
"excludeSelf",
")",
"{",
"return",
"sendToConnections",
"(",
"message",
",",
"tag",
",",
"manager",
".",
"tagRegistry",
"(",
")",
",",
"excludeSelf",
")",
";",
"}"
] | Send message to all connections labeled with tag specified.
@param message the message to be sent
@param tag the string that tag the connections to be sent
@param excludeSelf specify whether the connection of this context should be send
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"labeled",
"with",
"tag",
"specified",
"."
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L232-L234 |
161,502 | actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendToUser | public WebSocketContext sendToUser(String message, String username) {
return sendToConnections(message, username, manager.usernameRegistry(), true);
} | java | public WebSocketContext sendToUser(String message, String username) {
return sendToConnections(message, username, manager.usernameRegistry(), true);
} | [
"public",
"WebSocketContext",
"sendToUser",
"(",
"String",
"message",
",",
"String",
"username",
")",
"{",
"return",
"sendToConnections",
"(",
"message",
",",
"username",
",",
"manager",
".",
"usernameRegistry",
"(",
")",
",",
"true",
")",
";",
"}"
] | Send message to all connections of a certain user
@param message the message to be sent
@param username the username
@return this context | [
"Send",
"message",
"to",
"all",
"connections",
"of",
"a",
"certain",
"user"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L269-L271 |
161,503 | actframework/actframework | src/main/java/act/ws/WebSocketContext.java | WebSocketContext.sendJsonToUser | public WebSocketContext sendJsonToUser(Object data, String username) {
return sendToTagged(JSON.toJSONString(data), username);
} | java | public WebSocketContext sendJsonToUser(Object data, String username) {
return sendToTagged(JSON.toJSONString(data), username);
} | [
"public",
"WebSocketContext",
"sendJsonToUser",
"(",
"Object",
"data",
",",
"String",
"username",
")",
"{",
"return",
"sendToTagged",
"(",
"JSON",
".",
"toJSONString",
"(",
"data",
")",
",",
"username",
")",
";",
"}"
] | Send JSON representation of a data object to all connections of a certain user
@param data the data to be sent
@param username the username
@return this context | [
"Send",
"JSON",
"representation",
"of",
"a",
"data",
"object",
"to",
"all",
"connections",
"of",
"a",
"certain",
"user"
] | 55a8f8b45e71159a79ec6e157c02f71700f8cd54 | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/ws/WebSocketContext.java#L280-L282 |
161,504 | noboomu/proteus | core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java | ApplicationModule.bindMappers | public void bindMappers()
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(xmlModule);
xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
this.bind(XmlMapper.class).toInstance(xmlMapper);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
objectMapper.registerModule(new AfterburnerModule());
objectMapper.registerModule(new Jdk8Module());
this.bind(ObjectMapper.class).toInstance(objectMapper);
this.requestStaticInjection(Extractors.class);
this.requestStaticInjection(ServerResponse.class);
} | java | public void bindMappers()
{
JacksonXmlModule xmlModule = new JacksonXmlModule();
xmlModule.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(xmlModule);
xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
this.bind(XmlMapper.class).toInstance(xmlMapper);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
objectMapper.registerModule(new AfterburnerModule());
objectMapper.registerModule(new Jdk8Module());
this.bind(ObjectMapper.class).toInstance(objectMapper);
this.requestStaticInjection(Extractors.class);
this.requestStaticInjection(ServerResponse.class);
} | [
"public",
"void",
"bindMappers",
"(",
")",
"{",
"JacksonXmlModule",
"xmlModule",
"=",
"new",
"JacksonXmlModule",
"(",
")",
";",
"xmlModule",
".",
"setDefaultUseWrapper",
"(",
"false",
")",
";",
"XmlMapper",
"xmlMapper",
"=",
"new",
"XmlMapper",
"(",
"xmlModule",
")",
";",
"xmlMapper",
".",
"enable",
"(",
"ToXmlGenerator",
".",
"Feature",
".",
"WRITE_XML_DECLARATION",
")",
";",
"this",
".",
"bind",
"(",
"XmlMapper",
".",
"class",
")",
".",
"toInstance",
"(",
"xmlMapper",
")",
";",
"ObjectMapper",
"objectMapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"FAIL_ON_UNKNOWN_PROPERTIES",
",",
"false",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT",
",",
"true",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"ACCEPT_EMPTY_STRING_AS_NULL_OBJECT",
",",
"true",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"EAGER_DESERIALIZER_FETCH",
",",
"true",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"ACCEPT_SINGLE_VALUE_AS_ARRAY",
",",
"true",
")",
";",
"objectMapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"USE_BIG_DECIMAL_FOR_FLOATS",
",",
"true",
")",
";",
"objectMapper",
".",
"registerModule",
"(",
"new",
"AfterburnerModule",
"(",
")",
")",
";",
"objectMapper",
".",
"registerModule",
"(",
"new",
"Jdk8Module",
"(",
")",
")",
";",
"this",
".",
"bind",
"(",
"ObjectMapper",
".",
"class",
")",
".",
"toInstance",
"(",
"objectMapper",
")",
";",
"this",
".",
"requestStaticInjection",
"(",
"Extractors",
".",
"class",
")",
";",
"this",
".",
"requestStaticInjection",
"(",
"ServerResponse",
".",
"class",
")",
";",
"}"
] | Override for customizing XmlMapper and ObjectMapper | [
"Override",
"for",
"customizing",
"XmlMapper",
"and",
"ObjectMapper"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java#L50-L76 |
161,505 | noboomu/proteus | swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java | Reader.read | public Swagger read(Set<Class<?>> classes) {
Set<Class<?>> sortedClasses = new TreeSet<>((class1, class2) -> {
if (class1.equals(class2)) {
return 0;
} else if (class1.isAssignableFrom(class2)) {
return -1;
} else if (class2.isAssignableFrom(class1)) {
return 1;
}
return class1.getName().compareTo(class2.getName());
});
sortedClasses.addAll(classes);
Map<Class<?>, ReaderListener> listeners = new HashMap<Class<?>, ReaderListener>();
for (Class<?> cls : sortedClasses) {
if (ReaderListener.class.isAssignableFrom(cls) && !listeners.containsKey(cls)) {
try {
listeners.put(cls, (ReaderListener) cls.newInstance());
} catch (Exception e) {
LOGGER.error("Failed to create ReaderListener", e);
}
}
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.beforeScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking beforeScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
// process SwaggerDefinitions first - so we get tags in desired order
for (Class<?> cls : sortedClasses) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
}
for (Class<?> cls : sortedClasses) {
read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.afterScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking afterScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
return swagger;
} | java | public Swagger read(Set<Class<?>> classes) {
Set<Class<?>> sortedClasses = new TreeSet<>((class1, class2) -> {
if (class1.equals(class2)) {
return 0;
} else if (class1.isAssignableFrom(class2)) {
return -1;
} else if (class2.isAssignableFrom(class1)) {
return 1;
}
return class1.getName().compareTo(class2.getName());
});
sortedClasses.addAll(classes);
Map<Class<?>, ReaderListener> listeners = new HashMap<Class<?>, ReaderListener>();
for (Class<?> cls : sortedClasses) {
if (ReaderListener.class.isAssignableFrom(cls) && !listeners.containsKey(cls)) {
try {
listeners.put(cls, (ReaderListener) cls.newInstance());
} catch (Exception e) {
LOGGER.error("Failed to create ReaderListener", e);
}
}
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.beforeScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking beforeScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
// process SwaggerDefinitions first - so we get tags in desired order
for (Class<?> cls : sortedClasses) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
}
for (Class<?> cls : sortedClasses) {
read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
}
// for (ReaderListener listener : listeners.values()) {
// try {
// listener.afterScan(this, swagger);
// } catch (Exception e) {
// LOGGER.error("Unexpected error invoking afterScan listener [" + listener.getClass().getName() + "]", e);
// }
// }
return swagger;
} | [
"public",
"Swagger",
"read",
"(",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
")",
"{",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"sortedClasses",
"=",
"new",
"TreeSet",
"<>",
"(",
"(",
"class1",
",",
"class2",
")",
"->",
"{",
"if",
"(",
"class1",
".",
"equals",
"(",
"class2",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"class1",
".",
"isAssignableFrom",
"(",
"class2",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"class2",
".",
"isAssignableFrom",
"(",
"class1",
")",
")",
"{",
"return",
"1",
";",
"}",
"return",
"class1",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"class2",
".",
"getName",
"(",
")",
")",
";",
"}",
")",
";",
"sortedClasses",
".",
"addAll",
"(",
"classes",
")",
";",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"ReaderListener",
">",
"listeners",
"=",
"new",
"HashMap",
"<",
"Class",
"<",
"?",
">",
",",
"ReaderListener",
">",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"cls",
":",
"sortedClasses",
")",
"{",
"if",
"(",
"ReaderListener",
".",
"class",
".",
"isAssignableFrom",
"(",
"cls",
")",
"&&",
"!",
"listeners",
".",
"containsKey",
"(",
"cls",
")",
")",
"{",
"try",
"{",
"listeners",
".",
"put",
"(",
"cls",
",",
"(",
"ReaderListener",
")",
"cls",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Failed to create ReaderListener\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"// for (ReaderListener listener : listeners.values()) {",
"// try {",
"// listener.beforeScan(this, swagger);",
"// } catch (Exception e) {",
"// LOGGER.error(\"Unexpected error invoking beforeScan listener [\" + listener.getClass().getName() + \"]\", e);",
"// }",
"// }",
"// process SwaggerDefinitions first - so we get tags in desired order",
"for",
"(",
"Class",
"<",
"?",
">",
"cls",
":",
"sortedClasses",
")",
"{",
"SwaggerDefinition",
"swaggerDefinition",
"=",
"cls",
".",
"getAnnotation",
"(",
"SwaggerDefinition",
".",
"class",
")",
";",
"if",
"(",
"swaggerDefinition",
"!=",
"null",
")",
"{",
"readSwaggerConfig",
"(",
"cls",
",",
"swaggerDefinition",
")",
";",
"}",
"}",
"for",
"(",
"Class",
"<",
"?",
">",
"cls",
":",
"sortedClasses",
")",
"{",
"read",
"(",
"cls",
",",
"\"\"",
",",
"null",
",",
"false",
",",
"new",
"String",
"[",
"0",
"]",
",",
"new",
"String",
"[",
"0",
"]",
",",
"new",
"LinkedHashMap",
"<>",
"(",
")",
",",
"new",
"ArrayList",
"<>",
"(",
")",
",",
"new",
"HashSet",
"<>",
"(",
")",
")",
";",
"}",
"// for (ReaderListener listener : listeners.values()) {",
"// try {",
"// listener.afterScan(this, swagger);",
"// } catch (Exception e) {",
"// LOGGER.error(\"Unexpected error invoking afterScan listener [\" + listener.getClass().getName() + \"]\", e);",
"// }",
"// }",
"return",
"swagger",
";",
"}"
] | Scans a set of classes for both ReaderListeners and Swagger annotations. All found listeners will
be instantiated before any of the classes are scanned for Swagger annotations - so they can be invoked
accordingly.
@param classes a set of classes to scan
@return the generated Swagger definition | [
"Scans",
"a",
"set",
"of",
"classes",
"for",
"both",
"ReaderListeners",
"and",
"Swagger",
"annotations",
".",
"All",
"found",
"listeners",
"will",
"be",
"instantiated",
"before",
"any",
"of",
"the",
"classes",
"are",
"scanned",
"for",
"Swagger",
"annotations",
"-",
"so",
"they",
"can",
"be",
"invoked",
"accordingly",
"."
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java#L97-L151 |
161,506 | noboomu/proteus | swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java | Reader.read | public Swagger read(Class<?> cls) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
return read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
} | java | public Swagger read(Class<?> cls) {
SwaggerDefinition swaggerDefinition = cls.getAnnotation(SwaggerDefinition.class);
if (swaggerDefinition != null) {
readSwaggerConfig(cls, swaggerDefinition);
}
return read(cls, "", null, false, new String[0], new String[0], new LinkedHashMap<>(), new ArrayList<>(), new HashSet<>());
} | [
"public",
"Swagger",
"read",
"(",
"Class",
"<",
"?",
">",
"cls",
")",
"{",
"SwaggerDefinition",
"swaggerDefinition",
"=",
"cls",
".",
"getAnnotation",
"(",
"SwaggerDefinition",
".",
"class",
")",
";",
"if",
"(",
"swaggerDefinition",
"!=",
"null",
")",
"{",
"readSwaggerConfig",
"(",
"cls",
",",
"swaggerDefinition",
")",
";",
"}",
"return",
"read",
"(",
"cls",
",",
"\"\"",
",",
"null",
",",
"false",
",",
"new",
"String",
"[",
"0",
"]",
",",
"new",
"String",
"[",
"0",
"]",
",",
"new",
"LinkedHashMap",
"<>",
"(",
")",
",",
"new",
"ArrayList",
"<>",
"(",
")",
",",
"new",
"HashSet",
"<>",
"(",
")",
")",
";",
"}"
] | Scans a single class for Swagger annotations - does not invoke ReaderListeners | [
"Scans",
"a",
"single",
"class",
"for",
"Swagger",
"annotations",
"-",
"does",
"not",
"invoke",
"ReaderListeners"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/swagger/src/main/java/io/sinistral/proteus/swagger/jaxrs2/Reader.java#L156-L163 |
161,507 | noboomu/proteus | core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java | HandlerGenerator.generateRoutes | protected void generateRoutes()
{
try {
// Optional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// typeLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = typeLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// for(Method m : this.controllerClass.getDeclaredMethods())
// {
//
// Optional<io.sinistral.proteus.annotations.Chain> methodLevelWrapAnnotation = Optional.ofNullable(m.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// methodLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = methodLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// }
//
// log.info("handlerWrapperMap: " + handlerWrapperMap);
TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC)
.addSuperinterface(ParameterizedTypeName.get(Supplier.class, RoutingHandler.class));
ClassName extractorClass = ClassName.get("io.sinistral.proteus.server", "Extractors");
ClassName injectClass = ClassName.get("com.google.inject", "Inject");
MethodSpec.Builder constructor = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addAnnotation(injectClass);
String className = this.controllerClass.getSimpleName().toLowerCase() + "Controller";
typeBuilder.addField(this.controllerClass, className, Modifier.PROTECTED, Modifier.FINAL);
ClassName wrapperClass = ClassName.get("io.undertow.server", "HandlerWrapper");
ClassName stringClass = ClassName.get("java.lang", "String");
ClassName mapClass = ClassName.get("java.util", "Map");
TypeName mapOfWrappers = ParameterizedTypeName.get(mapClass, stringClass, wrapperClass);
TypeName annotatedMapOfWrappers = mapOfWrappers
.annotated(AnnotationSpec.builder(com.google.inject.name.Named.class).addMember("value", "$S", "registeredHandlerWrappers").build());
typeBuilder.addField(mapOfWrappers, "registeredHandlerWrappers", Modifier.PROTECTED, Modifier.FINAL);
constructor.addParameter(this.controllerClass, className);
constructor.addParameter(annotatedMapOfWrappers, "registeredHandlerWrappers");
constructor.addStatement("this.$N = $N", className, className);
constructor.addStatement("this.$N = $N", "registeredHandlerWrappers", "registeredHandlerWrappers");
addClassMethodHandlers(typeBuilder, this.controllerClass);
typeBuilder.addMethod(constructor.build());
JavaFile javaFile = JavaFile.builder(packageName, typeBuilder.build()).addStaticImport(extractorClass, "*").build();
StringBuilder sb = new StringBuilder();
javaFile.writeTo(sb);
this.sourceString = sb.toString();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} | java | protected void generateRoutes()
{
try {
// Optional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// typeLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = typeLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// for(Method m : this.controllerClass.getDeclaredMethods())
// {
//
// Optional<io.sinistral.proteus.annotations.Chain> methodLevelWrapAnnotation = Optional.ofNullable(m.getAnnotation(io.sinistral.proteus.annotations.Chain.class));
//
// methodLevelWrapAnnotation.ifPresent( a -> {
//
// io.sinistral.proteus.annotations.Chain w = methodLevelWrapAnnotation.get();
//
// Class<? extends HandlerWrapper> wrapperClasses[] = w.value();
//
// for (int i = 0; i < wrapperClasses.length; i++)
// {
// Class<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];
//
// String wrapperName = generateFieldName(wrapperClass.getCanonicalName());
//
// handlerWrapperMap.put(wrapperClass, wrapperName);
// }
//
// });
//
// }
//
// log.info("handlerWrapperMap: " + handlerWrapperMap);
TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC)
.addSuperinterface(ParameterizedTypeName.get(Supplier.class, RoutingHandler.class));
ClassName extractorClass = ClassName.get("io.sinistral.proteus.server", "Extractors");
ClassName injectClass = ClassName.get("com.google.inject", "Inject");
MethodSpec.Builder constructor = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addAnnotation(injectClass);
String className = this.controllerClass.getSimpleName().toLowerCase() + "Controller";
typeBuilder.addField(this.controllerClass, className, Modifier.PROTECTED, Modifier.FINAL);
ClassName wrapperClass = ClassName.get("io.undertow.server", "HandlerWrapper");
ClassName stringClass = ClassName.get("java.lang", "String");
ClassName mapClass = ClassName.get("java.util", "Map");
TypeName mapOfWrappers = ParameterizedTypeName.get(mapClass, stringClass, wrapperClass);
TypeName annotatedMapOfWrappers = mapOfWrappers
.annotated(AnnotationSpec.builder(com.google.inject.name.Named.class).addMember("value", "$S", "registeredHandlerWrappers").build());
typeBuilder.addField(mapOfWrappers, "registeredHandlerWrappers", Modifier.PROTECTED, Modifier.FINAL);
constructor.addParameter(this.controllerClass, className);
constructor.addParameter(annotatedMapOfWrappers, "registeredHandlerWrappers");
constructor.addStatement("this.$N = $N", className, className);
constructor.addStatement("this.$N = $N", "registeredHandlerWrappers", "registeredHandlerWrappers");
addClassMethodHandlers(typeBuilder, this.controllerClass);
typeBuilder.addMethod(constructor.build());
JavaFile javaFile = JavaFile.builder(packageName, typeBuilder.build()).addStaticImport(extractorClass, "*").build();
StringBuilder sb = new StringBuilder();
javaFile.writeTo(sb);
this.sourceString = sb.toString();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} | [
"protected",
"void",
"generateRoutes",
"(",
")",
"{",
"try",
"{",
"//\t\t\tOptional<io.sinistral.proteus.annotations.Chain> typeLevelWrapAnnotation = Optional.ofNullable(controllerClass.getAnnotation(io.sinistral.proteus.annotations.Chain.class));",
"//\t\t\t",
"//\t\t\ttypeLevelWrapAnnotation.ifPresent( a -> {",
"//\t\t\t\t ",
"//\t\t\t\tio.sinistral.proteus.annotations.Chain w = typeLevelWrapAnnotation.get();",
"//",
"//\t\t\t\tClass<? extends HandlerWrapper> wrapperClasses[] = w.value();",
"//",
"//\t\t\t\tfor (int i = 0; i < wrapperClasses.length; i++)",
"//\t\t\t\t{",
"//\t\t\t\t\tClass<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];",
"//",
"//\t\t\t\t\tString wrapperName = generateFieldName(wrapperClass.getCanonicalName());",
"//",
"//\t\t\t\t\thandlerWrapperMap.put(wrapperClass, wrapperName);",
"//\t\t\t\t}",
"//\t\t\t\t",
"//\t\t\t});",
"//\t\t\t",
"//\t\t\tfor(Method m : this.controllerClass.getDeclaredMethods())",
"//\t\t\t{",
"//\t\t\t",
"//\t\t\t\tOptional<io.sinistral.proteus.annotations.Chain> methodLevelWrapAnnotation = Optional.ofNullable(m.getAnnotation(io.sinistral.proteus.annotations.Chain.class));",
"//\t\t\t\t",
"//\t\t\t\tmethodLevelWrapAnnotation.ifPresent( a -> {",
"//\t\t\t\t\t ",
"//\t\t\t\t\tio.sinistral.proteus.annotations.Chain w = methodLevelWrapAnnotation.get();",
"//\t",
"//\t\t\t\t\tClass<? extends HandlerWrapper> wrapperClasses[] = w.value();",
"//\t",
"//\t\t\t\t\tfor (int i = 0; i < wrapperClasses.length; i++)",
"//\t\t\t\t\t{",
"//\t\t\t\t\t\tClass<? extends HandlerWrapper> wrapperClass = wrapperClasses[i];",
"//\t",
"//\t\t\t\t\t\tString wrapperName = generateFieldName(wrapperClass.getCanonicalName());",
"//\t",
"//\t\t\t\t\t\thandlerWrapperMap.put(wrapperClass, wrapperName);",
"//\t\t\t\t\t}",
"//\t\t\t\t\t",
"//\t\t\t\t});",
"//",
"//\t\t\t}",
"//\t\t\t",
"//\t\t\tlog.info(\"handlerWrapperMap: \" + handlerWrapperMap);",
"TypeSpec",
".",
"Builder",
"typeBuilder",
"=",
"TypeSpec",
".",
"classBuilder",
"(",
"className",
")",
".",
"addModifiers",
"(",
"Modifier",
".",
"PUBLIC",
")",
".",
"addSuperinterface",
"(",
"ParameterizedTypeName",
".",
"get",
"(",
"Supplier",
".",
"class",
",",
"RoutingHandler",
".",
"class",
")",
")",
";",
"ClassName",
"extractorClass",
"=",
"ClassName",
".",
"get",
"(",
"\"io.sinistral.proteus.server\"",
",",
"\"Extractors\"",
")",
";",
"ClassName",
"injectClass",
"=",
"ClassName",
".",
"get",
"(",
"\"com.google.inject\"",
",",
"\"Inject\"",
")",
";",
"MethodSpec",
".",
"Builder",
"constructor",
"=",
"MethodSpec",
".",
"constructorBuilder",
"(",
")",
".",
"addModifiers",
"(",
"Modifier",
".",
"PUBLIC",
")",
".",
"addAnnotation",
"(",
"injectClass",
")",
";",
"String",
"className",
"=",
"this",
".",
"controllerClass",
".",
"getSimpleName",
"(",
")",
".",
"toLowerCase",
"(",
")",
"+",
"\"Controller\"",
";",
"typeBuilder",
".",
"addField",
"(",
"this",
".",
"controllerClass",
",",
"className",
",",
"Modifier",
".",
"PROTECTED",
",",
"Modifier",
".",
"FINAL",
")",
";",
"ClassName",
"wrapperClass",
"=",
"ClassName",
".",
"get",
"(",
"\"io.undertow.server\"",
",",
"\"HandlerWrapper\"",
")",
";",
"ClassName",
"stringClass",
"=",
"ClassName",
".",
"get",
"(",
"\"java.lang\"",
",",
"\"String\"",
")",
";",
"ClassName",
"mapClass",
"=",
"ClassName",
".",
"get",
"(",
"\"java.util\"",
",",
"\"Map\"",
")",
";",
"TypeName",
"mapOfWrappers",
"=",
"ParameterizedTypeName",
".",
"get",
"(",
"mapClass",
",",
"stringClass",
",",
"wrapperClass",
")",
";",
"TypeName",
"annotatedMapOfWrappers",
"=",
"mapOfWrappers",
".",
"annotated",
"(",
"AnnotationSpec",
".",
"builder",
"(",
"com",
".",
"google",
".",
"inject",
".",
"name",
".",
"Named",
".",
"class",
")",
".",
"addMember",
"(",
"\"value\"",
",",
"\"$S\"",
",",
"\"registeredHandlerWrappers\"",
")",
".",
"build",
"(",
")",
")",
";",
"typeBuilder",
".",
"addField",
"(",
"mapOfWrappers",
",",
"\"registeredHandlerWrappers\"",
",",
"Modifier",
".",
"PROTECTED",
",",
"Modifier",
".",
"FINAL",
")",
";",
"constructor",
".",
"addParameter",
"(",
"this",
".",
"controllerClass",
",",
"className",
")",
";",
"constructor",
".",
"addParameter",
"(",
"annotatedMapOfWrappers",
",",
"\"registeredHandlerWrappers\"",
")",
";",
"constructor",
".",
"addStatement",
"(",
"\"this.$N = $N\"",
",",
"className",
",",
"className",
")",
";",
"constructor",
".",
"addStatement",
"(",
"\"this.$N = $N\"",
",",
"\"registeredHandlerWrappers\"",
",",
"\"registeredHandlerWrappers\"",
")",
";",
"addClassMethodHandlers",
"(",
"typeBuilder",
",",
"this",
".",
"controllerClass",
")",
";",
"typeBuilder",
".",
"addMethod",
"(",
"constructor",
".",
"build",
"(",
")",
")",
";",
"JavaFile",
"javaFile",
"=",
"JavaFile",
".",
"builder",
"(",
"packageName",
",",
"typeBuilder",
".",
"build",
"(",
")",
")",
".",
"addStaticImport",
"(",
"extractorClass",
",",
"\"*\"",
")",
".",
"build",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"javaFile",
".",
"writeTo",
"(",
"sb",
")",
";",
"this",
".",
"sourceString",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Generates the routing Java source code | [
"Generates",
"the",
"routing",
"Java",
"source",
"code"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java#L128-L224 |
161,508 | noboomu/proteus | core/src/main/java/io/sinistral/proteus/ProteusApplication.java | ProteusApplication.addDefaultRoutes | public ProteusApplication addDefaultRoutes(RoutingHandler router)
{
if (config.hasPath("health.statusPath")) {
try {
final String statusPath = config.getString("health.statusPath");
router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
exchange.getResponseSender().send("OK");
});
this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());
} catch (Exception e) {
log.error("Error adding health status route.", e.getMessage());
}
}
if (config.hasPath("application.favicon")) {
try {
final ByteBuffer faviconImageBuffer;
final File faviconFile = new File(config.getString("application.favicon"));
if (!faviconFile.exists()) {
try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
} else {
try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
}
router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString());
exchange.getResponseSender().send(faviconImageBuffer);
});
} catch (Exception e) {
log.error("Error adding favicon route.", e.getMessage());
}
}
return this;
} | java | public ProteusApplication addDefaultRoutes(RoutingHandler router)
{
if (config.hasPath("health.statusPath")) {
try {
final String statusPath = config.getString("health.statusPath");
router.add(Methods.GET, statusPath, (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, MediaType.TEXT_PLAIN);
exchange.getResponseSender().send("OK");
});
this.registeredEndpoints.add(EndpointInfo.builder().withConsumes("*/*").withProduces("text/plain").withPathTemplate(statusPath).withControllerName("Internal").withMethod(Methods.GET).build());
} catch (Exception e) {
log.error("Error adding health status route.", e.getMessage());
}
}
if (config.hasPath("application.favicon")) {
try {
final ByteBuffer faviconImageBuffer;
final File faviconFile = new File(config.getString("application.favicon"));
if (!faviconFile.exists()) {
try (final InputStream stream = this.getClass().getResourceAsStream(config.getString("application.favicon"))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
} else {
try (final InputStream stream = Files.newInputStream(Paths.get(config.getString("application.favicon")))) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while (read != -1) {
read = stream.read(buffer);
if (read > 0) {
baos.write(buffer, 0, read);
}
}
faviconImageBuffer = ByteBuffer.wrap(baos.toByteArray());
}
}
router.add(Methods.GET, "favicon.ico", (final HttpServerExchange exchange) ->
{
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, io.sinistral.proteus.server.MediaType.IMAGE_X_ICON.toString());
exchange.getResponseSender().send(faviconImageBuffer);
});
} catch (Exception e) {
log.error("Error adding favicon route.", e.getMessage());
}
}
return this;
} | [
"public",
"ProteusApplication",
"addDefaultRoutes",
"(",
"RoutingHandler",
"router",
")",
"{",
"if",
"(",
"config",
".",
"hasPath",
"(",
"\"health.statusPath\"",
")",
")",
"{",
"try",
"{",
"final",
"String",
"statusPath",
"=",
"config",
".",
"getString",
"(",
"\"health.statusPath\"",
")",
";",
"router",
".",
"add",
"(",
"Methods",
".",
"GET",
",",
"statusPath",
",",
"(",
"final",
"HttpServerExchange",
"exchange",
")",
"->",
"{",
"exchange",
".",
"getResponseHeaders",
"(",
")",
".",
"add",
"(",
"Headers",
".",
"CONTENT_TYPE",
",",
"MediaType",
".",
"TEXT_PLAIN",
")",
";",
"exchange",
".",
"getResponseSender",
"(",
")",
".",
"send",
"(",
"\"OK\"",
")",
";",
"}",
")",
";",
"this",
".",
"registeredEndpoints",
".",
"add",
"(",
"EndpointInfo",
".",
"builder",
"(",
")",
".",
"withConsumes",
"(",
"\"*/*\"",
")",
".",
"withProduces",
"(",
"\"text/plain\"",
")",
".",
"withPathTemplate",
"(",
"statusPath",
")",
".",
"withControllerName",
"(",
"\"Internal\"",
")",
".",
"withMethod",
"(",
"Methods",
".",
"GET",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error adding health status route.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"config",
".",
"hasPath",
"(",
"\"application.favicon\"",
")",
")",
"{",
"try",
"{",
"final",
"ByteBuffer",
"faviconImageBuffer",
";",
"final",
"File",
"faviconFile",
"=",
"new",
"File",
"(",
"config",
".",
"getString",
"(",
"\"application.favicon\"",
")",
")",
";",
"if",
"(",
"!",
"faviconFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"(",
"final",
"InputStream",
"stream",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getResourceAsStream",
"(",
"config",
".",
"getString",
"(",
"\"application.favicon\"",
")",
")",
")",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"int",
"read",
"=",
"0",
";",
"while",
"(",
"read",
"!=",
"-",
"1",
")",
"{",
"read",
"=",
"stream",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"read",
">",
"0",
")",
"{",
"baos",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"}",
"faviconImageBuffer",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"baos",
".",
"toByteArray",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"try",
"(",
"final",
"InputStream",
"stream",
"=",
"Files",
".",
"newInputStream",
"(",
"Paths",
".",
"get",
"(",
"config",
".",
"getString",
"(",
"\"application.favicon\"",
")",
")",
")",
")",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"int",
"read",
"=",
"0",
";",
"while",
"(",
"read",
"!=",
"-",
"1",
")",
"{",
"read",
"=",
"stream",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"read",
">",
"0",
")",
"{",
"baos",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"}",
"faviconImageBuffer",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"baos",
".",
"toByteArray",
"(",
")",
")",
";",
"}",
"}",
"router",
".",
"add",
"(",
"Methods",
".",
"GET",
",",
"\"favicon.ico\"",
",",
"(",
"final",
"HttpServerExchange",
"exchange",
")",
"->",
"{",
"exchange",
".",
"getResponseHeaders",
"(",
")",
".",
"add",
"(",
"Headers",
".",
"CONTENT_TYPE",
",",
"io",
".",
"sinistral",
".",
"proteus",
".",
"server",
".",
"MediaType",
".",
"IMAGE_X_ICON",
".",
"toString",
"(",
")",
")",
";",
"exchange",
".",
"getResponseSender",
"(",
")",
".",
"send",
"(",
"faviconImageBuffer",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error adding favicon route.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Add utility routes the router
@param router | [
"Add",
"utility",
"routes",
"the",
"router"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/ProteusApplication.java#L362-L434 |
161,509 | noboomu/proteus | core/src/main/java/io/sinistral/proteus/ProteusApplication.java | ProteusApplication.setServerConfigurationFunction | public ProteusApplication setServerConfigurationFunction(Function<Undertow.Builder, Undertow.Builder> serverConfigurationFunction)
{
this.serverConfigurationFunction = serverConfigurationFunction;
return this;
} | java | public ProteusApplication setServerConfigurationFunction(Function<Undertow.Builder, Undertow.Builder> serverConfigurationFunction)
{
this.serverConfigurationFunction = serverConfigurationFunction;
return this;
} | [
"public",
"ProteusApplication",
"setServerConfigurationFunction",
"(",
"Function",
"<",
"Undertow",
".",
"Builder",
",",
"Undertow",
".",
"Builder",
">",
"serverConfigurationFunction",
")",
"{",
"this",
".",
"serverConfigurationFunction",
"=",
"serverConfigurationFunction",
";",
"return",
"this",
";",
"}"
] | Allows direct access to the Undertow.Builder for custom configuration
@param serverConfigurationFunction the serverConfigurationFunction | [
"Allows",
"direct",
"access",
"to",
"the",
"Undertow",
".",
"Builder",
"for",
"custom",
"configuration"
] | 9bf999e19e9b491b13912f3ee0e3fbefdbacc509 | https://github.com/noboomu/proteus/blob/9bf999e19e9b491b13912f3ee0e3fbefdbacc509/core/src/main/java/io/sinistral/proteus/ProteusApplication.java#L465-L469 |
161,510 | felipecsl/AsymmetricGridView | library/src/main/java/com/felipecsl/asymmetricgridview/Utils.java | Utils.getDisplayMetrics | static DisplayMetrics getDisplayMetrics(final Context context) {
final WindowManager
windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics;
} | java | static DisplayMetrics getDisplayMetrics(final Context context) {
final WindowManager
windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
final DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics;
} | [
"static",
"DisplayMetrics",
"getDisplayMetrics",
"(",
"final",
"Context",
"context",
")",
"{",
"final",
"WindowManager",
"windowManager",
"=",
"(",
"WindowManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"WINDOW_SERVICE",
")",
";",
"final",
"DisplayMetrics",
"metrics",
"=",
"new",
"DisplayMetrics",
"(",
")",
";",
"windowManager",
".",
"getDefaultDisplay",
"(",
")",
".",
"getMetrics",
"(",
"metrics",
")",
";",
"return",
"metrics",
";",
"}"
] | Returns a valid DisplayMetrics object
@param context valid context
@return DisplayMetrics object | [
"Returns",
"a",
"valid",
"DisplayMetrics",
"object"
] | f8c3d6da518a85218c3627b93ec62415befe7a6a | https://github.com/felipecsl/AsymmetricGridView/blob/f8c3d6da518a85218c3627b93ec62415befe7a6a/library/src/main/java/com/felipecsl/asymmetricgridview/Utils.java#L27-L34 |
161,511 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/live/LiveBlurWorker.java | LiveBlurWorker.crop | private static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
float scale = 1f / downsampling;
return Bitmap.createBitmap(
srcBmp,
(int) Math.floor((ViewCompat.getX(canvasView)) * scale),
(int) Math.floor((ViewCompat.getY(canvasView)) * scale),
(int) Math.floor((canvasView.getWidth()) * scale),
(int) Math.floor((canvasView.getHeight()) * scale)
);
} | java | private static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
float scale = 1f / downsampling;
return Bitmap.createBitmap(
srcBmp,
(int) Math.floor((ViewCompat.getX(canvasView)) * scale),
(int) Math.floor((ViewCompat.getY(canvasView)) * scale),
(int) Math.floor((canvasView.getWidth()) * scale),
(int) Math.floor((canvasView.getHeight()) * scale)
);
} | [
"private",
"static",
"Bitmap",
"crop",
"(",
"Bitmap",
"srcBmp",
",",
"View",
"canvasView",
",",
"int",
"downsampling",
")",
"{",
"float",
"scale",
"=",
"1f",
"/",
"downsampling",
";",
"return",
"Bitmap",
".",
"createBitmap",
"(",
"srcBmp",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"ViewCompat",
".",
"getX",
"(",
"canvasView",
")",
")",
"*",
"scale",
")",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"ViewCompat",
".",
"getY",
"(",
"canvasView",
")",
")",
"*",
"scale",
")",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"canvasView",
".",
"getWidth",
"(",
")",
")",
"*",
"scale",
")",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"(",
"canvasView",
".",
"getHeight",
"(",
")",
")",
"*",
"scale",
")",
")",
";",
"}"
] | crops the srcBmp with the canvasView bounds and returns the cropped bitmap | [
"crops",
"the",
"srcBmp",
"with",
"the",
"canvasView",
"bounds",
"and",
"returns",
"the",
"cropped",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/live/LiveBlurWorker.java#L102-L111 |
161,512 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java | PerformanceProfiler.startTask | public void startTask(int id, String taskName) {
if (isActivated) {
durations.add(new Duration(id, taskName, BenchmarkUtil.elapsedRealTimeNanos()));
}
} | java | public void startTask(int id, String taskName) {
if (isActivated) {
durations.add(new Duration(id, taskName, BenchmarkUtil.elapsedRealTimeNanos()));
}
} | [
"public",
"void",
"startTask",
"(",
"int",
"id",
",",
"String",
"taskName",
")",
"{",
"if",
"(",
"isActivated",
")",
"{",
"durations",
".",
"add",
"(",
"new",
"Duration",
"(",
"id",
",",
"taskName",
",",
"BenchmarkUtil",
".",
"elapsedRealTimeNanos",
"(",
")",
")",
")",
";",
"}",
"}"
] | Start a task. The id is needed to end the task
@param id
@param taskName | [
"Start",
"a",
"task",
".",
"The",
"id",
"is",
"needed",
"to",
"end",
"the",
"task"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java#L43-L47 |
161,513 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java | PerformanceProfiler.getDurationMs | public double getDurationMs() {
double durationMs = 0;
for (Duration duration : durations) {
if (duration.taskFinished()) {
durationMs += duration.getDurationMS();
}
}
return durationMs;
} | java | public double getDurationMs() {
double durationMs = 0;
for (Duration duration : durations) {
if (duration.taskFinished()) {
durationMs += duration.getDurationMS();
}
}
return durationMs;
} | [
"public",
"double",
"getDurationMs",
"(",
")",
"{",
"double",
"durationMs",
"=",
"0",
";",
"for",
"(",
"Duration",
"duration",
":",
"durations",
")",
"{",
"if",
"(",
"duration",
".",
"taskFinished",
"(",
")",
")",
"{",
"durationMs",
"+=",
"duration",
".",
"getDurationMS",
"(",
")",
";",
"}",
"}",
"return",
"durationMs",
";",
"}"
] | Returns the duration of the measured tasks in ms | [
"Returns",
"the",
"duration",
"of",
"the",
"measured",
"tasks",
"in",
"ms"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/PerformanceProfiler.java#L71-L79 |
161,514 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.setViewBackground | public static void setViewBackground(View v, Drawable d) {
if (Build.VERSION.SDK_INT >= 16) {
v.setBackground(d);
} else {
v.setBackgroundDrawable(d);
}
} | java | public static void setViewBackground(View v, Drawable d) {
if (Build.VERSION.SDK_INT >= 16) {
v.setBackground(d);
} else {
v.setBackgroundDrawable(d);
}
} | [
"public",
"static",
"void",
"setViewBackground",
"(",
"View",
"v",
",",
"Drawable",
"d",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"16",
")",
"{",
"v",
".",
"setBackground",
"(",
"d",
")",
";",
"}",
"else",
"{",
"v",
".",
"setBackgroundDrawable",
"(",
"d",
")",
";",
"}",
"}"
] | legacy helper for setting background | [
"legacy",
"helper",
"for",
"setting",
"background"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L36-L42 |
161,515 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.byteSizeOf | public static int byteSizeOf(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return bitmap.getAllocationByteCount();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
} | java | public static int byteSizeOf(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return bitmap.getAllocationByteCount();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
} | [
"public",
"static",
"int",
"byteSizeOf",
"(",
"Bitmap",
"bitmap",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"KITKAT",
")",
"{",
"return",
"bitmap",
".",
"getAllocationByteCount",
"(",
")",
";",
"}",
"else",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB_MR1",
")",
"{",
"return",
"bitmap",
".",
"getByteCount",
"(",
")",
";",
"}",
"else",
"{",
"return",
"bitmap",
".",
"getRowBytes",
"(",
")",
"*",
"bitmap",
".",
"getHeight",
"(",
")",
";",
"}",
"}"
] | returns the bytesize of the give bitmap | [
"returns",
"the",
"bytesize",
"of",
"the",
"give",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L47-L55 |
161,516 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java | LegacySDKUtil.getCacheDir | public static String getCacheDir(Context ctx) {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || (!Environment.isExternalStorageRemovable() && ctx.getExternalCacheDir() != null) ?
ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath();
} | java | public static String getCacheDir(Context ctx) {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || (!Environment.isExternalStorageRemovable() && ctx.getExternalCacheDir() != null) ?
ctx.getExternalCacheDir().getPath() : ctx.getCacheDir().getPath();
} | [
"public",
"static",
"String",
"getCacheDir",
"(",
"Context",
"ctx",
")",
"{",
"return",
"Environment",
".",
"MEDIA_MOUNTED",
".",
"equals",
"(",
"Environment",
".",
"getExternalStorageState",
"(",
")",
")",
"||",
"(",
"!",
"Environment",
".",
"isExternalStorageRemovable",
"(",
")",
"&&",
"ctx",
".",
"getExternalCacheDir",
"(",
")",
"!=",
"null",
")",
"?",
"ctx",
".",
"getExternalCacheDir",
"(",
")",
".",
"getPath",
"(",
")",
":",
"ctx",
".",
"getCacheDir",
"(",
")",
".",
"getPath",
"(",
")",
";",
"}"
] | Gets the appropriate cache dir
@param ctx
@return | [
"Gets",
"the",
"appropriate",
"cache",
"dir"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/LegacySDKUtil.java#L72-L75 |
161,517 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ImageReference.java | ImageReference.measureImage | public Point measureImage(Resources resources) {
BitmapFactory.Options justBoundsOptions = new BitmapFactory.Options();
justBoundsOptions.inJustDecodeBounds = true;
if (bitmap != null) {
return new Point(bitmap.getWidth(), bitmap.getHeight());
} else if (resId != null) {
BitmapFactory.decodeResource(resources, resId, justBoundsOptions);
float scale = (float) justBoundsOptions.inTargetDensity / justBoundsOptions.inDensity;
return new Point((int) (justBoundsOptions.outWidth * scale + 0.5f), (int) (justBoundsOptions.outHeight * scale + 0.5f));
} else if (fileToBitmap != null) {
BitmapFactory.decodeFile(fileToBitmap.getAbsolutePath(), justBoundsOptions);
} else if (inputStream != null) {
BitmapFactory.decodeStream(inputStream, null, justBoundsOptions);
try {
inputStream.reset();
} catch (IOException ignored) {
}
} else if (view != null) {
return new Point(view.getWidth(), view.getHeight());
}
return new Point(justBoundsOptions.outWidth, justBoundsOptions.outHeight);
} | java | public Point measureImage(Resources resources) {
BitmapFactory.Options justBoundsOptions = new BitmapFactory.Options();
justBoundsOptions.inJustDecodeBounds = true;
if (bitmap != null) {
return new Point(bitmap.getWidth(), bitmap.getHeight());
} else if (resId != null) {
BitmapFactory.decodeResource(resources, resId, justBoundsOptions);
float scale = (float) justBoundsOptions.inTargetDensity / justBoundsOptions.inDensity;
return new Point((int) (justBoundsOptions.outWidth * scale + 0.5f), (int) (justBoundsOptions.outHeight * scale + 0.5f));
} else if (fileToBitmap != null) {
BitmapFactory.decodeFile(fileToBitmap.getAbsolutePath(), justBoundsOptions);
} else if (inputStream != null) {
BitmapFactory.decodeStream(inputStream, null, justBoundsOptions);
try {
inputStream.reset();
} catch (IOException ignored) {
}
} else if (view != null) {
return new Point(view.getWidth(), view.getHeight());
}
return new Point(justBoundsOptions.outWidth, justBoundsOptions.outHeight);
} | [
"public",
"Point",
"measureImage",
"(",
"Resources",
"resources",
")",
"{",
"BitmapFactory",
".",
"Options",
"justBoundsOptions",
"=",
"new",
"BitmapFactory",
".",
"Options",
"(",
")",
";",
"justBoundsOptions",
".",
"inJustDecodeBounds",
"=",
"true",
";",
"if",
"(",
"bitmap",
"!=",
"null",
")",
"{",
"return",
"new",
"Point",
"(",
"bitmap",
".",
"getWidth",
"(",
")",
",",
"bitmap",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"resId",
"!=",
"null",
")",
"{",
"BitmapFactory",
".",
"decodeResource",
"(",
"resources",
",",
"resId",
",",
"justBoundsOptions",
")",
";",
"float",
"scale",
"=",
"(",
"float",
")",
"justBoundsOptions",
".",
"inTargetDensity",
"/",
"justBoundsOptions",
".",
"inDensity",
";",
"return",
"new",
"Point",
"(",
"(",
"int",
")",
"(",
"justBoundsOptions",
".",
"outWidth",
"*",
"scale",
"+",
"0.5f",
")",
",",
"(",
"int",
")",
"(",
"justBoundsOptions",
".",
"outHeight",
"*",
"scale",
"+",
"0.5f",
")",
")",
";",
"}",
"else",
"if",
"(",
"fileToBitmap",
"!=",
"null",
")",
"{",
"BitmapFactory",
".",
"decodeFile",
"(",
"fileToBitmap",
".",
"getAbsolutePath",
"(",
")",
",",
"justBoundsOptions",
")",
";",
"}",
"else",
"if",
"(",
"inputStream",
"!=",
"null",
")",
"{",
"BitmapFactory",
".",
"decodeStream",
"(",
"inputStream",
",",
"null",
",",
"justBoundsOptions",
")",
";",
"try",
"{",
"inputStream",
".",
"reset",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ignored",
")",
"{",
"}",
"}",
"else",
"if",
"(",
"view",
"!=",
"null",
")",
"{",
"return",
"new",
"Point",
"(",
"view",
".",
"getWidth",
"(",
")",
",",
"view",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"return",
"new",
"Point",
"(",
"justBoundsOptions",
".",
"outWidth",
",",
"justBoundsOptions",
".",
"outHeight",
")",
";",
"}"
] | If the not a bitmap itself, this will read the file's meta data.
@param resources {@link android.content.Context#getResources()}
@return Point where x = width and y = height | [
"If",
"the",
"not",
"a",
"bitmap",
"itself",
"this",
"will",
"read",
"the",
"file",
"s",
"meta",
"data",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ImageReference.java#L153-L175 |
161,518 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ExecutorManager.java | ExecutorManager.cancelByTag | public synchronized int cancelByTag(String tagToCancel) {
int i = 0;
if (taskList.containsKey(tagToCancel)) {
removeDoneTasks();
for (Future<BlurWorker.Result> future : taskList.get(tagToCancel)) {
BuilderUtil.logVerbose(Dali.getConfig().logTag, "Canceling task with tag " + tagToCancel, Dali.getConfig().debugMode);
future.cancel(true);
i++;
}
//remove all canceled tasks
Iterator<Future<BlurWorker.Result>> iter = taskList.get(tagToCancel).iterator();
while (iter.hasNext()) {
if (iter.next().isCancelled()) {
iter.remove();
}
}
}
return i;
} | java | public synchronized int cancelByTag(String tagToCancel) {
int i = 0;
if (taskList.containsKey(tagToCancel)) {
removeDoneTasks();
for (Future<BlurWorker.Result> future : taskList.get(tagToCancel)) {
BuilderUtil.logVerbose(Dali.getConfig().logTag, "Canceling task with tag " + tagToCancel, Dali.getConfig().debugMode);
future.cancel(true);
i++;
}
//remove all canceled tasks
Iterator<Future<BlurWorker.Result>> iter = taskList.get(tagToCancel).iterator();
while (iter.hasNext()) {
if (iter.next().isCancelled()) {
iter.remove();
}
}
}
return i;
} | [
"public",
"synchronized",
"int",
"cancelByTag",
"(",
"String",
"tagToCancel",
")",
"{",
"int",
"i",
"=",
"0",
";",
"if",
"(",
"taskList",
".",
"containsKey",
"(",
"tagToCancel",
")",
")",
"{",
"removeDoneTasks",
"(",
")",
";",
"for",
"(",
"Future",
"<",
"BlurWorker",
".",
"Result",
">",
"future",
":",
"taskList",
".",
"get",
"(",
"tagToCancel",
")",
")",
"{",
"BuilderUtil",
".",
"logVerbose",
"(",
"Dali",
".",
"getConfig",
"(",
")",
".",
"logTag",
",",
"\"Canceling task with tag \"",
"+",
"tagToCancel",
",",
"Dali",
".",
"getConfig",
"(",
")",
".",
"debugMode",
")",
";",
"future",
".",
"cancel",
"(",
"true",
")",
";",
"i",
"++",
";",
"}",
"//remove all canceled tasks",
"Iterator",
"<",
"Future",
"<",
"BlurWorker",
".",
"Result",
">",
">",
"iter",
"=",
"taskList",
".",
"get",
"(",
"tagToCancel",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"iter",
".",
"next",
"(",
")",
".",
"isCancelled",
"(",
")",
")",
"{",
"iter",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}",
"return",
"i",
";",
"}"
] | Cancel all task with this tag and returns the canceled task count
@param tagToCancel
@return | [
"Cancel",
"all",
"task",
"with",
"this",
"tag",
"and",
"returns",
"the",
"canceled",
"task",
"count"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ExecutorManager.java#L69-L89 |
161,519 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/BitmapUtil.java | BitmapUtil.flip | public static Bitmap flip(Bitmap src) {
Matrix m = new Matrix();
m.preScale(-1, 1);
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
} | java | public static Bitmap flip(Bitmap src) {
Matrix m = new Matrix();
m.preScale(-1, 1);
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
} | [
"public",
"static",
"Bitmap",
"flip",
"(",
"Bitmap",
"src",
")",
"{",
"Matrix",
"m",
"=",
"new",
"Matrix",
"(",
")",
";",
"m",
".",
"preScale",
"(",
"-",
"1",
",",
"1",
")",
";",
"return",
"Bitmap",
".",
"createBitmap",
"(",
"src",
",",
"0",
",",
"0",
",",
"src",
".",
"getWidth",
"(",
")",
",",
"src",
".",
"getHeight",
"(",
")",
",",
"m",
",",
"false",
")",
";",
"}"
] | Mirrors the given bitmap | [
"Mirrors",
"the",
"given",
"bitmap"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/BitmapUtil.java#L83-L87 |
161,520 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/TwoLevelCache.java | TwoLevelCache.purge | public void purge(String cacheKey) {
try {
if (useMemoryCache) {
if (memoryCache != null) {
memoryCache.remove(cacheKey);
}
}
if (useDiskCache) {
if (diskLruCache != null) {
diskLruCache.remove(cacheKey);
}
}
} catch (Exception e) {
Log.w(TAG, "Could not remove entry in cache purge", e);
}
} | java | public void purge(String cacheKey) {
try {
if (useMemoryCache) {
if (memoryCache != null) {
memoryCache.remove(cacheKey);
}
}
if (useDiskCache) {
if (diskLruCache != null) {
diskLruCache.remove(cacheKey);
}
}
} catch (Exception e) {
Log.w(TAG, "Could not remove entry in cache purge", e);
}
} | [
"public",
"void",
"purge",
"(",
"String",
"cacheKey",
")",
"{",
"try",
"{",
"if",
"(",
"useMemoryCache",
")",
"{",
"if",
"(",
"memoryCache",
"!=",
"null",
")",
"{",
"memoryCache",
".",
"remove",
"(",
"cacheKey",
")",
";",
"}",
"}",
"if",
"(",
"useDiskCache",
")",
"{",
"if",
"(",
"diskLruCache",
"!=",
"null",
")",
"{",
"diskLruCache",
".",
"remove",
"(",
"cacheKey",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Could not remove entry in cache purge\"",
",",
"e",
")",
";",
"}",
"}"
] | Removes the value connected to the given key
from all levels of the cache. Will not throw an
exception on fail.
@param cacheKey | [
"Removes",
"the",
"value",
"connected",
"to",
"the",
"given",
"key",
"from",
"all",
"levels",
"of",
"the",
"cache",
".",
"Will",
"not",
"throw",
"an",
"exception",
"on",
"fail",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/TwoLevelCache.java#L223-L239 |
161,521 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/ContextWrapper.java | ContextWrapper.getRenderScript | public RenderScript getRenderScript() {
if (renderScript == null) {
renderScript = RenderScript.create(context, renderScriptContextType);
}
return renderScript;
} | java | public RenderScript getRenderScript() {
if (renderScript == null) {
renderScript = RenderScript.create(context, renderScriptContextType);
}
return renderScript;
} | [
"public",
"RenderScript",
"getRenderScript",
"(",
")",
"{",
"if",
"(",
"renderScript",
"==",
"null",
")",
"{",
"renderScript",
"=",
"RenderScript",
".",
"create",
"(",
"context",
",",
"renderScriptContextType",
")",
";",
"}",
"return",
"renderScript",
";",
"}"
] | Syncronously creates a Renderscript context if none exists.
Creating a Renderscript context takes about 20 ms in Nexus 5
@return | [
"Syncronously",
"creates",
"a",
"Renderscript",
"context",
"if",
"none",
"exists",
".",
"Creating",
"a",
"Renderscript",
"context",
"takes",
"about",
"20",
"ms",
"in",
"Nexus",
"5"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/ContextWrapper.java#L34-L39 |
161,522 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java | DaliBlurDrawerToggle.renderBlurLayer | private void renderBlurLayer(float slideOffset) {
if (enableBlur) {
if (slideOffset == 0 || forceRedraw) {
clearBlurView();
}
if (slideOffset > 0f && blurView == null) {
if (drawerLayout.getChildCount() == 2) {
blurView = new ImageView(drawerLayout.getContext());
blurView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
blurView.setScaleType(ImageView.ScaleType.FIT_CENTER);
drawerLayout.addView(blurView, 1);
}
if (BuilderUtil.isOnUiThread()) {
if (cacheMode.equals(CacheMode.AUTO) || forceRedraw) {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().skipCache().into(blurView);
forceRedraw = false;
} else {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().into(blurView);
}
}
}
if (slideOffset > 0f && slideOffset < 1f) {
int alpha = (int) Math.ceil((double) slideOffset * 255d);
LegacySDKUtil.setImageAlpha(blurView, alpha);
}
}
} | java | private void renderBlurLayer(float slideOffset) {
if (enableBlur) {
if (slideOffset == 0 || forceRedraw) {
clearBlurView();
}
if (slideOffset > 0f && blurView == null) {
if (drawerLayout.getChildCount() == 2) {
blurView = new ImageView(drawerLayout.getContext());
blurView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
blurView.setScaleType(ImageView.ScaleType.FIT_CENTER);
drawerLayout.addView(blurView, 1);
}
if (BuilderUtil.isOnUiThread()) {
if (cacheMode.equals(CacheMode.AUTO) || forceRedraw) {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().skipCache().into(blurView);
forceRedraw = false;
} else {
dali.load(drawerLayout.getChildAt(0)).blurRadius(blurRadius).downScale(downSample).noFade().error(Dali.NO_RESID).concurrent().into(blurView);
}
}
}
if (slideOffset > 0f && slideOffset < 1f) {
int alpha = (int) Math.ceil((double) slideOffset * 255d);
LegacySDKUtil.setImageAlpha(blurView, alpha);
}
}
} | [
"private",
"void",
"renderBlurLayer",
"(",
"float",
"slideOffset",
")",
"{",
"if",
"(",
"enableBlur",
")",
"{",
"if",
"(",
"slideOffset",
"==",
"0",
"||",
"forceRedraw",
")",
"{",
"clearBlurView",
"(",
")",
";",
"}",
"if",
"(",
"slideOffset",
">",
"0f",
"&&",
"blurView",
"==",
"null",
")",
"{",
"if",
"(",
"drawerLayout",
".",
"getChildCount",
"(",
")",
"==",
"2",
")",
"{",
"blurView",
"=",
"new",
"ImageView",
"(",
"drawerLayout",
".",
"getContext",
"(",
")",
")",
";",
"blurView",
".",
"setLayoutParams",
"(",
"new",
"ViewGroup",
".",
"LayoutParams",
"(",
"ViewGroup",
".",
"LayoutParams",
".",
"MATCH_PARENT",
",",
"ViewGroup",
".",
"LayoutParams",
".",
"MATCH_PARENT",
")",
")",
";",
"blurView",
".",
"setScaleType",
"(",
"ImageView",
".",
"ScaleType",
".",
"FIT_CENTER",
")",
";",
"drawerLayout",
".",
"addView",
"(",
"blurView",
",",
"1",
")",
";",
"}",
"if",
"(",
"BuilderUtil",
".",
"isOnUiThread",
"(",
")",
")",
"{",
"if",
"(",
"cacheMode",
".",
"equals",
"(",
"CacheMode",
".",
"AUTO",
")",
"||",
"forceRedraw",
")",
"{",
"dali",
".",
"load",
"(",
"drawerLayout",
".",
"getChildAt",
"(",
"0",
")",
")",
".",
"blurRadius",
"(",
"blurRadius",
")",
".",
"downScale",
"(",
"downSample",
")",
".",
"noFade",
"(",
")",
".",
"error",
"(",
"Dali",
".",
"NO_RESID",
")",
".",
"concurrent",
"(",
")",
".",
"skipCache",
"(",
")",
".",
"into",
"(",
"blurView",
")",
";",
"forceRedraw",
"=",
"false",
";",
"}",
"else",
"{",
"dali",
".",
"load",
"(",
"drawerLayout",
".",
"getChildAt",
"(",
"0",
")",
")",
".",
"blurRadius",
"(",
"blurRadius",
")",
".",
"downScale",
"(",
"downSample",
")",
".",
"noFade",
"(",
")",
".",
"error",
"(",
"Dali",
".",
"NO_RESID",
")",
".",
"concurrent",
"(",
")",
".",
"into",
"(",
"blurView",
")",
";",
"}",
"}",
"}",
"if",
"(",
"slideOffset",
">",
"0f",
"&&",
"slideOffset",
"<",
"1f",
")",
"{",
"int",
"alpha",
"=",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"(",
"double",
")",
"slideOffset",
"*",
"255d",
")",
";",
"LegacySDKUtil",
".",
"setImageAlpha",
"(",
"blurView",
",",
"alpha",
")",
";",
"}",
"}",
"}"
] | This will blur the view behind it and set it in
a imageview over the content with a alpha value
that corresponds to slideOffset. | [
"This",
"will",
"blur",
"the",
"view",
"behind",
"it",
"and",
"set",
"it",
"in",
"a",
"imageview",
"over",
"the",
"content",
"with",
"a",
"alpha",
"value",
"that",
"corresponds",
"to",
"slideOffset",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java#L70-L99 |
161,523 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java | DaliBlurDrawerToggle.onDrawerOpened | public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (listener != null) listener.onDrawerClosed(drawerView);
} | java | public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (listener != null) listener.onDrawerClosed(drawerView);
} | [
"public",
"void",
"onDrawerOpened",
"(",
"View",
"drawerView",
")",
"{",
"super",
".",
"onDrawerOpened",
"(",
"drawerView",
")",
";",
"if",
"(",
"listener",
"!=",
"null",
")",
"listener",
".",
"onDrawerClosed",
"(",
"drawerView",
")",
";",
"}"
] | Called when a drawer has settled in a completely open state. | [
"Called",
"when",
"a",
"drawer",
"has",
"settled",
"in",
"a",
"completely",
"open",
"state",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/nav/DaliBlurDrawerToggle.java#L149-L152 |
161,524 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/util/BuilderUtil.java | BuilderUtil.getIBlurAlgorithm | public static IBlur getIBlurAlgorithm(EBlurAlgorithm algorithm, ContextWrapper contextWrapper) {
RenderScript rs = contextWrapper.getRenderScript();
Context ctx = contextWrapper.getContext();
switch (algorithm) {
case RS_GAUSS_FAST:
return new RenderScriptGaussianBlur(rs);
case RS_BOX_5x5:
return new RenderScriptBox5x5Blur(rs);
case RS_GAUSS_5x5:
return new RenderScriptGaussian5x5Blur(rs);
case RS_STACKBLUR:
return new RenderScriptStackBlur(rs, ctx);
case STACKBLUR:
return new StackBlur();
case GAUSS_FAST:
return new GaussianFastBlur();
case BOX_BLUR:
return new BoxBlur();
default:
return new IgnoreBlur();
}
} | java | public static IBlur getIBlurAlgorithm(EBlurAlgorithm algorithm, ContextWrapper contextWrapper) {
RenderScript rs = contextWrapper.getRenderScript();
Context ctx = contextWrapper.getContext();
switch (algorithm) {
case RS_GAUSS_FAST:
return new RenderScriptGaussianBlur(rs);
case RS_BOX_5x5:
return new RenderScriptBox5x5Blur(rs);
case RS_GAUSS_5x5:
return new RenderScriptGaussian5x5Blur(rs);
case RS_STACKBLUR:
return new RenderScriptStackBlur(rs, ctx);
case STACKBLUR:
return new StackBlur();
case GAUSS_FAST:
return new GaussianFastBlur();
case BOX_BLUR:
return new BoxBlur();
default:
return new IgnoreBlur();
}
} | [
"public",
"static",
"IBlur",
"getIBlurAlgorithm",
"(",
"EBlurAlgorithm",
"algorithm",
",",
"ContextWrapper",
"contextWrapper",
")",
"{",
"RenderScript",
"rs",
"=",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
";",
"Context",
"ctx",
"=",
"contextWrapper",
".",
"getContext",
"(",
")",
";",
"switch",
"(",
"algorithm",
")",
"{",
"case",
"RS_GAUSS_FAST",
":",
"return",
"new",
"RenderScriptGaussianBlur",
"(",
"rs",
")",
";",
"case",
"RS_BOX_5x5",
":",
"return",
"new",
"RenderScriptBox5x5Blur",
"(",
"rs",
")",
";",
"case",
"RS_GAUSS_5x5",
":",
"return",
"new",
"RenderScriptGaussian5x5Blur",
"(",
"rs",
")",
";",
"case",
"RS_STACKBLUR",
":",
"return",
"new",
"RenderScriptStackBlur",
"(",
"rs",
",",
"ctx",
")",
";",
"case",
"STACKBLUR",
":",
"return",
"new",
"StackBlur",
"(",
")",
";",
"case",
"GAUSS_FAST",
":",
"return",
"new",
"GaussianFastBlur",
"(",
")",
";",
"case",
"BOX_BLUR",
":",
"return",
"new",
"BoxBlur",
"(",
")",
";",
"default",
":",
"return",
"new",
"IgnoreBlur",
"(",
")",
";",
"}",
"}"
] | Creates an IBlur instance for the given algorithm enum
@param algorithm
@param contextWrapper
@return | [
"Creates",
"an",
"IBlur",
"instance",
"for",
"the",
"given",
"algorithm",
"enum"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/util/BuilderUtil.java#L40-L62 |
161,525 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.downScale | public BlurBuilder downScale(int scaleInSample) {
data.options.inSampleSize = Math.min(Math.max(1, scaleInSample), 16384);
return this;
} | java | public BlurBuilder downScale(int scaleInSample) {
data.options.inSampleSize = Math.min(Math.max(1, scaleInSample), 16384);
return this;
} | [
"public",
"BlurBuilder",
"downScale",
"(",
"int",
"scaleInSample",
")",
"{",
"data",
".",
"options",
".",
"inSampleSize",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"1",
",",
"scaleInSample",
")",
",",
"16384",
")",
";",
"return",
"this",
";",
"}"
] | Will scale the image down before processing for
performance enhancement and less memory usage
sacrificing image quality.
@param scaleInSample value greater than 1 will scale the image width/height, so 2 will getFromDiskCache you 1/4
of the original size and 4 will getFromDiskCache you 1/16 of the original size - this just sets
the inSample size in {@link android.graphics.BitmapFactory.Options#inSampleSize } and
behaves exactly the same, so keep the value 2^n for least scaling artifacts | [
"Will",
"scale",
"the",
"image",
"down",
"before",
"processing",
"for",
"performance",
"enhancement",
"and",
"less",
"memory",
"usage",
"sacrificing",
"image",
"quality",
"."
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L110-L113 |
161,526 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.brightness | public BlurBuilder brightness(float brightness) {
data.preProcessors.add(new RenderscriptBrightnessProcessor(data.contextWrapper.getRenderScript(), brightness, data.contextWrapper.getResources()));
return this;
} | java | public BlurBuilder brightness(float brightness) {
data.preProcessors.add(new RenderscriptBrightnessProcessor(data.contextWrapper.getRenderScript(), brightness, data.contextWrapper.getResources()));
return this;
} | [
"public",
"BlurBuilder",
"brightness",
"(",
"float",
"brightness",
")",
"{",
"data",
".",
"preProcessors",
".",
"add",
"(",
"new",
"RenderscriptBrightnessProcessor",
"(",
"data",
".",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
",",
"brightness",
",",
"data",
".",
"contextWrapper",
".",
"getResources",
"(",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set brightness to eg. darken the resulting image for use as background
@param brightness default is 0, pos values increase brightness, neg. values decrease brightness
.-100 is black, positive goes up to 1000+ | [
"Set",
"brightness",
"to",
"eg",
".",
"darken",
"the",
"resulting",
"image",
"for",
"use",
"as",
"background"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L155-L158 |
161,527 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java | BlurBuilder.contrast | public BlurBuilder contrast(float contrast) {
data.preProcessors.add(new ContrastProcessor(data.contextWrapper.getRenderScript(), Math.max(Math.min(1500.f, contrast), -1500.f)));
return this;
} | java | public BlurBuilder contrast(float contrast) {
data.preProcessors.add(new ContrastProcessor(data.contextWrapper.getRenderScript(), Math.max(Math.min(1500.f, contrast), -1500.f)));
return this;
} | [
"public",
"BlurBuilder",
"contrast",
"(",
"float",
"contrast",
")",
"{",
"data",
".",
"preProcessors",
".",
"add",
"(",
"new",
"ContrastProcessor",
"(",
"data",
".",
"contextWrapper",
".",
"getRenderScript",
"(",
")",
",",
"Math",
".",
"max",
"(",
"Math",
".",
"min",
"(",
"1500.f",
",",
"contrast",
")",
",",
"-",
"1500.f",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Change contrast of the image
@param contrast default is 0, pos values increase contrast, neg. values decrease contrast | [
"Change",
"contrast",
"of",
"the",
"image"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java#L165-L168 |
161,528 | patrickfav/Dali | dali/src/main/java/at/favre/lib/dali/Dali.java | Dali.resetAndSetNewConfig | public static synchronized void resetAndSetNewConfig(Context ctx, Config config) {
GLOBAL_CONFIG = config;
if (DISK_CACHE_MANAGER != null) {
DISK_CACHE_MANAGER.clear();
DISK_CACHE_MANAGER = null;
createCache(ctx);
}
if (EXECUTOR_MANAGER != null) {
EXECUTOR_MANAGER.shutDown();
EXECUTOR_MANAGER = null;
}
Log.i(TAG, "New config set");
} | java | public static synchronized void resetAndSetNewConfig(Context ctx, Config config) {
GLOBAL_CONFIG = config;
if (DISK_CACHE_MANAGER != null) {
DISK_CACHE_MANAGER.clear();
DISK_CACHE_MANAGER = null;
createCache(ctx);
}
if (EXECUTOR_MANAGER != null) {
EXECUTOR_MANAGER.shutDown();
EXECUTOR_MANAGER = null;
}
Log.i(TAG, "New config set");
} | [
"public",
"static",
"synchronized",
"void",
"resetAndSetNewConfig",
"(",
"Context",
"ctx",
",",
"Config",
"config",
")",
"{",
"GLOBAL_CONFIG",
"=",
"config",
";",
"if",
"(",
"DISK_CACHE_MANAGER",
"!=",
"null",
")",
"{",
"DISK_CACHE_MANAGER",
".",
"clear",
"(",
")",
";",
"DISK_CACHE_MANAGER",
"=",
"null",
";",
"createCache",
"(",
"ctx",
")",
";",
"}",
"if",
"(",
"EXECUTOR_MANAGER",
"!=",
"null",
")",
"{",
"EXECUTOR_MANAGER",
".",
"shutDown",
"(",
")",
";",
"EXECUTOR_MANAGER",
"=",
"null",
";",
"}",
"Log",
".",
"i",
"(",
"TAG",
",",
"\"New config set\"",
")",
";",
"}"
] | Sets a new config and clears the previous cache | [
"Sets",
"a",
"new",
"config",
"and",
"clears",
"the",
"previous",
"cache"
] | 4c90a8c174517873844638d4b8349d890453cc17 | https://github.com/patrickfav/Dali/blob/4c90a8c174517873844638d4b8349d890453cc17/dali/src/main/java/at/favre/lib/dali/Dali.java#L49-L63 |
161,529 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.getIbanLength | public static int getIbanLength(final CountryCode countryCode) {
final BbanStructure structure = getBbanStructure(countryCode);
return COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH + structure.getBbanLength();
} | java | public static int getIbanLength(final CountryCode countryCode) {
final BbanStructure structure = getBbanStructure(countryCode);
return COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH + structure.getBbanLength();
} | [
"public",
"static",
"int",
"getIbanLength",
"(",
"final",
"CountryCode",
"countryCode",
")",
"{",
"final",
"BbanStructure",
"structure",
"=",
"getBbanStructure",
"(",
"countryCode",
")",
";",
"return",
"COUNTRY_CODE_LENGTH",
"+",
"CHECK_DIGIT_LENGTH",
"+",
"structure",
".",
"getBbanLength",
"(",
")",
";",
"}"
] | Returns iban length for the specified country.
@param countryCode {@link org.iban4j.CountryCode}
@return the length of the iban for the specified country. | [
"Returns",
"iban",
"length",
"for",
"the",
"specified",
"country",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L133-L136 |
161,530 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.getCountryCodeAndCheckDigit | public static String getCountryCodeAndCheckDigit(final String iban) {
return iban.substring(COUNTRY_CODE_INDEX,
COUNTRY_CODE_INDEX + COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH);
} | java | public static String getCountryCodeAndCheckDigit(final String iban) {
return iban.substring(COUNTRY_CODE_INDEX,
COUNTRY_CODE_INDEX + COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH);
} | [
"public",
"static",
"String",
"getCountryCodeAndCheckDigit",
"(",
"final",
"String",
"iban",
")",
"{",
"return",
"iban",
".",
"substring",
"(",
"COUNTRY_CODE_INDEX",
",",
"COUNTRY_CODE_INDEX",
"+",
"COUNTRY_CODE_LENGTH",
"+",
"CHECK_DIGIT_LENGTH",
")",
";",
"}"
] | Returns iban's country code and check digit.
@param iban String
@return countryCodeAndCheckDigit String | [
"Returns",
"iban",
"s",
"country",
"code",
"and",
"check",
"digit",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L166-L169 |
161,531 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.replaceCheckDigit | static String replaceCheckDigit(final String iban, final String checkDigit) {
return getCountryCode(iban) + checkDigit + getBban(iban);
} | java | static String replaceCheckDigit(final String iban, final String checkDigit) {
return getCountryCode(iban) + checkDigit + getBban(iban);
} | [
"static",
"String",
"replaceCheckDigit",
"(",
"final",
"String",
"iban",
",",
"final",
"String",
"checkDigit",
")",
"{",
"return",
"getCountryCode",
"(",
"iban",
")",
"+",
"checkDigit",
"+",
"getBban",
"(",
"iban",
")",
";",
"}"
] | Returns an iban with replaced check digit.
@param iban The iban
@return The iban without the check digit | [
"Returns",
"an",
"iban",
"with",
"replaced",
"check",
"digit",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L261-L263 |
161,532 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/IbanUtil.java | IbanUtil.toFormattedString | static String toFormattedString(final String iban) {
final StringBuilder ibanBuffer = new StringBuilder(iban);
final int length = ibanBuffer.length();
for (int i = 0; i < length / 4; i++) {
ibanBuffer.insert((i + 1) * 4 + i, ' ');
}
return ibanBuffer.toString().trim();
} | java | static String toFormattedString(final String iban) {
final StringBuilder ibanBuffer = new StringBuilder(iban);
final int length = ibanBuffer.length();
for (int i = 0; i < length / 4; i++) {
ibanBuffer.insert((i + 1) * 4 + i, ' ');
}
return ibanBuffer.toString().trim();
} | [
"static",
"String",
"toFormattedString",
"(",
"final",
"String",
"iban",
")",
"{",
"final",
"StringBuilder",
"ibanBuffer",
"=",
"new",
"StringBuilder",
"(",
"iban",
")",
";",
"final",
"int",
"length",
"=",
"ibanBuffer",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
"/",
"4",
";",
"i",
"++",
")",
"{",
"ibanBuffer",
".",
"insert",
"(",
"(",
"i",
"+",
"1",
")",
"*",
"4",
"+",
"i",
",",
"'",
"'",
")",
";",
"}",
"return",
"ibanBuffer",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"}"
] | Returns formatted version of Iban.
@return A string representing formatted Iban for printing. | [
"Returns",
"formatted",
"version",
"of",
"Iban",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/IbanUtil.java#L270-L279 |
161,533 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/Bic.java | Bic.valueOf | public static Bic valueOf(final String bic) throws BicFormatException,
UnsupportedCountryException {
BicUtil.validate(bic);
return new Bic(bic);
} | java | public static Bic valueOf(final String bic) throws BicFormatException,
UnsupportedCountryException {
BicUtil.validate(bic);
return new Bic(bic);
} | [
"public",
"static",
"Bic",
"valueOf",
"(",
"final",
"String",
"bic",
")",
"throws",
"BicFormatException",
",",
"UnsupportedCountryException",
"{",
"BicUtil",
".",
"validate",
"(",
"bic",
")",
";",
"return",
"new",
"Bic",
"(",
"bic",
")",
";",
"}"
] | Returns a Bic object holding the value of the specified String.
@param bic the String to be parsed.
@return a Bic object holding the value represented by the string argument.
@throws BicFormatException if the String doesn't contain parsable Bic.
UnsupportedCountryException if bic's country is not supported. | [
"Returns",
"a",
"Bic",
"object",
"holding",
"the",
"value",
"of",
"the",
"specified",
"String",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/Bic.java#L40-L44 |
161,534 | arturmkrtchyan/iban4j | src/main/java/org/iban4j/BicUtil.java | BicUtil.validate | public static void validate(final String bic) throws BicFormatException,
UnsupportedCountryException {
try {
validateEmpty(bic);
validateLength(bic);
validateCase(bic);
validateBankCode(bic);
validateCountryCode(bic);
validateLocationCode(bic);
if(hasBranchCode(bic)) {
validateBranchCode(bic);
}
} catch (UnsupportedCountryException e) {
throw e;
} catch (RuntimeException e) {
throw new BicFormatException(UNKNOWN, e.getMessage());
}
} | java | public static void validate(final String bic) throws BicFormatException,
UnsupportedCountryException {
try {
validateEmpty(bic);
validateLength(bic);
validateCase(bic);
validateBankCode(bic);
validateCountryCode(bic);
validateLocationCode(bic);
if(hasBranchCode(bic)) {
validateBranchCode(bic);
}
} catch (UnsupportedCountryException e) {
throw e;
} catch (RuntimeException e) {
throw new BicFormatException(UNKNOWN, e.getMessage());
}
} | [
"public",
"static",
"void",
"validate",
"(",
"final",
"String",
"bic",
")",
"throws",
"BicFormatException",
",",
"UnsupportedCountryException",
"{",
"try",
"{",
"validateEmpty",
"(",
"bic",
")",
";",
"validateLength",
"(",
"bic",
")",
";",
"validateCase",
"(",
"bic",
")",
";",
"validateBankCode",
"(",
"bic",
")",
";",
"validateCountryCode",
"(",
"bic",
")",
";",
"validateLocationCode",
"(",
"bic",
")",
";",
"if",
"(",
"hasBranchCode",
"(",
"bic",
")",
")",
"{",
"validateBranchCode",
"(",
"bic",
")",
";",
"}",
"}",
"catch",
"(",
"UnsupportedCountryException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"BicFormatException",
"(",
"UNKNOWN",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Validates bic.
@param bic to be validated.
@throws BicFormatException if bic is invalid.
UnsupportedCountryException if bic's country is not supported. | [
"Validates",
"bic",
"."
] | 9889e8873c4ba5c34fc61d17594af935d2ca28a3 | https://github.com/arturmkrtchyan/iban4j/blob/9889e8873c4ba5c34fc61d17594af935d2ca28a3/src/main/java/org/iban4j/BicUtil.java#L44-L62 |
161,535 | detro/ghostdriver | binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriver.java | PhantomJSDriver.getScreenshotAs | @Override
public <X> X getScreenshotAs(OutputType<X> target) {
// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)
String base64 = (String) execute(DriverCommand.SCREENSHOT).getValue();
return target.convertFromBase64Png(base64);
} | java | @Override
public <X> X getScreenshotAs(OutputType<X> target) {
// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)
String base64 = (String) execute(DriverCommand.SCREENSHOT).getValue();
return target.convertFromBase64Png(base64);
} | [
"@",
"Override",
"public",
"<",
"X",
">",
"X",
"getScreenshotAs",
"(",
"OutputType",
"<",
"X",
">",
"target",
")",
"{",
"// Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>)",
"String",
"base64",
"=",
"(",
"String",
")",
"execute",
"(",
"DriverCommand",
".",
"SCREENSHOT",
")",
".",
"getValue",
"(",
")",
";",
"return",
"target",
".",
"convertFromBase64Png",
"(",
"base64",
")",
";",
"}"
] | Take screenshot of the current window.
@param target The target type/format of the Screenshot
@return Screenshot of current window, in the requested format | [
"Take",
"screenshot",
"of",
"the",
"current",
"window",
"."
] | fe3063d52f47ec2781d43970452595c42f729ebf | https://github.com/detro/ghostdriver/blob/fe3063d52f47ec2781d43970452595c42f729ebf/binding/java/src/main/java/org/openqa/selenium/phantomjs/PhantomJSDriver.java#L134-L139 |
161,536 | notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.sound | public PayloadBuilder sound(final String sound) {
if (sound != null) {
aps.put("sound", sound);
} else {
aps.remove("sound");
}
return this;
} | java | public PayloadBuilder sound(final String sound) {
if (sound != null) {
aps.put("sound", sound);
} else {
aps.remove("sound");
}
return this;
} | [
"public",
"PayloadBuilder",
"sound",
"(",
"final",
"String",
"sound",
")",
"{",
"if",
"(",
"sound",
"!=",
"null",
")",
"{",
"aps",
".",
"put",
"(",
"\"sound\"",
",",
"sound",
")",
";",
"}",
"else",
"{",
"aps",
".",
"remove",
"(",
"\"sound\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the alert sound to be played.
Passing {@code null} disables the notification sound.
@param sound the file name or song name to be played
when receiving the notification
@return this | [
"Sets",
"the",
"alert",
"sound",
"to",
"be",
"played",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L153-L160 |
161,537 | notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.category | public PayloadBuilder category(final String category) {
if (category != null) {
aps.put("category", category);
} else {
aps.remove("category");
}
return this;
} | java | public PayloadBuilder category(final String category) {
if (category != null) {
aps.put("category", category);
} else {
aps.remove("category");
}
return this;
} | [
"public",
"PayloadBuilder",
"category",
"(",
"final",
"String",
"category",
")",
"{",
"if",
"(",
"category",
"!=",
"null",
")",
"{",
"aps",
".",
"put",
"(",
"\"category\"",
",",
"category",
")",
";",
"}",
"else",
"{",
"aps",
".",
"remove",
"(",
"\"category\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the category of the notification for iOS8 notification
actions. See 13 minutes into "What's new in iOS Notifications"
Passing {@code null} removes the category.
@param category the name of the category supplied to the app
when receiving the notification
@return this | [
"Sets",
"the",
"category",
"of",
"the",
"notification",
"for",
"iOS8",
"notification",
"actions",
".",
"See",
"13",
"minutes",
"into",
"What",
"s",
"new",
"in",
"iOS",
"Notifications"
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L172-L179 |
161,538 | notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.customField | public PayloadBuilder customField(final String key, final Object value) {
root.put(key, value);
return this;
} | java | public PayloadBuilder customField(final String key, final Object value) {
root.put(key, value);
return this;
} | [
"public",
"PayloadBuilder",
"customField",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"value",
")",
"{",
"root",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Sets any application-specific custom fields. The values
are presented to the application and the iPhone doesn't
display them automatically.
This can be used to pass specific values (urls, ids, etc) to
the application in addition to the notification message
itself.
@param key the custom field name
@param value the custom field value
@return this | [
"Sets",
"any",
"application",
"-",
"specific",
"custom",
"fields",
".",
"The",
"values",
"are",
"presented",
"to",
"the",
"application",
"and",
"the",
"iPhone",
"doesn",
"t",
"display",
"them",
"automatically",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L327-L330 |
161,539 | notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.resizeAlertBody | public PayloadBuilder resizeAlertBody(final int payloadLength, final String postfix) {
int currLength = length();
if (currLength <= payloadLength) {
return this;
}
// now we are sure that truncation is required
String body = (String)customAlert.get("body");
final int acceptableSize = Utilities.toUTF8Bytes(body).length
- (currLength - payloadLength
+ Utilities.toUTF8Bytes(postfix).length);
body = Utilities.truncateWhenUTF8(body, acceptableSize) + postfix;
// set it back
customAlert.put("body", body);
// calculate the length again
currLength = length();
if(currLength > payloadLength) {
// string is still too long, just remove the body as the body is
// anyway not the cause OR the postfix might be too long
customAlert.remove("body");
}
return this;
} | java | public PayloadBuilder resizeAlertBody(final int payloadLength, final String postfix) {
int currLength = length();
if (currLength <= payloadLength) {
return this;
}
// now we are sure that truncation is required
String body = (String)customAlert.get("body");
final int acceptableSize = Utilities.toUTF8Bytes(body).length
- (currLength - payloadLength
+ Utilities.toUTF8Bytes(postfix).length);
body = Utilities.truncateWhenUTF8(body, acceptableSize) + postfix;
// set it back
customAlert.put("body", body);
// calculate the length again
currLength = length();
if(currLength > payloadLength) {
// string is still too long, just remove the body as the body is
// anyway not the cause OR the postfix might be too long
customAlert.remove("body");
}
return this;
} | [
"public",
"PayloadBuilder",
"resizeAlertBody",
"(",
"final",
"int",
"payloadLength",
",",
"final",
"String",
"postfix",
")",
"{",
"int",
"currLength",
"=",
"length",
"(",
")",
";",
"if",
"(",
"currLength",
"<=",
"payloadLength",
")",
"{",
"return",
"this",
";",
"}",
"// now we are sure that truncation is required",
"String",
"body",
"=",
"(",
"String",
")",
"customAlert",
".",
"get",
"(",
"\"body\"",
")",
";",
"final",
"int",
"acceptableSize",
"=",
"Utilities",
".",
"toUTF8Bytes",
"(",
"body",
")",
".",
"length",
"-",
"(",
"currLength",
"-",
"payloadLength",
"+",
"Utilities",
".",
"toUTF8Bytes",
"(",
"postfix",
")",
".",
"length",
")",
";",
"body",
"=",
"Utilities",
".",
"truncateWhenUTF8",
"(",
"body",
",",
"acceptableSize",
")",
"+",
"postfix",
";",
"// set it back",
"customAlert",
".",
"put",
"(",
"\"body\"",
",",
"body",
")",
";",
"// calculate the length again",
"currLength",
"=",
"length",
"(",
")",
";",
"if",
"(",
"currLength",
">",
"payloadLength",
")",
"{",
"// string is still too long, just remove the body as the body is",
"// anyway not the cause OR the postfix might be too long",
"customAlert",
".",
"remove",
"(",
"\"body\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Shrinks the alert message body so that the resulting payload
message fits within the passed expected payload length.
This method performs best-effort approach, and its behavior
is unspecified when handling alerts where the payload
without body is already longer than the permitted size, or
if the break occurs within word.
@param payloadLength the expected max size of the payload
@param postfix for the truncated body, e.g. "..."
@return this | [
"Shrinks",
"the",
"alert",
"message",
"body",
"so",
"that",
"the",
"resulting",
"payload",
"message",
"fits",
"within",
"the",
"passed",
"expected",
"payload",
"length",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L401-L428 |
161,540 | notnoop/java-apns | src/main/java/com/notnoop/apns/PayloadBuilder.java | PayloadBuilder.build | public String build() {
if (!root.containsKey("mdm")) {
insertCustomAlert();
root.put("aps", aps);
}
try {
return mapper.writeValueAsString(root);
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | java | public String build() {
if (!root.containsKey("mdm")) {
insertCustomAlert();
root.put("aps", aps);
}
try {
return mapper.writeValueAsString(root);
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"String",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"root",
".",
"containsKey",
"(",
"\"mdm\"",
")",
")",
"{",
"insertCustomAlert",
"(",
")",
";",
"root",
".",
"put",
"(",
"\"aps\"",
",",
"aps",
")",
";",
"}",
"try",
"{",
"return",
"mapper",
".",
"writeValueAsString",
"(",
"root",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Returns the JSON String representation of the payload
according to Apple APNS specification
@return the String representation as expected by Apple | [
"Returns",
"the",
"JSON",
"String",
"representation",
"of",
"the",
"payload",
"according",
"to",
"Apple",
"APNS",
"specification"
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/PayloadBuilder.java#L468-L478 |
161,541 | notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withSocksProxy | public ApnsServiceBuilder withSocksProxy(String host, int port) {
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
new InetSocketAddress(host, port));
return withProxy(proxy);
} | java | public ApnsServiceBuilder withSocksProxy(String host, int port) {
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
new InetSocketAddress(host, port));
return withProxy(proxy);
} | [
"public",
"ApnsServiceBuilder",
"withSocksProxy",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"Proxy",
"proxy",
"=",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"SOCKS",
",",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
")",
";",
"return",
"withProxy",
"(",
"proxy",
")",
";",
"}"
] | Specify the address of the SOCKS proxy the connection should
use.
<p>Read the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html">
Java Networking and Proxies</a> guide to understand the
proxies complexity.
<p>Be aware that this method only handles SOCKS proxies, not
HTTPS proxies. Use {@link #withProxy(Proxy)} instead.
@param host the hostname of the SOCKS proxy
@param port the port of the SOCKS proxy server
@return this | [
"Specify",
"the",
"address",
"of",
"the",
"SOCKS",
"proxy",
"the",
"connection",
"should",
"use",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L469-L473 |
161,542 | notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withAuthProxy | public ApnsServiceBuilder withAuthProxy(Proxy proxy, String proxyUsername, String proxyPassword) {
this.proxy = proxy;
this.proxyUsername = proxyUsername;
this.proxyPassword = proxyPassword;
return this;
} | java | public ApnsServiceBuilder withAuthProxy(Proxy proxy, String proxyUsername, String proxyPassword) {
this.proxy = proxy;
this.proxyUsername = proxyUsername;
this.proxyPassword = proxyPassword;
return this;
} | [
"public",
"ApnsServiceBuilder",
"withAuthProxy",
"(",
"Proxy",
"proxy",
",",
"String",
"proxyUsername",
",",
"String",
"proxyPassword",
")",
"{",
"this",
".",
"proxy",
"=",
"proxy",
";",
"this",
".",
"proxyUsername",
"=",
"proxyUsername",
";",
"this",
".",
"proxyPassword",
"=",
"proxyPassword",
";",
"return",
"this",
";",
"}"
] | Specify the proxy and the authentication parameters to be used
to establish the connections to Apple Servers.
<p>Read the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html">
Java Networking and Proxies</a> guide to understand the
proxies complexity.
@param proxy the proxy object to be used to create connections
@param proxyUsername a String object representing the username of the proxy server
@param proxyPassword a String object representing the password of the proxy server
@return this | [
"Specify",
"the",
"proxy",
"and",
"the",
"authentication",
"parameters",
"to",
"be",
"used",
"to",
"establish",
"the",
"connections",
"to",
"Apple",
"Servers",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L488-L493 |
161,543 | notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withProxySocket | @Deprecated
public ApnsServiceBuilder withProxySocket(Socket proxySocket) {
return this.withProxy(new Proxy(Proxy.Type.SOCKS,
proxySocket.getRemoteSocketAddress()));
} | java | @Deprecated
public ApnsServiceBuilder withProxySocket(Socket proxySocket) {
return this.withProxy(new Proxy(Proxy.Type.SOCKS,
proxySocket.getRemoteSocketAddress()));
} | [
"@",
"Deprecated",
"public",
"ApnsServiceBuilder",
"withProxySocket",
"(",
"Socket",
"proxySocket",
")",
"{",
"return",
"this",
".",
"withProxy",
"(",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"SOCKS",
",",
"proxySocket",
".",
"getRemoteSocketAddress",
"(",
")",
")",
")",
";",
"}"
] | Specify the socket to be used as underlying socket to connect
to the APN service.
This assumes that the socket connects to a SOCKS proxy.
@deprecated use {@link ApnsServiceBuilder#withProxy(Proxy)} instead
@param proxySocket the underlying socket for connections
@return this | [
"Specify",
"the",
"socket",
"to",
"be",
"used",
"as",
"underlying",
"socket",
"to",
"connect",
"to",
"the",
"APN",
"service",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L533-L537 |
161,544 | notnoop/java-apns | src/main/java/com/notnoop/apns/ApnsServiceBuilder.java | ApnsServiceBuilder.withDelegate | public ApnsServiceBuilder withDelegate(ApnsDelegate delegate) {
this.delegate = delegate == null ? ApnsDelegate.EMPTY : delegate;
return this;
} | java | public ApnsServiceBuilder withDelegate(ApnsDelegate delegate) {
this.delegate = delegate == null ? ApnsDelegate.EMPTY : delegate;
return this;
} | [
"public",
"ApnsServiceBuilder",
"withDelegate",
"(",
"ApnsDelegate",
"delegate",
")",
"{",
"this",
".",
"delegate",
"=",
"delegate",
"==",
"null",
"?",
"ApnsDelegate",
".",
"EMPTY",
":",
"delegate",
";",
"return",
"this",
";",
"}"
] | Sets the delegate of the service, that gets notified of the
status of message delivery.
Note: This option has no effect when using non-blocking
connections. | [
"Sets",
"the",
"delegate",
"of",
"the",
"service",
"that",
"gets",
"notified",
"of",
"the",
"status",
"of",
"message",
"delivery",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/ApnsServiceBuilder.java#L679-L682 |
161,545 | notnoop/java-apns | src/main/java/com/notnoop/apns/SimpleApnsNotification.java | SimpleApnsNotification.length | public int length() {
int length = 1 + 2 + deviceToken.length + 2 + payload.length;
final int marshalledLength = marshall().length;
assert marshalledLength == length;
return length;
} | java | public int length() {
int length = 1 + 2 + deviceToken.length + 2 + payload.length;
final int marshalledLength = marshall().length;
assert marshalledLength == length;
return length;
} | [
"public",
"int",
"length",
"(",
")",
"{",
"int",
"length",
"=",
"1",
"+",
"2",
"+",
"deviceToken",
".",
"length",
"+",
"2",
"+",
"payload",
".",
"length",
";",
"final",
"int",
"marshalledLength",
"=",
"marshall",
"(",
")",
".",
"length",
";",
"assert",
"marshalledLength",
"==",
"length",
";",
"return",
"length",
";",
"}"
] | Returns the length of the message in bytes as it is encoded on the wire.
Apple require the message to be of length 255 bytes or less.
@return length of encoded message in bytes | [
"Returns",
"the",
"length",
"of",
"the",
"message",
"in",
"bytes",
"as",
"it",
"is",
"encoded",
"on",
"the",
"wire",
"."
] | 180a190d4cb49458441596ca7c69d50ec7f1dba5 | https://github.com/notnoop/java-apns/blob/180a190d4cb49458441596ca7c69d50ec7f1dba5/src/main/java/com/notnoop/apns/SimpleApnsNotification.java#L124-L129 |
161,546 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java | MultiPageStack.setPadding | public void setPadding(float padding, Layout.Axis axis) {
OrientedLayout layout = null;
switch(axis) {
case X:
layout = mShiftLayout;
break;
case Y:
layout = mShiftLayout;
break;
case Z:
layout = mStackLayout;
break;
}
if (layout != null) {
if (!equal(layout.getDividerPadding(axis), padding)) {
layout.setDividerPadding(padding, axis);
if (layout.getOrientationAxis() == axis) {
requestLayout();
}
}
}
} | java | public void setPadding(float padding, Layout.Axis axis) {
OrientedLayout layout = null;
switch(axis) {
case X:
layout = mShiftLayout;
break;
case Y:
layout = mShiftLayout;
break;
case Z:
layout = mStackLayout;
break;
}
if (layout != null) {
if (!equal(layout.getDividerPadding(axis), padding)) {
layout.setDividerPadding(padding, axis);
if (layout.getOrientationAxis() == axis) {
requestLayout();
}
}
}
} | [
"public",
"void",
"setPadding",
"(",
"float",
"padding",
",",
"Layout",
".",
"Axis",
"axis",
")",
"{",
"OrientedLayout",
"layout",
"=",
"null",
";",
"switch",
"(",
"axis",
")",
"{",
"case",
"X",
":",
"layout",
"=",
"mShiftLayout",
";",
"break",
";",
"case",
"Y",
":",
"layout",
"=",
"mShiftLayout",
";",
"break",
";",
"case",
"Z",
":",
"layout",
"=",
"mStackLayout",
";",
"break",
";",
"}",
"if",
"(",
"layout",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"equal",
"(",
"layout",
".",
"getDividerPadding",
"(",
"axis",
")",
",",
"padding",
")",
")",
"{",
"layout",
".",
"setDividerPadding",
"(",
"padding",
",",
"axis",
")",
";",
"if",
"(",
"layout",
".",
"getOrientationAxis",
"(",
")",
"==",
"axis",
")",
"{",
"requestLayout",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Sets padding between the pages
@param padding
@param axis | [
"Sets",
"padding",
"between",
"the",
"pages"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java#L80-L103 |
161,547 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java | MultiPageStack.setShiftOrientation | public void setShiftOrientation(OrientedLayout.Orientation orientation) {
if (mShiftLayout.getOrientation() != orientation &&
orientation != OrientedLayout.Orientation.STACK) {
mShiftLayout.setOrientation(orientation);
requestLayout();
}
} | java | public void setShiftOrientation(OrientedLayout.Orientation orientation) {
if (mShiftLayout.getOrientation() != orientation &&
orientation != OrientedLayout.Orientation.STACK) {
mShiftLayout.setOrientation(orientation);
requestLayout();
}
} | [
"public",
"void",
"setShiftOrientation",
"(",
"OrientedLayout",
".",
"Orientation",
"orientation",
")",
"{",
"if",
"(",
"mShiftLayout",
".",
"getOrientation",
"(",
")",
"!=",
"orientation",
"&&",
"orientation",
"!=",
"OrientedLayout",
".",
"Orientation",
".",
"STACK",
")",
"{",
"mShiftLayout",
".",
"setOrientation",
"(",
"orientation",
")",
";",
"requestLayout",
"(",
")",
";",
"}",
"}"
] | Sets page shift orientation. The pages might be shifted horizontally or vertically relative
to each other to make the content of each page on the screen at least partially visible
@param orientation | [
"Sets",
"page",
"shift",
"orientation",
".",
"The",
"pages",
"might",
"be",
"shifted",
"horizontally",
"or",
"vertically",
"relative",
"to",
"each",
"other",
"to",
"make",
"the",
"content",
"of",
"each",
"page",
"on",
"the",
"screen",
"at",
"least",
"partially",
"visible"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/MultiPageStack.java#L110-L116 |
161,548 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java | TouchManager.removeHandlerFor | public boolean removeHandlerFor(final GVRSceneObject sceneObject) {
sceneObject.detachComponent(GVRCollider.getComponentType());
return null != touchHandlers.remove(sceneObject);
} | java | public boolean removeHandlerFor(final GVRSceneObject sceneObject) {
sceneObject.detachComponent(GVRCollider.getComponentType());
return null != touchHandlers.remove(sceneObject);
} | [
"public",
"boolean",
"removeHandlerFor",
"(",
"final",
"GVRSceneObject",
"sceneObject",
")",
"{",
"sceneObject",
".",
"detachComponent",
"(",
"GVRCollider",
".",
"getComponentType",
"(",
")",
")",
";",
"return",
"null",
"!=",
"touchHandlers",
".",
"remove",
"(",
"sceneObject",
")",
";",
"}"
] | Makes the object unpickable and removes the touch handler for it
@param sceneObject
@return true if the handler has been successfully removed | [
"Makes",
"the",
"object",
"unpickable",
"and",
"removes",
"the",
"touch",
"handler",
"for",
"it"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java#L93-L96 |
161,549 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java | TouchManager.makePickable | public void makePickable(GVRSceneObject sceneObject) {
try {
GVRMeshCollider collider = new GVRMeshCollider(sceneObject.getGVRContext(), false);
sceneObject.attachComponent(collider);
} catch (Exception e) {
// Possible that some objects (X3D panel nodes) are without mesh
Log.e(Log.SUBSYSTEM.INPUT, TAG, "makePickable(): possible that some objects (X3D panel nodes) are without mesh!");
}
} | java | public void makePickable(GVRSceneObject sceneObject) {
try {
GVRMeshCollider collider = new GVRMeshCollider(sceneObject.getGVRContext(), false);
sceneObject.attachComponent(collider);
} catch (Exception e) {
// Possible that some objects (X3D panel nodes) are without mesh
Log.e(Log.SUBSYSTEM.INPUT, TAG, "makePickable(): possible that some objects (X3D panel nodes) are without mesh!");
}
} | [
"public",
"void",
"makePickable",
"(",
"GVRSceneObject",
"sceneObject",
")",
"{",
"try",
"{",
"GVRMeshCollider",
"collider",
"=",
"new",
"GVRMeshCollider",
"(",
"sceneObject",
".",
"getGVRContext",
"(",
")",
",",
"false",
")",
";",
"sceneObject",
".",
"attachComponent",
"(",
"collider",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Possible that some objects (X3D panel nodes) are without mesh",
"Log",
".",
"e",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"INPUT",
",",
"TAG",
",",
"\"makePickable(): possible that some objects (X3D panel nodes) are without mesh!\"",
")",
";",
"}",
"}"
] | Makes the scene object pickable by eyes. However, the object has to be touchable to process
the touch events.
@param sceneObject | [
"Makes",
"the",
"scene",
"object",
"pickable",
"by",
"eyes",
".",
"However",
"the",
"object",
"has",
"to",
"be",
"touchable",
"to",
"process",
"the",
"touch",
"events",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/TouchManager.java#L104-L112 |
161,550 | Samsung/GearVRf | GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableUtility.java | GearWearableUtility.isInCircle | static boolean isInCircle(float x, float y, float centerX, float centerY, float
radius) {
return Math.abs(x - centerX) < radius && Math.abs(y - centerY) < radius;
} | java | static boolean isInCircle(float x, float y, float centerX, float centerY, float
radius) {
return Math.abs(x - centerX) < radius && Math.abs(y - centerY) < radius;
} | [
"static",
"boolean",
"isInCircle",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"centerX",
",",
"float",
"centerY",
",",
"float",
"radius",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"x",
"-",
"centerX",
")",
"<",
"radius",
"&&",
"Math",
".",
"abs",
"(",
"y",
"-",
"centerY",
")",
"<",
"radius",
";",
"}"
] | Check if a position is within a circle
@param x x position
@param y y position
@param centerX center x of circle
@param centerY center y of circle
@return true if within circle, false otherwise | [
"Check",
"if",
"a",
"position",
"is",
"within",
"a",
"circle"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/3DCursor/IODevices/gearwear/GearWearIoDevice/src/main/java/com/gearvrf/io/gearwear/GearWearableUtility.java#L13-L16 |
161,551 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/keyframe/GVRRotationKey.java | GVRRotationKey.setValue | public void setValue(Quaternionf rot) {
mX = rot.x;
mY = rot.y;
mZ = rot.z;
mW = rot.w;
} | java | public void setValue(Quaternionf rot) {
mX = rot.x;
mY = rot.y;
mZ = rot.z;
mW = rot.w;
} | [
"public",
"void",
"setValue",
"(",
"Quaternionf",
"rot",
")",
"{",
"mX",
"=",
"rot",
".",
"x",
";",
"mY",
"=",
"rot",
".",
"y",
";",
"mZ",
"=",
"rot",
".",
"z",
";",
"mW",
"=",
"rot",
".",
"w",
";",
"}"
] | Sets the quaternion of the keyframe. | [
"Sets",
"the",
"quaternion",
"of",
"the",
"keyframe",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/keyframe/GVRRotationKey.java#L44-L49 |
161,552 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRFloatImage.java | GVRFloatImage.update | public void update(int width, int height, float[] data)
throws IllegalArgumentException
{
if ((width <= 0) || (height <= 0) ||
(data == null) || (data.length < height * width * mFloatsPerPixel))
{
throw new IllegalArgumentException();
}
NativeFloatImage.update(getNative(), width, height, 0, data);
} | java | public void update(int width, int height, float[] data)
throws IllegalArgumentException
{
if ((width <= 0) || (height <= 0) ||
(data == null) || (data.length < height * width * mFloatsPerPixel))
{
throw new IllegalArgumentException();
}
NativeFloatImage.update(getNative(), width, height, 0, data);
} | [
"public",
"void",
"update",
"(",
"int",
"width",
",",
"int",
"height",
",",
"float",
"[",
"]",
"data",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"(",
"width",
"<=",
"0",
")",
"||",
"(",
"height",
"<=",
"0",
")",
"||",
"(",
"data",
"==",
"null",
")",
"||",
"(",
"data",
".",
"length",
"<",
"height",
"*",
"width",
"*",
"mFloatsPerPixel",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"NativeFloatImage",
".",
"update",
"(",
"getNative",
"(",
")",
",",
"width",
",",
"height",
",",
"0",
",",
"data",
")",
";",
"}"
] | Copy new data to an existing float-point texture.
Creating a new {@link GVRFloatImage} is pretty cheap, but it's still
not a totally trivial operation: it does involve some memory management
and some GL hardware handshaking. Reusing the texture reduces this
overhead (primarily by delaying garbage collection). Do be aware that
updating a texture will affect any and all {@linkplain GVRMaterial
materials} (and/or post effects that use the texture!
@param width
Texture width, in pixels
@param height
Texture height, in pixels
@param data
A linear array of float pairs.
@return {@code true} if the updateGPU succeeded, and {@code false} if it
failed. Updating a texture requires that the new data parameter
has the exact same {@code width} and {@code height} and pixel
format as the original data.
@throws IllegalArgumentException
If {@code width} or {@code height} is {@literal <= 0,} or if
{@code data} is {@code null}, or if
{@code data.length < height * width * 2} | [
"Copy",
"new",
"data",
"to",
"an",
"existing",
"float",
"-",
"point",
"texture",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRFloatImage.java#L92-L101 |
161,553 | Samsung/GearVRf | GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/node/ImageTexture.java | ImageTexture.getUrl | public String[] getUrl() {
String[] valueDestination = new String[ url.size() ];
this.url.getValue(valueDestination);
return valueDestination;
} | java | public String[] getUrl() {
String[] valueDestination = new String[ url.size() ];
this.url.getValue(valueDestination);
return valueDestination;
} | [
"public",
"String",
"[",
"]",
"getUrl",
"(",
")",
"{",
"String",
"[",
"]",
"valueDestination",
"=",
"new",
"String",
"[",
"url",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"url",
".",
"getValue",
"(",
"valueDestination",
")",
";",
"return",
"valueDestination",
";",
"}"
] | Provide array of String results from inputOutput MFString field named url.
@array saved in valueDestination | [
"Provide",
"array",
"of",
"String",
"results",
"from",
"inputOutput",
"MFString",
"field",
"named",
"url",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/node/ImageTexture.java#L68-L72 |
161,554 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/basic/ArchLayout.java | ArchLayout.getSizeArcLength | protected float getSizeArcLength(float angle) {
if (mRadius <= 0) {
throw new IllegalArgumentException("mRadius is not specified!");
}
return angle == Float.MAX_VALUE ? Float.MAX_VALUE :
LayoutHelpers.lengthOfArc(angle, mRadius);
} | java | protected float getSizeArcLength(float angle) {
if (mRadius <= 0) {
throw new IllegalArgumentException("mRadius is not specified!");
}
return angle == Float.MAX_VALUE ? Float.MAX_VALUE :
LayoutHelpers.lengthOfArc(angle, mRadius);
} | [
"protected",
"float",
"getSizeArcLength",
"(",
"float",
"angle",
")",
"{",
"if",
"(",
"mRadius",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"mRadius is not specified!\"",
")",
";",
"}",
"return",
"angle",
"==",
"Float",
".",
"MAX_VALUE",
"?",
"Float",
".",
"MAX_VALUE",
":",
"LayoutHelpers",
".",
"lengthOfArc",
"(",
"angle",
",",
"mRadius",
")",
";",
"}"
] | Calculate the arc length by angle and radius
@param angle
@return arc length | [
"Calculate",
"the",
"arc",
"length",
"by",
"angle",
"and",
"radius"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/basic/ArchLayout.java#L114-L120 |
161,555 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsole.java | GVRConsole.writeLine | public void writeLine(String pattern, Object... parameters) {
String line = (parameters == null || parameters.length == 0) ? pattern
: String.format(pattern, parameters);
lines.add(0, line); // we'll write bottom to top, then purge unwritten
// lines from end
updateHUD();
} | java | public void writeLine(String pattern, Object... parameters) {
String line = (parameters == null || parameters.length == 0) ? pattern
: String.format(pattern, parameters);
lines.add(0, line); // we'll write bottom to top, then purge unwritten
// lines from end
updateHUD();
} | [
"public",
"void",
"writeLine",
"(",
"String",
"pattern",
",",
"Object",
"...",
"parameters",
")",
"{",
"String",
"line",
"=",
"(",
"parameters",
"==",
"null",
"||",
"parameters",
".",
"length",
"==",
"0",
")",
"?",
"pattern",
":",
"String",
".",
"format",
"(",
"pattern",
",",
"parameters",
")",
";",
"lines",
".",
"add",
"(",
"0",
",",
"line",
")",
";",
"// we'll write bottom to top, then purge unwritten",
"// lines from end",
"updateHUD",
"(",
")",
";",
"}"
] | Write a message to the console.
@param pattern
A {@link String#format(String, Object...)} pattern
@param parameters
Optional parameters to plug into the pattern | [
"Write",
"a",
"message",
"to",
"the",
"console",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsole.java#L178-L184 |
161,556 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsole.java | GVRConsole.setCanvasWidthHeight | public void setCanvasWidthHeight(int width, int height) {
hudWidth = width;
hudHeight = height;
HUD = Bitmap.createBitmap(width, height, Config.ARGB_8888);
canvas = new Canvas(HUD);
texture = null;
} | java | public void setCanvasWidthHeight(int width, int height) {
hudWidth = width;
hudHeight = height;
HUD = Bitmap.createBitmap(width, height, Config.ARGB_8888);
canvas = new Canvas(HUD);
texture = null;
} | [
"public",
"void",
"setCanvasWidthHeight",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"hudWidth",
"=",
"width",
";",
"hudHeight",
"=",
"height",
";",
"HUD",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"width",
",",
"height",
",",
"Config",
".",
"ARGB_8888",
")",
";",
"canvas",
"=",
"new",
"Canvas",
"(",
"HUD",
")",
";",
"texture",
"=",
"null",
";",
"}"
] | Sets the width and height of the canvas the text is drawn to.
@param width
width of the new canvas.
@param height
hegiht of the new canvas. | [
"Sets",
"the",
"width",
"and",
"height",
"of",
"the",
"canvas",
"the",
"text",
"is",
"drawn",
"to",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/debug/GVRConsole.java#L336-L342 |
161,557 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java | MeshUtils.scale | public static void scale(GVRMesh mesh, float x, float y, float z) {
final float [] vertices = mesh.getVertices();
final int vsize = vertices.length;
for (int i = 0; i < vsize; i += 3) {
vertices[i] *= x;
vertices[i + 1] *= y;
vertices[i + 2] *= z;
}
mesh.setVertices(vertices);
} | java | public static void scale(GVRMesh mesh, float x, float y, float z) {
final float [] vertices = mesh.getVertices();
final int vsize = vertices.length;
for (int i = 0; i < vsize; i += 3) {
vertices[i] *= x;
vertices[i + 1] *= y;
vertices[i + 2] *= z;
}
mesh.setVertices(vertices);
} | [
"public",
"static",
"void",
"scale",
"(",
"GVRMesh",
"mesh",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
")",
"{",
"final",
"float",
"[",
"]",
"vertices",
"=",
"mesh",
".",
"getVertices",
"(",
")",
";",
"final",
"int",
"vsize",
"=",
"vertices",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vsize",
";",
"i",
"+=",
"3",
")",
"{",
"vertices",
"[",
"i",
"]",
"*=",
"x",
";",
"vertices",
"[",
"i",
"+",
"1",
"]",
"*=",
"y",
";",
"vertices",
"[",
"i",
"+",
"2",
"]",
"*=",
"z",
";",
"}",
"mesh",
".",
"setVertices",
"(",
"vertices",
")",
";",
"}"
] | Scale the mesh at x, y and z axis.
@param mesh Mesh to be scaled.
@param x Scale to be applied on x-axis.
@param y Scale to be applied on y-axis.
@param z Scale to be applied on z-axis. | [
"Scale",
"the",
"mesh",
"at",
"x",
"y",
"and",
"z",
"axis",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java#L35-L46 |
161,558 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java | MeshUtils.resize | public static void resize(GVRMesh mesh, float xsize, float ysize, float zsize) {
float dim[] = getBoundingSize(mesh);
scale(mesh, xsize / dim[0], ysize / dim[1], zsize / dim[2]);
} | java | public static void resize(GVRMesh mesh, float xsize, float ysize, float zsize) {
float dim[] = getBoundingSize(mesh);
scale(mesh, xsize / dim[0], ysize / dim[1], zsize / dim[2]);
} | [
"public",
"static",
"void",
"resize",
"(",
"GVRMesh",
"mesh",
",",
"float",
"xsize",
",",
"float",
"ysize",
",",
"float",
"zsize",
")",
"{",
"float",
"dim",
"[",
"]",
"=",
"getBoundingSize",
"(",
"mesh",
")",
";",
"scale",
"(",
"mesh",
",",
"xsize",
"/",
"dim",
"[",
"0",
"]",
",",
"ysize",
"/",
"dim",
"[",
"1",
"]",
",",
"zsize",
"/",
"dim",
"[",
"2",
"]",
")",
";",
"}"
] | Resize the mesh to given size for each axis.
@param mesh Mesh to be resized.
@param xsize Size for x-axis.
@param ysize Size for y-axis.
@param zsize Size fof z-axis. | [
"Resize",
"the",
"mesh",
"to",
"given",
"size",
"for",
"each",
"axis",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java#L66-L70 |
161,559 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java | MeshUtils.resize | public static void resize(GVRMesh mesh, float size) {
float dim[] = getBoundingSize(mesh);
float maxsize = 0.0f;
if (dim[0] > maxsize) maxsize = dim[0];
if (dim[1] > maxsize) maxsize = dim[1];
if (dim[2] > maxsize) maxsize = dim[2];
scale(mesh, size / maxsize);
} | java | public static void resize(GVRMesh mesh, float size) {
float dim[] = getBoundingSize(mesh);
float maxsize = 0.0f;
if (dim[0] > maxsize) maxsize = dim[0];
if (dim[1] > maxsize) maxsize = dim[1];
if (dim[2] > maxsize) maxsize = dim[2];
scale(mesh, size / maxsize);
} | [
"public",
"static",
"void",
"resize",
"(",
"GVRMesh",
"mesh",
",",
"float",
"size",
")",
"{",
"float",
"dim",
"[",
"]",
"=",
"getBoundingSize",
"(",
"mesh",
")",
";",
"float",
"maxsize",
"=",
"0.0f",
";",
"if",
"(",
"dim",
"[",
"0",
"]",
">",
"maxsize",
")",
"maxsize",
"=",
"dim",
"[",
"0",
"]",
";",
"if",
"(",
"dim",
"[",
"1",
"]",
">",
"maxsize",
")",
"maxsize",
"=",
"dim",
"[",
"1",
"]",
";",
"if",
"(",
"dim",
"[",
"2",
"]",
">",
"maxsize",
")",
"maxsize",
"=",
"dim",
"[",
"2",
"]",
";",
"scale",
"(",
"mesh",
",",
"size",
"/",
"maxsize",
")",
";",
"}"
] | Resize the given mesh keeping its aspect ration.
@param mesh Mesh to be resized.
@param size Max size for the axis. | [
"Resize",
"the",
"given",
"mesh",
"keeping",
"its",
"aspect",
"ration",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java#L77-L86 |
161,560 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java | MeshUtils.getBoundingSize | public static float[] getBoundingSize(GVRMesh mesh) {
final float [] dim = new float[3];
final float [] vertices = mesh.getVertices();
final int vsize = vertices.length;
float minx = Integer.MAX_VALUE;
float miny = Integer.MAX_VALUE;
float minz = Integer.MAX_VALUE;
float maxx = Integer.MIN_VALUE;
float maxy = Integer.MIN_VALUE;
float maxz = Integer.MIN_VALUE;
for (int i = 0; i < vsize; i += 3) {
if (vertices[i] < minx) minx = vertices[i];
if (vertices[i] > maxx) maxx = vertices[i];
if (vertices[i + 1] < miny) miny = vertices[i + 1];
if (vertices[i + 1] > maxy) maxy = vertices[i + 1];
if (vertices[i + 2] < minz) minz = vertices[i + 2];
if (vertices[i + 2] > maxz) maxz = vertices[i + 2];
}
dim[0] = maxx - minx;
dim[1] = maxy - miny;
dim[2] = maxz - minz;
return dim;
} | java | public static float[] getBoundingSize(GVRMesh mesh) {
final float [] dim = new float[3];
final float [] vertices = mesh.getVertices();
final int vsize = vertices.length;
float minx = Integer.MAX_VALUE;
float miny = Integer.MAX_VALUE;
float minz = Integer.MAX_VALUE;
float maxx = Integer.MIN_VALUE;
float maxy = Integer.MIN_VALUE;
float maxz = Integer.MIN_VALUE;
for (int i = 0; i < vsize; i += 3) {
if (vertices[i] < minx) minx = vertices[i];
if (vertices[i] > maxx) maxx = vertices[i];
if (vertices[i + 1] < miny) miny = vertices[i + 1];
if (vertices[i + 1] > maxy) maxy = vertices[i + 1];
if (vertices[i + 2] < minz) minz = vertices[i + 2];
if (vertices[i + 2] > maxz) maxz = vertices[i + 2];
}
dim[0] = maxx - minx;
dim[1] = maxy - miny;
dim[2] = maxz - minz;
return dim;
} | [
"public",
"static",
"float",
"[",
"]",
"getBoundingSize",
"(",
"GVRMesh",
"mesh",
")",
"{",
"final",
"float",
"[",
"]",
"dim",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"final",
"float",
"[",
"]",
"vertices",
"=",
"mesh",
".",
"getVertices",
"(",
")",
";",
"final",
"int",
"vsize",
"=",
"vertices",
".",
"length",
";",
"float",
"minx",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"float",
"miny",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"float",
"minz",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"float",
"maxx",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"float",
"maxy",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"float",
"maxz",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vsize",
";",
"i",
"+=",
"3",
")",
"{",
"if",
"(",
"vertices",
"[",
"i",
"]",
"<",
"minx",
")",
"minx",
"=",
"vertices",
"[",
"i",
"]",
";",
"if",
"(",
"vertices",
"[",
"i",
"]",
">",
"maxx",
")",
"maxx",
"=",
"vertices",
"[",
"i",
"]",
";",
"if",
"(",
"vertices",
"[",
"i",
"+",
"1",
"]",
"<",
"miny",
")",
"miny",
"=",
"vertices",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"vertices",
"[",
"i",
"+",
"1",
"]",
">",
"maxy",
")",
"maxy",
"=",
"vertices",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"vertices",
"[",
"i",
"+",
"2",
"]",
"<",
"minz",
")",
"minz",
"=",
"vertices",
"[",
"i",
"+",
"2",
"]",
";",
"if",
"(",
"vertices",
"[",
"i",
"+",
"2",
"]",
">",
"maxz",
")",
"maxz",
"=",
"vertices",
"[",
"i",
"+",
"2",
"]",
";",
"}",
"dim",
"[",
"0",
"]",
"=",
"maxx",
"-",
"minx",
";",
"dim",
"[",
"1",
"]",
"=",
"maxy",
"-",
"miny",
";",
"dim",
"[",
"2",
"]",
"=",
"maxz",
"-",
"minz",
";",
"return",
"dim",
";",
"}"
] | Calcs the bonding size of given mesh.
@param mesh Mesh to calc its bouding size.
@return The bounding size for x, y and z axis. | [
"Calcs",
"the",
"bonding",
"size",
"of",
"given",
"mesh",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java#L107-L134 |
161,561 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java | MeshUtils.createQuad | public static GVRMesh createQuad(GVRContext gvrContext, float width, float height) {
GVRMesh mesh = new GVRMesh(gvrContext);
float[] vertices = { width * -0.5f, height * 0.5f, 0.0f, width * -0.5f,
height * -0.5f, 0.0f, width * 0.5f, height * 0.5f, 0.0f,
width * 0.5f, height * -0.5f, 0.0f };
mesh.setVertices(vertices);
final float[] normals = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 1.0f };
mesh.setNormals(normals);
final float[] texCoords = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,
1.0f };
mesh.setTexCoords(texCoords);
char[] triangles = { 0, 1, 2, 1, 3, 2 };
mesh.setIndices(triangles);
return mesh;
} | java | public static GVRMesh createQuad(GVRContext gvrContext, float width, float height) {
GVRMesh mesh = new GVRMesh(gvrContext);
float[] vertices = { width * -0.5f, height * 0.5f, 0.0f, width * -0.5f,
height * -0.5f, 0.0f, width * 0.5f, height * 0.5f, 0.0f,
width * 0.5f, height * -0.5f, 0.0f };
mesh.setVertices(vertices);
final float[] normals = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 1.0f };
mesh.setNormals(normals);
final float[] texCoords = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f,
1.0f };
mesh.setTexCoords(texCoords);
char[] triangles = { 0, 1, 2, 1, 3, 2 };
mesh.setIndices(triangles);
return mesh;
} | [
"public",
"static",
"GVRMesh",
"createQuad",
"(",
"GVRContext",
"gvrContext",
",",
"float",
"width",
",",
"float",
"height",
")",
"{",
"GVRMesh",
"mesh",
"=",
"new",
"GVRMesh",
"(",
"gvrContext",
")",
";",
"float",
"[",
"]",
"vertices",
"=",
"{",
"width",
"*",
"-",
"0.5f",
",",
"height",
"*",
"0.5f",
",",
"0.0f",
",",
"width",
"*",
"-",
"0.5f",
",",
"height",
"*",
"-",
"0.5f",
",",
"0.0f",
",",
"width",
"*",
"0.5f",
",",
"height",
"*",
"0.5f",
",",
"0.0f",
",",
"width",
"*",
"0.5f",
",",
"height",
"*",
"-",
"0.5f",
",",
"0.0f",
"}",
";",
"mesh",
".",
"setVertices",
"(",
"vertices",
")",
";",
"final",
"float",
"[",
"]",
"normals",
"=",
"{",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
"}",
";",
"mesh",
".",
"setNormals",
"(",
"normals",
")",
";",
"final",
"float",
"[",
"]",
"texCoords",
"=",
"{",
"0.0f",
",",
"0.0f",
",",
"0.0f",
",",
"1.0f",
",",
"1.0f",
",",
"0.0f",
",",
"1.0f",
",",
"1.0f",
"}",
";",
"mesh",
".",
"setTexCoords",
"(",
"texCoords",
")",
";",
"char",
"[",
"]",
"triangles",
"=",
"{",
"0",
",",
"1",
",",
"2",
",",
"1",
",",
"3",
",",
"2",
"}",
";",
"mesh",
".",
"setIndices",
"(",
"triangles",
")",
";",
"return",
"mesh",
";",
"}"
] | Creates a quad consisting of two triangles, with the specified width and
height.
@param gvrContext current {@link GVRContext}
@param width
the quad's width
@param height
the quad's height
@return A 2D, rectangular mesh with four vertices and two triangles | [
"Creates",
"a",
"quad",
"consisting",
"of",
"two",
"triangles",
"with",
"the",
"specified",
"width",
"and",
"height",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/utility/MeshUtils.java#L148-L168 |
161,562 | Samsung/GearVRf | GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java | OvrViewManager.onSurfaceChanged | void onSurfaceChanged(int width, int height) {
Log.v(TAG, "onSurfaceChanged");
final VrAppSettings.EyeBufferParams.DepthFormat depthFormat = mApplication.getAppSettings().getEyeBufferParams().getDepthFormat();
mApplication.getConfigurationManager().configureRendering(VrAppSettings.EyeBufferParams.DepthFormat.DEPTH_24_STENCIL_8 == depthFormat);
} | java | void onSurfaceChanged(int width, int height) {
Log.v(TAG, "onSurfaceChanged");
final VrAppSettings.EyeBufferParams.DepthFormat depthFormat = mApplication.getAppSettings().getEyeBufferParams().getDepthFormat();
mApplication.getConfigurationManager().configureRendering(VrAppSettings.EyeBufferParams.DepthFormat.DEPTH_24_STENCIL_8 == depthFormat);
} | [
"void",
"onSurfaceChanged",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onSurfaceChanged\"",
")",
";",
"final",
"VrAppSettings",
".",
"EyeBufferParams",
".",
"DepthFormat",
"depthFormat",
"=",
"mApplication",
".",
"getAppSettings",
"(",
")",
".",
"getEyeBufferParams",
"(",
")",
".",
"getDepthFormat",
"(",
")",
";",
"mApplication",
".",
"getConfigurationManager",
"(",
")",
".",
"configureRendering",
"(",
"VrAppSettings",
".",
"EyeBufferParams",
".",
"DepthFormat",
".",
"DEPTH_24_STENCIL_8",
"==",
"depthFormat",
")",
";",
"}"
] | Called when the surface is created or recreated. Avoided because this can
be called twice at the beginning. | [
"Called",
"when",
"the",
"surface",
"is",
"created",
"or",
"recreated",
".",
"Avoided",
"because",
"this",
"can",
"be",
"called",
"twice",
"at",
"the",
"beginning",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java#L145-L150 |
161,563 | Samsung/GearVRf | GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java | OvrViewManager.onDrawEye | void onDrawEye(int eye, int swapChainIndex, boolean use_multiview) {
mCurrentEye = eye;
if (!(mSensoredScene == null || !mMainScene.equals(mSensoredScene))) {
GVRCameraRig mainCameraRig = mMainScene.getMainCameraRig();
if (use_multiview) {
if (DEBUG_STATS) {
mTracerDrawEyes1.enter(); // this eye is drawn first
mTracerDrawEyes2.enter();
}
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.MULTIVIEW, swapChainIndex);
GVRCamera camera = mMainScene.getMainCameraRig().getCenterCamera();
GVRCamera left_camera = mMainScene.getMainCameraRig().getLeftCamera();
renderTarget.cullFromCamera(mMainScene, camera,mRenderBundle.getShaderManager());
captureCenterEye(renderTarget, true);
capture3DScreenShot(renderTarget, true);
renderTarget.render(mMainScene, left_camera, mRenderBundle.getShaderManager(),mRenderBundle.getPostEffectRenderTextureA(),
mRenderBundle.getPostEffectRenderTextureB());
captureRightEye(renderTarget, true);
captureLeftEye(renderTarget, true);
captureFinish();
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes2.leave();
}
} else {
if (eye == 1) {
if (DEBUG_STATS) {
mTracerDrawEyes1.enter();
}
GVRCamera rightCamera = mainCameraRig.getRightCamera();
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.RIGHT, swapChainIndex);
renderTarget.render(mMainScene, rightCamera, mRenderBundle.getShaderManager(), mRenderBundle.getPostEffectRenderTextureA(),
mRenderBundle.getPostEffectRenderTextureB());
captureRightEye(renderTarget, false);
captureFinish();
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes.leave();
}
} else {
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes.leave();
}
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.LEFT, swapChainIndex);
GVRCamera leftCamera = mainCameraRig.getLeftCamera();
capture3DScreenShot(renderTarget, false);
renderTarget.cullFromCamera(mMainScene, mainCameraRig.getCenterCamera(), mRenderBundle.getShaderManager());
captureCenterEye(renderTarget, false);
renderTarget.render(mMainScene, leftCamera, mRenderBundle.getShaderManager(), mRenderBundle.getPostEffectRenderTextureA(), mRenderBundle.getPostEffectRenderTextureB());
captureLeftEye(renderTarget, false);
if (DEBUG_STATS) {
mTracerDrawEyes2.leave();
}
}
}
}
} | java | void onDrawEye(int eye, int swapChainIndex, boolean use_multiview) {
mCurrentEye = eye;
if (!(mSensoredScene == null || !mMainScene.equals(mSensoredScene))) {
GVRCameraRig mainCameraRig = mMainScene.getMainCameraRig();
if (use_multiview) {
if (DEBUG_STATS) {
mTracerDrawEyes1.enter(); // this eye is drawn first
mTracerDrawEyes2.enter();
}
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.MULTIVIEW, swapChainIndex);
GVRCamera camera = mMainScene.getMainCameraRig().getCenterCamera();
GVRCamera left_camera = mMainScene.getMainCameraRig().getLeftCamera();
renderTarget.cullFromCamera(mMainScene, camera,mRenderBundle.getShaderManager());
captureCenterEye(renderTarget, true);
capture3DScreenShot(renderTarget, true);
renderTarget.render(mMainScene, left_camera, mRenderBundle.getShaderManager(),mRenderBundle.getPostEffectRenderTextureA(),
mRenderBundle.getPostEffectRenderTextureB());
captureRightEye(renderTarget, true);
captureLeftEye(renderTarget, true);
captureFinish();
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes2.leave();
}
} else {
if (eye == 1) {
if (DEBUG_STATS) {
mTracerDrawEyes1.enter();
}
GVRCamera rightCamera = mainCameraRig.getRightCamera();
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.RIGHT, swapChainIndex);
renderTarget.render(mMainScene, rightCamera, mRenderBundle.getShaderManager(), mRenderBundle.getPostEffectRenderTextureA(),
mRenderBundle.getPostEffectRenderTextureB());
captureRightEye(renderTarget, false);
captureFinish();
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes.leave();
}
} else {
if (DEBUG_STATS) {
mTracerDrawEyes1.leave();
mTracerDrawEyes.leave();
}
GVRRenderTarget renderTarget = mRenderBundle.getRenderTarget(EYE.LEFT, swapChainIndex);
GVRCamera leftCamera = mainCameraRig.getLeftCamera();
capture3DScreenShot(renderTarget, false);
renderTarget.cullFromCamera(mMainScene, mainCameraRig.getCenterCamera(), mRenderBundle.getShaderManager());
captureCenterEye(renderTarget, false);
renderTarget.render(mMainScene, leftCamera, mRenderBundle.getShaderManager(), mRenderBundle.getPostEffectRenderTextureA(), mRenderBundle.getPostEffectRenderTextureB());
captureLeftEye(renderTarget, false);
if (DEBUG_STATS) {
mTracerDrawEyes2.leave();
}
}
}
}
} | [
"void",
"onDrawEye",
"(",
"int",
"eye",
",",
"int",
"swapChainIndex",
",",
"boolean",
"use_multiview",
")",
"{",
"mCurrentEye",
"=",
"eye",
";",
"if",
"(",
"!",
"(",
"mSensoredScene",
"==",
"null",
"||",
"!",
"mMainScene",
".",
"equals",
"(",
"mSensoredScene",
")",
")",
")",
"{",
"GVRCameraRig",
"mainCameraRig",
"=",
"mMainScene",
".",
"getMainCameraRig",
"(",
")",
";",
"if",
"(",
"use_multiview",
")",
"{",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes1",
".",
"enter",
"(",
")",
";",
"// this eye is drawn first",
"mTracerDrawEyes2",
".",
"enter",
"(",
")",
";",
"}",
"GVRRenderTarget",
"renderTarget",
"=",
"mRenderBundle",
".",
"getRenderTarget",
"(",
"EYE",
".",
"MULTIVIEW",
",",
"swapChainIndex",
")",
";",
"GVRCamera",
"camera",
"=",
"mMainScene",
".",
"getMainCameraRig",
"(",
")",
".",
"getCenterCamera",
"(",
")",
";",
"GVRCamera",
"left_camera",
"=",
"mMainScene",
".",
"getMainCameraRig",
"(",
")",
".",
"getLeftCamera",
"(",
")",
";",
"renderTarget",
".",
"cullFromCamera",
"(",
"mMainScene",
",",
"camera",
",",
"mRenderBundle",
".",
"getShaderManager",
"(",
")",
")",
";",
"captureCenterEye",
"(",
"renderTarget",
",",
"true",
")",
";",
"capture3DScreenShot",
"(",
"renderTarget",
",",
"true",
")",
";",
"renderTarget",
".",
"render",
"(",
"mMainScene",
",",
"left_camera",
",",
"mRenderBundle",
".",
"getShaderManager",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureA",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureB",
"(",
")",
")",
";",
"captureRightEye",
"(",
"renderTarget",
",",
"true",
")",
";",
"captureLeftEye",
"(",
"renderTarget",
",",
"true",
")",
";",
"captureFinish",
"(",
")",
";",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes1",
".",
"leave",
"(",
")",
";",
"mTracerDrawEyes2",
".",
"leave",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"eye",
"==",
"1",
")",
"{",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes1",
".",
"enter",
"(",
")",
";",
"}",
"GVRCamera",
"rightCamera",
"=",
"mainCameraRig",
".",
"getRightCamera",
"(",
")",
";",
"GVRRenderTarget",
"renderTarget",
"=",
"mRenderBundle",
".",
"getRenderTarget",
"(",
"EYE",
".",
"RIGHT",
",",
"swapChainIndex",
")",
";",
"renderTarget",
".",
"render",
"(",
"mMainScene",
",",
"rightCamera",
",",
"mRenderBundle",
".",
"getShaderManager",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureA",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureB",
"(",
")",
")",
";",
"captureRightEye",
"(",
"renderTarget",
",",
"false",
")",
";",
"captureFinish",
"(",
")",
";",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes1",
".",
"leave",
"(",
")",
";",
"mTracerDrawEyes",
".",
"leave",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes1",
".",
"leave",
"(",
")",
";",
"mTracerDrawEyes",
".",
"leave",
"(",
")",
";",
"}",
"GVRRenderTarget",
"renderTarget",
"=",
"mRenderBundle",
".",
"getRenderTarget",
"(",
"EYE",
".",
"LEFT",
",",
"swapChainIndex",
")",
";",
"GVRCamera",
"leftCamera",
"=",
"mainCameraRig",
".",
"getLeftCamera",
"(",
")",
";",
"capture3DScreenShot",
"(",
"renderTarget",
",",
"false",
")",
";",
"renderTarget",
".",
"cullFromCamera",
"(",
"mMainScene",
",",
"mainCameraRig",
".",
"getCenterCamera",
"(",
")",
",",
"mRenderBundle",
".",
"getShaderManager",
"(",
")",
")",
";",
"captureCenterEye",
"(",
"renderTarget",
",",
"false",
")",
";",
"renderTarget",
".",
"render",
"(",
"mMainScene",
",",
"leftCamera",
",",
"mRenderBundle",
".",
"getShaderManager",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureA",
"(",
")",
",",
"mRenderBundle",
".",
"getPostEffectRenderTextureB",
"(",
")",
")",
";",
"captureLeftEye",
"(",
"renderTarget",
",",
"false",
")",
";",
"if",
"(",
"DEBUG_STATS",
")",
"{",
"mTracerDrawEyes2",
".",
"leave",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Called from the native side
@param eye | [
"Called",
"from",
"the",
"native",
"side"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/backend_oculus/src/main/java/org/gearvrf/OvrViewManager.java#L174-L249 |
161,564 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRResourceVolume.java | GVRResourceVolume.openResource | public GVRAndroidResource openResource(String filePath) throws IOException {
// Error tolerance: Remove initial '/' introduced by file::///filename
// In this case, the path is interpreted as relative to defaultPath,
// which is the root of the filesystem.
if (filePath.startsWith(File.separator)) {
filePath = filePath.substring(File.separator.length());
}
filePath = adaptFilePath(filePath);
String path;
int resourceId;
GVRAndroidResource resourceKey;
switch (volumeType) {
case ANDROID_ASSETS:
// Resolve '..' and '.'
path = getFullPath(defaultPath, filePath);
path = new File(path).getCanonicalPath();
if (path.startsWith(File.separator)) {
path = path.substring(1);
}
resourceKey = new GVRAndroidResource(gvrContext, path);
break;
case ANDROID_RESOURCE:
path = FileNameUtils.getBaseName(filePath);
resourceId = gvrContext.getContext().getResources().getIdentifier(path, "raw", gvrContext.getContext().getPackageName());
if (resourceId == 0) {
throw new FileNotFoundException(filePath + " resource not found");
}
resourceKey = new GVRAndroidResource(gvrContext, resourceId);
break;
case LINUX_FILESYSTEM:
resourceKey = new GVRAndroidResource(
getFullPath(defaultPath, filePath));
break;
case ANDROID_SDCARD:
String linuxPath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
resourceKey = new GVRAndroidResource(
getFullPath(linuxPath, defaultPath, filePath));
break;
case INPUT_STREAM:
resourceKey = new GVRAndroidResource(getFullPath(defaultPath, filePath), volumeInputStream);
break;
case NETWORK:
resourceKey = new GVRAndroidResource(gvrContext,
getFullURL(defaultPath, filePath), enableUrlLocalCache);
break;
default:
throw new IOException(
String.format("Unrecognized volumeType %s", volumeType));
}
return addResource(resourceKey);
} | java | public GVRAndroidResource openResource(String filePath) throws IOException {
// Error tolerance: Remove initial '/' introduced by file::///filename
// In this case, the path is interpreted as relative to defaultPath,
// which is the root of the filesystem.
if (filePath.startsWith(File.separator)) {
filePath = filePath.substring(File.separator.length());
}
filePath = adaptFilePath(filePath);
String path;
int resourceId;
GVRAndroidResource resourceKey;
switch (volumeType) {
case ANDROID_ASSETS:
// Resolve '..' and '.'
path = getFullPath(defaultPath, filePath);
path = new File(path).getCanonicalPath();
if (path.startsWith(File.separator)) {
path = path.substring(1);
}
resourceKey = new GVRAndroidResource(gvrContext, path);
break;
case ANDROID_RESOURCE:
path = FileNameUtils.getBaseName(filePath);
resourceId = gvrContext.getContext().getResources().getIdentifier(path, "raw", gvrContext.getContext().getPackageName());
if (resourceId == 0) {
throw new FileNotFoundException(filePath + " resource not found");
}
resourceKey = new GVRAndroidResource(gvrContext, resourceId);
break;
case LINUX_FILESYSTEM:
resourceKey = new GVRAndroidResource(
getFullPath(defaultPath, filePath));
break;
case ANDROID_SDCARD:
String linuxPath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
resourceKey = new GVRAndroidResource(
getFullPath(linuxPath, defaultPath, filePath));
break;
case INPUT_STREAM:
resourceKey = new GVRAndroidResource(getFullPath(defaultPath, filePath), volumeInputStream);
break;
case NETWORK:
resourceKey = new GVRAndroidResource(gvrContext,
getFullURL(defaultPath, filePath), enableUrlLocalCache);
break;
default:
throw new IOException(
String.format("Unrecognized volumeType %s", volumeType));
}
return addResource(resourceKey);
} | [
"public",
"GVRAndroidResource",
"openResource",
"(",
"String",
"filePath",
")",
"throws",
"IOException",
"{",
"// Error tolerance: Remove initial '/' introduced by file::///filename",
"// In this case, the path is interpreted as relative to defaultPath,",
"// which is the root of the filesystem.",
"if",
"(",
"filePath",
".",
"startsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"filePath",
"=",
"filePath",
".",
"substring",
"(",
"File",
".",
"separator",
".",
"length",
"(",
")",
")",
";",
"}",
"filePath",
"=",
"adaptFilePath",
"(",
"filePath",
")",
";",
"String",
"path",
";",
"int",
"resourceId",
";",
"GVRAndroidResource",
"resourceKey",
";",
"switch",
"(",
"volumeType",
")",
"{",
"case",
"ANDROID_ASSETS",
":",
"// Resolve '..' and '.'",
"path",
"=",
"getFullPath",
"(",
"defaultPath",
",",
"filePath",
")",
";",
"path",
"=",
"new",
"File",
"(",
"path",
")",
".",
"getCanonicalPath",
"(",
")",
";",
"if",
"(",
"path",
".",
"startsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"path",
"=",
"path",
".",
"substring",
"(",
"1",
")",
";",
"}",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"gvrContext",
",",
"path",
")",
";",
"break",
";",
"case",
"ANDROID_RESOURCE",
":",
"path",
"=",
"FileNameUtils",
".",
"getBaseName",
"(",
"filePath",
")",
";",
"resourceId",
"=",
"gvrContext",
".",
"getContext",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getIdentifier",
"(",
"path",
",",
"\"raw\"",
",",
"gvrContext",
".",
"getContext",
"(",
")",
".",
"getPackageName",
"(",
")",
")",
";",
"if",
"(",
"resourceId",
"==",
"0",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"filePath",
"+",
"\" resource not found\"",
")",
";",
"}",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"gvrContext",
",",
"resourceId",
")",
";",
"break",
";",
"case",
"LINUX_FILESYSTEM",
":",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"getFullPath",
"(",
"defaultPath",
",",
"filePath",
")",
")",
";",
"break",
";",
"case",
"ANDROID_SDCARD",
":",
"String",
"linuxPath",
"=",
"Environment",
".",
"getExternalStorageDirectory",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"getFullPath",
"(",
"linuxPath",
",",
"defaultPath",
",",
"filePath",
")",
")",
";",
"break",
";",
"case",
"INPUT_STREAM",
":",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"getFullPath",
"(",
"defaultPath",
",",
"filePath",
")",
",",
"volumeInputStream",
")",
";",
"break",
";",
"case",
"NETWORK",
":",
"resourceKey",
"=",
"new",
"GVRAndroidResource",
"(",
"gvrContext",
",",
"getFullURL",
"(",
"defaultPath",
",",
"filePath",
")",
",",
"enableUrlLocalCache",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Unrecognized volumeType %s\"",
",",
"volumeType",
")",
")",
";",
"}",
"return",
"addResource",
"(",
"resourceKey",
")",
";",
"}"
] | Opens a file from the volume. The filePath is relative to the
defaultPath.
@param filePath
File path of the resource to open.
@throws IOException | [
"Opens",
"a",
"file",
"from",
"the",
"volume",
".",
"The",
"filePath",
"is",
"relative",
"to",
"the",
"defaultPath",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRResourceVolume.java#L281-L340 |
161,565 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRResourceVolume.java | GVRResourceVolume.adaptFilePath | protected String adaptFilePath(String filePath) {
// Convert windows file path to target FS
String targetPath = filePath.replaceAll("\\\\", volumeType.getSeparator());
return targetPath;
} | java | protected String adaptFilePath(String filePath) {
// Convert windows file path to target FS
String targetPath = filePath.replaceAll("\\\\", volumeType.getSeparator());
return targetPath;
} | [
"protected",
"String",
"adaptFilePath",
"(",
"String",
"filePath",
")",
"{",
"// Convert windows file path to target FS",
"String",
"targetPath",
"=",
"filePath",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"volumeType",
".",
"getSeparator",
"(",
")",
")",
";",
"return",
"targetPath",
";",
"}"
] | Adapt a file path to the current file system.
@param filePath The input file path string.
@return File path compatible with the file system of this {@link GVRResourceVolume}. | [
"Adapt",
"a",
"file",
"path",
"to",
"the",
"current",
"file",
"system",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRResourceVolume.java#L357-L362 |
161,566 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getFloatVec | public FloatBuffer getFloatVec(String attributeName)
{
int size = getAttributeSize(attributeName);
if (size <= 0)
{
return null;
}
size *= 4 * getVertexCount();
ByteBuffer buffer = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
FloatBuffer data = buffer.asFloatBuffer();
if (!NativeVertexBuffer.getFloatVec(getNative(), attributeName, data, 0, 0))
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return data;
} | java | public FloatBuffer getFloatVec(String attributeName)
{
int size = getAttributeSize(attributeName);
if (size <= 0)
{
return null;
}
size *= 4 * getVertexCount();
ByteBuffer buffer = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
FloatBuffer data = buffer.asFloatBuffer();
if (!NativeVertexBuffer.getFloatVec(getNative(), attributeName, data, 0, 0))
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return data;
} | [
"public",
"FloatBuffer",
"getFloatVec",
"(",
"String",
"attributeName",
")",
"{",
"int",
"size",
"=",
"getAttributeSize",
"(",
"attributeName",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"size",
"*=",
"4",
"*",
"getVertexCount",
"(",
")",
";",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"size",
")",
".",
"order",
"(",
"ByteOrder",
".",
"nativeOrder",
"(",
")",
")",
";",
"FloatBuffer",
"data",
"=",
"buffer",
".",
"asFloatBuffer",
"(",
")",
";",
"if",
"(",
"!",
"NativeVertexBuffer",
".",
"getFloatVec",
"(",
"getNative",
"(",
")",
",",
"attributeName",
",",
"data",
",",
"0",
",",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name \"",
"+",
"attributeName",
"+",
"\" cannot be accessed\"",
")",
";",
"}",
"return",
"data",
";",
"}"
] | Retrieves a vertex attribute as a float buffer.
The attribute name must be one of the
attributes named in the descriptor passed to the constructor.
@param attributeName name of the attribute to update
@throws IllegalArgumentException if attribute name not in descriptor vertex attribute is not <i>float</i>
@see #setFloatArray(String, float[])
@see #getFloatVec(String) | [
"Retrieves",
"a",
"vertex",
"attribute",
"as",
"a",
"float",
"buffer",
".",
"The",
"attribute",
"name",
"must",
"be",
"one",
"of",
"the",
"attributes",
"named",
"in",
"the",
"descriptor",
"passed",
"to",
"the",
"constructor",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L152-L167 |
161,567 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getFloatArray | public float[] getFloatArray(String attributeName)
{
float[] array = NativeVertexBuffer.getFloatArray(getNative(), attributeName);
if (array == null)
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return array;
} | java | public float[] getFloatArray(String attributeName)
{
float[] array = NativeVertexBuffer.getFloatArray(getNative(), attributeName);
if (array == null)
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return array;
} | [
"public",
"float",
"[",
"]",
"getFloatArray",
"(",
"String",
"attributeName",
")",
"{",
"float",
"[",
"]",
"array",
"=",
"NativeVertexBuffer",
".",
"getFloatArray",
"(",
"getNative",
"(",
")",
",",
"attributeName",
")",
";",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name \"",
"+",
"attributeName",
"+",
"\" cannot be accessed\"",
")",
";",
"}",
"return",
"array",
";",
"}"
] | Retrieves a vertex attribute as a float array.
The attribute name must be one of the
attributes named in the descriptor passed to the constructor.
@param attributeName name of the attribute to update
@throws IllegalArgumentException if attribute name not in descriptor vertex attribute is not <i>float</i>
@see #setFloatVec(String, FloatBuffer)
@see #getFloatArray(String) | [
"Retrieves",
"a",
"vertex",
"attribute",
"as",
"a",
"float",
"array",
".",
"The",
"attribute",
"name",
"must",
"be",
"one",
"of",
"the",
"attributes",
"named",
"in",
"the",
"descriptor",
"passed",
"to",
"the",
"constructor",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L178-L186 |
161,568 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getIntVec | public IntBuffer getIntVec(String attributeName)
{
int size = getAttributeSize(attributeName);
if (size <= 0)
{
return null;
}
size *= 4 * getVertexCount();
ByteBuffer buffer = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
IntBuffer data = buffer.asIntBuffer();
if (!NativeVertexBuffer.getIntVec(getNative(), attributeName, data, 0, 0))
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return data;
} | java | public IntBuffer getIntVec(String attributeName)
{
int size = getAttributeSize(attributeName);
if (size <= 0)
{
return null;
}
size *= 4 * getVertexCount();
ByteBuffer buffer = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
IntBuffer data = buffer.asIntBuffer();
if (!NativeVertexBuffer.getIntVec(getNative(), attributeName, data, 0, 0))
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return data;
} | [
"public",
"IntBuffer",
"getIntVec",
"(",
"String",
"attributeName",
")",
"{",
"int",
"size",
"=",
"getAttributeSize",
"(",
"attributeName",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"size",
"*=",
"4",
"*",
"getVertexCount",
"(",
")",
";",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"size",
")",
".",
"order",
"(",
"ByteOrder",
".",
"nativeOrder",
"(",
")",
")",
";",
"IntBuffer",
"data",
"=",
"buffer",
".",
"asIntBuffer",
"(",
")",
";",
"if",
"(",
"!",
"NativeVertexBuffer",
".",
"getIntVec",
"(",
"getNative",
"(",
")",
",",
"attributeName",
",",
"data",
",",
"0",
",",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name \"",
"+",
"attributeName",
"+",
"\" cannot be accessed\"",
")",
";",
"}",
"return",
"data",
";",
"}"
] | Retrieves a vertex attribute as an integer buffer.
The attribute name must be one of the
attributes named in the descriptor passed to the constructor.
@param attributeName name of the attribute to update
@throws IllegalArgumentException if attribute name not in descriptor vertex attribute is not <i>int</i>
@see #setIntArray(String, int[])
@see #getIntVec(String) | [
"Retrieves",
"a",
"vertex",
"attribute",
"as",
"an",
"integer",
"buffer",
".",
"The",
"attribute",
"name",
"must",
"be",
"one",
"of",
"the",
"attributes",
"named",
"in",
"the",
"descriptor",
"passed",
"to",
"the",
"constructor",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L197-L212 |
161,569 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getIntArray | public int[] getIntArray(String attributeName)
{
int[] array = NativeVertexBuffer.getIntArray(getNative(), attributeName);
if (array == null)
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return array;
} | java | public int[] getIntArray(String attributeName)
{
int[] array = NativeVertexBuffer.getIntArray(getNative(), attributeName);
if (array == null)
{
throw new IllegalArgumentException("Attribute name " + attributeName + " cannot be accessed");
}
return array;
} | [
"public",
"int",
"[",
"]",
"getIntArray",
"(",
"String",
"attributeName",
")",
"{",
"int",
"[",
"]",
"array",
"=",
"NativeVertexBuffer",
".",
"getIntArray",
"(",
"getNative",
"(",
")",
",",
"attributeName",
")",
";",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attribute name \"",
"+",
"attributeName",
"+",
"\" cannot be accessed\"",
")",
";",
"}",
"return",
"array",
";",
"}"
] | Retrieves a vertex attribute as an integer array.
The attribute name must be one of the
attributes named in the descriptor passed to the constructor.
@param attributeName name of the attribute to update
@throws IllegalArgumentException if attribute name not in descriptor vertex attribute is not <i>int</i>
@see #setIntVec(String, IntBuffer)
@see #getIntArray(String) | [
"Retrieves",
"a",
"vertex",
"attribute",
"as",
"an",
"integer",
"array",
".",
"The",
"attribute",
"name",
"must",
"be",
"one",
"of",
"the",
"attributes",
"named",
"in",
"the",
"descriptor",
"passed",
"to",
"the",
"constructor",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L223-L231 |
161,570 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getSphereBound | public float getSphereBound(float[] sphere)
{
if ((sphere == null) || (sphere.length != 4) ||
((NativeVertexBuffer.getBoundingVolume(getNative(), sphere)) < 0))
{
throw new IllegalArgumentException("Cannot copy sphere bound into array provided");
}
return sphere[0];
} | java | public float getSphereBound(float[] sphere)
{
if ((sphere == null) || (sphere.length != 4) ||
((NativeVertexBuffer.getBoundingVolume(getNative(), sphere)) < 0))
{
throw new IllegalArgumentException("Cannot copy sphere bound into array provided");
}
return sphere[0];
} | [
"public",
"float",
"getSphereBound",
"(",
"float",
"[",
"]",
"sphere",
")",
"{",
"if",
"(",
"(",
"sphere",
"==",
"null",
")",
"||",
"(",
"sphere",
".",
"length",
"!=",
"4",
")",
"||",
"(",
"(",
"NativeVertexBuffer",
".",
"getBoundingVolume",
"(",
"getNative",
"(",
")",
",",
"sphere",
")",
")",
"<",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot copy sphere bound into array provided\"",
")",
";",
"}",
"return",
"sphere",
"[",
"0",
"]",
";",
"}"
] | Returns the bounding sphere of the vertices.
@param sphere destination array to get bounding sphere.
The first entry is the radius, the next
three are the center.
@return radius of bounding sphere or 0.0 if no vertices | [
"Returns",
"the",
"bounding",
"sphere",
"of",
"the",
"vertices",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L551-L559 |
161,571 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java | GVRVertexBuffer.getBoxBound | public boolean getBoxBound(float[] corners)
{
int rc;
if ((corners == null) || (corners.length != 6) ||
((rc = NativeVertexBuffer.getBoundingVolume(getNative(), corners)) < 0))
{
throw new IllegalArgumentException("Cannot copy box bound into array provided");
}
return rc != 0;
} | java | public boolean getBoxBound(float[] corners)
{
int rc;
if ((corners == null) || (corners.length != 6) ||
((rc = NativeVertexBuffer.getBoundingVolume(getNative(), corners)) < 0))
{
throw new IllegalArgumentException("Cannot copy box bound into array provided");
}
return rc != 0;
} | [
"public",
"boolean",
"getBoxBound",
"(",
"float",
"[",
"]",
"corners",
")",
"{",
"int",
"rc",
";",
"if",
"(",
"(",
"corners",
"==",
"null",
")",
"||",
"(",
"corners",
".",
"length",
"!=",
"6",
")",
"||",
"(",
"(",
"rc",
"=",
"NativeVertexBuffer",
".",
"getBoundingVolume",
"(",
"getNative",
"(",
")",
",",
"corners",
")",
")",
"<",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot copy box bound into array provided\"",
")",
";",
"}",
"return",
"rc",
"!=",
"0",
";",
"}"
] | Returns the bounding box of the vertices.
@param corners destination array to get corners of bounding box.
The first three entries are the minimum X,Y,Z values
and the next three are the maximum X,Y,Z.
@return true if bounds are not empty, false if empty (no vertices) | [
"Returns",
"the",
"bounding",
"box",
"of",
"the",
"vertices",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRVertexBuffer.java#L568-L577 |
161,572 | Samsung/GearVRf | GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java | GVRAudioSource.load | public void load(String soundFile)
{
if (mSoundFile != null)
{
unload();
}
mSoundFile = soundFile;
if (mAudioListener != null)
{
mAudioListener.getAudioEngine().preloadSoundFile(soundFile);
Log.d("SOUND", "loaded audio file %s", getSoundFile());
}
} | java | public void load(String soundFile)
{
if (mSoundFile != null)
{
unload();
}
mSoundFile = soundFile;
if (mAudioListener != null)
{
mAudioListener.getAudioEngine().preloadSoundFile(soundFile);
Log.d("SOUND", "loaded audio file %s", getSoundFile());
}
} | [
"public",
"void",
"load",
"(",
"String",
"soundFile",
")",
"{",
"if",
"(",
"mSoundFile",
"!=",
"null",
")",
"{",
"unload",
"(",
")",
";",
"}",
"mSoundFile",
"=",
"soundFile",
";",
"if",
"(",
"mAudioListener",
"!=",
"null",
")",
"{",
"mAudioListener",
".",
"getAudioEngine",
"(",
")",
".",
"preloadSoundFile",
"(",
"soundFile",
")",
";",
"Log",
".",
"d",
"(",
"\"SOUND\"",
",",
"\"loaded audio file %s\"",
",",
"getSoundFile",
"(",
")",
")",
";",
"}",
"}"
] | Preloads a sound file.
@param soundFile path/name of the file to be played. | [
"Preloads",
"a",
"sound",
"file",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java#L85-L97 |
161,573 | Samsung/GearVRf | GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java | GVRAudioSource.unload | public void unload()
{
if (mAudioListener != null)
{
Log.d("SOUND", "unloading audio source %d %s", getSourceId(), getSoundFile());
mAudioListener.getAudioEngine().unloadSoundFile(getSoundFile());
}
mSoundFile = null;
mSourceId = GvrAudioEngine.INVALID_ID;
} | java | public void unload()
{
if (mAudioListener != null)
{
Log.d("SOUND", "unloading audio source %d %s", getSourceId(), getSoundFile());
mAudioListener.getAudioEngine().unloadSoundFile(getSoundFile());
}
mSoundFile = null;
mSourceId = GvrAudioEngine.INVALID_ID;
} | [
"public",
"void",
"unload",
"(",
")",
"{",
"if",
"(",
"mAudioListener",
"!=",
"null",
")",
"{",
"Log",
".",
"d",
"(",
"\"SOUND\"",
",",
"\"unloading audio source %d %s\"",
",",
"getSourceId",
"(",
")",
",",
"getSoundFile",
"(",
")",
")",
";",
"mAudioListener",
".",
"getAudioEngine",
"(",
")",
".",
"unloadSoundFile",
"(",
"getSoundFile",
"(",
")",
")",
";",
"}",
"mSoundFile",
"=",
"null",
";",
"mSourceId",
"=",
"GvrAudioEngine",
".",
"INVALID_ID",
";",
"}"
] | Unloads the sound file for this source, if any. | [
"Unloads",
"the",
"sound",
"file",
"for",
"this",
"source",
"if",
"any",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java#L102-L111 |
161,574 | Samsung/GearVRf | GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java | GVRAudioSource.pause | public void pause()
{
if (mAudioListener != null)
{
int sourceId = getSourceId();
if (sourceId != GvrAudioEngine.INVALID_ID)
{
mAudioListener.getAudioEngine().pauseSound(sourceId);
}
}
} | java | public void pause()
{
if (mAudioListener != null)
{
int sourceId = getSourceId();
if (sourceId != GvrAudioEngine.INVALID_ID)
{
mAudioListener.getAudioEngine().pauseSound(sourceId);
}
}
} | [
"public",
"void",
"pause",
"(",
")",
"{",
"if",
"(",
"mAudioListener",
"!=",
"null",
")",
"{",
"int",
"sourceId",
"=",
"getSourceId",
"(",
")",
";",
"if",
"(",
"sourceId",
"!=",
"GvrAudioEngine",
".",
"INVALID_ID",
")",
"{",
"mAudioListener",
".",
"getAudioEngine",
"(",
")",
".",
"pauseSound",
"(",
"sourceId",
")",
";",
"}",
"}",
"}"
] | Pauses the playback of a sound. | [
"Pauses",
"the",
"playback",
"of",
"a",
"sound",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java#L225-L235 |
161,575 | Samsung/GearVRf | GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java | GVRAudioSource.stop | public void stop()
{
if (mAudioListener != null)
{
Log.d("SOUND", "stopping audio source %d %s", getSourceId(), getSoundFile());
mAudioListener.getAudioEngine().stopSound(getSourceId());
}
} | java | public void stop()
{
if (mAudioListener != null)
{
Log.d("SOUND", "stopping audio source %d %s", getSourceId(), getSoundFile());
mAudioListener.getAudioEngine().stopSound(getSourceId());
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"mAudioListener",
"!=",
"null",
")",
"{",
"Log",
".",
"d",
"(",
"\"SOUND\"",
",",
"\"stopping audio source %d %s\"",
",",
"getSourceId",
"(",
")",
",",
"getSoundFile",
"(",
")",
")",
";",
"mAudioListener",
".",
"getAudioEngine",
"(",
")",
".",
"stopSound",
"(",
"getSourceId",
"(",
")",
")",
";",
"}",
"}"
] | Stops the playback of a sound and destroys the corresponding Sound Object or Soundfield. | [
"Stops",
"the",
"playback",
"of",
"a",
"sound",
"and",
"destroys",
"the",
"corresponding",
"Sound",
"Object",
"or",
"Soundfield",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java#L263-L270 |
161,576 | Samsung/GearVRf | GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java | GVRAudioSource.setVolume | public void setVolume(float volume)
{
// Save this in case this audio source is not being played yet
mVolume = volume;
if (isPlaying() && (getSourceId() != GvrAudioEngine.INVALID_ID))
{
// This will actually work only if the sound file is being played
mAudioListener.getAudioEngine().setSoundVolume(getSourceId(), getVolume());
}
} | java | public void setVolume(float volume)
{
// Save this in case this audio source is not being played yet
mVolume = volume;
if (isPlaying() && (getSourceId() != GvrAudioEngine.INVALID_ID))
{
// This will actually work only if the sound file is being played
mAudioListener.getAudioEngine().setSoundVolume(getSourceId(), getVolume());
}
} | [
"public",
"void",
"setVolume",
"(",
"float",
"volume",
")",
"{",
"// Save this in case this audio source is not being played yet",
"mVolume",
"=",
"volume",
";",
"if",
"(",
"isPlaying",
"(",
")",
"&&",
"(",
"getSourceId",
"(",
")",
"!=",
"GvrAudioEngine",
".",
"INVALID_ID",
")",
")",
"{",
"// This will actually work only if the sound file is being played",
"mAudioListener",
".",
"getAudioEngine",
"(",
")",
".",
"setSoundVolume",
"(",
"getSourceId",
"(",
")",
",",
"getVolume",
"(",
")",
")",
";",
"}",
"}"
] | Changes the volume of an existing sound.
@param volume volume value. Should range from 0 (mute) to 1 (max) | [
"Changes",
"the",
"volume",
"of",
"an",
"existing",
"sound",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/ResonanceAudio/resonanceaudio/src/main/java/org/gearvrf/resonanceaudio/GVRAudioSource.java#L276-L285 |
161,577 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java | Vector3Axis.get | public float get(Layout.Axis axis) {
switch (axis) {
case X:
return x;
case Y:
return y;
case Z:
return z;
default:
throw new RuntimeAssertion("Bad axis specified: %s", axis);
}
} | java | public float get(Layout.Axis axis) {
switch (axis) {
case X:
return x;
case Y:
return y;
case Z:
return z;
default:
throw new RuntimeAssertion("Bad axis specified: %s", axis);
}
} | [
"public",
"float",
"get",
"(",
"Layout",
".",
"Axis",
"axis",
")",
"{",
"switch",
"(",
"axis",
")",
"{",
"case",
"X",
":",
"return",
"x",
";",
"case",
"Y",
":",
"return",
"y",
";",
"case",
"Z",
":",
"return",
"z",
";",
"default",
":",
"throw",
"new",
"RuntimeAssertion",
"(",
"\"Bad axis specified: %s\"",
",",
"axis",
")",
";",
"}",
"}"
] | Gets axis dimension
@param axis Axis. It might be either {@link Layout.Axis#X X} or
{@link Layout.Axis#Y Y} or {@link Layout.Axis#Z Z}
@return axis dimension | [
"Gets",
"axis",
"dimension"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java#L45-L56 |
161,578 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java | Vector3Axis.set | public void set(float val, Layout.Axis axis) {
switch (axis) {
case X:
x = val;
break;
case Y:
y = val;
break;
case Z:
z = val;
break;
default:
throw new RuntimeAssertion("Bad axis specified: %s", axis);
}
} | java | public void set(float val, Layout.Axis axis) {
switch (axis) {
case X:
x = val;
break;
case Y:
y = val;
break;
case Z:
z = val;
break;
default:
throw new RuntimeAssertion("Bad axis specified: %s", axis);
}
} | [
"public",
"void",
"set",
"(",
"float",
"val",
",",
"Layout",
".",
"Axis",
"axis",
")",
"{",
"switch",
"(",
"axis",
")",
"{",
"case",
"X",
":",
"x",
"=",
"val",
";",
"break",
";",
"case",
"Y",
":",
"y",
"=",
"val",
";",
"break",
";",
"case",
"Z",
":",
"z",
"=",
"val",
";",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeAssertion",
"(",
"\"Bad axis specified: %s\"",
",",
"axis",
")",
";",
"}",
"}"
] | Sets axis dimension
@param val dimension
@param axis Axis. It might be either {@link Layout.Axis#X X} or
{@link Layout.Axis#Y Y} or {@link Layout.Axis#Z Z} | [
"Sets",
"axis",
"dimension"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java#L64-L78 |
161,579 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java | Vector3Axis.delta | public Vector3Axis delta(Vector3f v) {
Vector3Axis ret = new Vector3Axis(Float.NaN, Float.NaN, Float.NaN);
if (x != Float.NaN && v.x != Float.NaN && !equal(x, v.x)) {
ret.set(x - v.x, Layout.Axis.X);
}
if (y != Float.NaN && v.y != Float.NaN && !equal(y, v.y)) {
ret.set(y - v.y, Layout.Axis.Y);
}
if (z != Float.NaN && v.z != Float.NaN && !equal(z, v.z)) {
ret.set(z - v.z, Layout.Axis.Z);
}
return ret;
} | java | public Vector3Axis delta(Vector3f v) {
Vector3Axis ret = new Vector3Axis(Float.NaN, Float.NaN, Float.NaN);
if (x != Float.NaN && v.x != Float.NaN && !equal(x, v.x)) {
ret.set(x - v.x, Layout.Axis.X);
}
if (y != Float.NaN && v.y != Float.NaN && !equal(y, v.y)) {
ret.set(y - v.y, Layout.Axis.Y);
}
if (z != Float.NaN && v.z != Float.NaN && !equal(z, v.z)) {
ret.set(z - v.z, Layout.Axis.Z);
}
return ret;
} | [
"public",
"Vector3Axis",
"delta",
"(",
"Vector3f",
"v",
")",
"{",
"Vector3Axis",
"ret",
"=",
"new",
"Vector3Axis",
"(",
"Float",
".",
"NaN",
",",
"Float",
".",
"NaN",
",",
"Float",
".",
"NaN",
")",
";",
"if",
"(",
"x",
"!=",
"Float",
".",
"NaN",
"&&",
"v",
".",
"x",
"!=",
"Float",
".",
"NaN",
"&&",
"!",
"equal",
"(",
"x",
",",
"v",
".",
"x",
")",
")",
"{",
"ret",
".",
"set",
"(",
"x",
"-",
"v",
".",
"x",
",",
"Layout",
".",
"Axis",
".",
"X",
")",
";",
"}",
"if",
"(",
"y",
"!=",
"Float",
".",
"NaN",
"&&",
"v",
".",
"y",
"!=",
"Float",
".",
"NaN",
"&&",
"!",
"equal",
"(",
"y",
",",
"v",
".",
"y",
")",
")",
"{",
"ret",
".",
"set",
"(",
"y",
"-",
"v",
".",
"y",
",",
"Layout",
".",
"Axis",
".",
"Y",
")",
";",
"}",
"if",
"(",
"z",
"!=",
"Float",
".",
"NaN",
"&&",
"v",
".",
"z",
"!=",
"Float",
".",
"NaN",
"&&",
"!",
"equal",
"(",
"z",
",",
"v",
".",
"z",
")",
")",
"{",
"ret",
".",
"set",
"(",
"z",
"-",
"v",
".",
"z",
",",
"Layout",
".",
"Axis",
".",
"Z",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Calculate delta with another vector
@param v another vector
@return delta vector | [
"Calculate",
"delta",
"with",
"another",
"vector"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/Vector3Axis.java#L101-L113 |
161,580 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/PageIndicatorWidget.java | PageIndicatorWidget.setPageCount | public int setPageCount(final int num) {
int diff = num - getCheckableCount();
if (diff > 0) {
addIndicatorChildren(diff);
} else if (diff < 0) {
removeIndicatorChildren(-diff);
}
if (mCurrentPage >=num ) {
mCurrentPage = 0;
}
setCurrentPage(mCurrentPage);
return diff;
} | java | public int setPageCount(final int num) {
int diff = num - getCheckableCount();
if (diff > 0) {
addIndicatorChildren(diff);
} else if (diff < 0) {
removeIndicatorChildren(-diff);
}
if (mCurrentPage >=num ) {
mCurrentPage = 0;
}
setCurrentPage(mCurrentPage);
return diff;
} | [
"public",
"int",
"setPageCount",
"(",
"final",
"int",
"num",
")",
"{",
"int",
"diff",
"=",
"num",
"-",
"getCheckableCount",
"(",
")",
";",
"if",
"(",
"diff",
">",
"0",
")",
"{",
"addIndicatorChildren",
"(",
"diff",
")",
";",
"}",
"else",
"if",
"(",
"diff",
"<",
"0",
")",
"{",
"removeIndicatorChildren",
"(",
"-",
"diff",
")",
";",
"}",
"if",
"(",
"mCurrentPage",
">=",
"num",
")",
"{",
"mCurrentPage",
"=",
"0",
";",
"}",
"setCurrentPage",
"(",
"mCurrentPage",
")",
";",
"return",
"diff",
";",
"}"
] | Sets number of pages. If the index of currently selected page is bigger than the total number
of pages, first page will be selected instead.
@return difference between the previous number of pages and new one. Negative value is
returned if new number of pages is less then it was before. | [
"Sets",
"number",
"of",
"pages",
".",
"If",
"the",
"index",
"of",
"currently",
"selected",
"page",
"is",
"bigger",
"than",
"the",
"total",
"number",
"of",
"pages",
"first",
"page",
"will",
"be",
"selected",
"instead",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/PageIndicatorWidget.java#L122-L134 |
161,581 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/PageIndicatorWidget.java | PageIndicatorWidget.setCurrentPage | public boolean setCurrentPage(final int page) {
Log.d(TAG, "setPageId pageId = %d", page);
return (page >= 0 && page < getCheckableCount()) && check(page);
} | java | public boolean setCurrentPage(final int page) {
Log.d(TAG, "setPageId pageId = %d", page);
return (page >= 0 && page < getCheckableCount()) && check(page);
} | [
"public",
"boolean",
"setCurrentPage",
"(",
"final",
"int",
"page",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"setPageId pageId = %d\"",
",",
"page",
")",
";",
"return",
"(",
"page",
">=",
"0",
"&&",
"page",
"<",
"getCheckableCount",
"(",
")",
")",
"&&",
"check",
"(",
"page",
")",
";",
"}"
] | Sets selected page implicitly
@param page new selected page
@return true if the page has been selected successfully | [
"Sets",
"selected",
"page",
"implicitly"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/custom/PageIndicatorWidget.java#L149-L152 |
161,582 | Samsung/GearVRf | GVRf/Extensions/gvrf-physics/src/main/java/org/gearvrf/physics/GVRPhysicsAvatar.java | GVRPhysicsAvatar.loadPhysics | public void loadPhysics(String filename, GVRScene scene) throws IOException
{
GVRPhysicsLoader.loadPhysicsFile(getGVRContext(), filename, true, scene);
} | java | public void loadPhysics(String filename, GVRScene scene) throws IOException
{
GVRPhysicsLoader.loadPhysicsFile(getGVRContext(), filename, true, scene);
} | [
"public",
"void",
"loadPhysics",
"(",
"String",
"filename",
",",
"GVRScene",
"scene",
")",
"throws",
"IOException",
"{",
"GVRPhysicsLoader",
".",
"loadPhysicsFile",
"(",
"getGVRContext",
"(",
")",
",",
"filename",
",",
"true",
",",
"scene",
")",
";",
"}"
] | Load physics information for the current avatar
@param filename name of physics file
@param scene scene the avatar is part of
@throws IOException if physics file cannot be parsed | [
"Load",
"physics",
"information",
"for",
"the",
"current",
"avatar"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/gvrf-physics/src/main/java/org/gearvrf/physics/GVRPhysicsAvatar.java#L62-L65 |
161,583 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java | MainScene.rotateToFaceCamera | public void rotateToFaceCamera(final GVRTransform transform) {
//see http://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
final GVRTransform t = getMainCameraRig().getHeadTransform();
final Quaternionf q = new Quaternionf(0, t.getRotationY(), 0, t.getRotationW()).normalize();
transform.rotateWithPivot(q.w, q.x, q.y, q.z, 0, 0, 0);
} | java | public void rotateToFaceCamera(final GVRTransform transform) {
//see http://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
final GVRTransform t = getMainCameraRig().getHeadTransform();
final Quaternionf q = new Quaternionf(0, t.getRotationY(), 0, t.getRotationW()).normalize();
transform.rotateWithPivot(q.w, q.x, q.y, q.z, 0, 0, 0);
} | [
"public",
"void",
"rotateToFaceCamera",
"(",
"final",
"GVRTransform",
"transform",
")",
"{",
"//see http://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion",
"final",
"GVRTransform",
"t",
"=",
"getMainCameraRig",
"(",
")",
".",
"getHeadTransform",
"(",
")",
";",
"final",
"Quaternionf",
"q",
"=",
"new",
"Quaternionf",
"(",
"0",
",",
"t",
".",
"getRotationY",
"(",
")",
",",
"0",
",",
"t",
".",
"getRotationW",
"(",
")",
")",
".",
"normalize",
"(",
")",
";",
"transform",
".",
"rotateWithPivot",
"(",
"q",
".",
"w",
",",
"q",
".",
"x",
",",
"q",
".",
"y",
",",
"q",
".",
"z",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"}"
] | Apply the necessary rotation to the transform so that it is in front of
the camera.
@param transform The transform to modify. | [
"Apply",
"the",
"necessary",
"rotation",
"to",
"the",
"transform",
"so",
"that",
"it",
"is",
"in",
"front",
"of",
"the",
"camera",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java#L465-L471 |
161,584 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java | MainScene.rotateToFaceCamera | public float rotateToFaceCamera(final Widget widget) {
final float yaw = getMainCameraRigYaw();
GVRTransform t = getMainCameraRig().getHeadTransform();
widget.rotateWithPivot(t.getRotationW(), 0, t.getRotationY(), 0, 0, 0, 0);
return yaw;
} | java | public float rotateToFaceCamera(final Widget widget) {
final float yaw = getMainCameraRigYaw();
GVRTransform t = getMainCameraRig().getHeadTransform();
widget.rotateWithPivot(t.getRotationW(), 0, t.getRotationY(), 0, 0, 0, 0);
return yaw;
} | [
"public",
"float",
"rotateToFaceCamera",
"(",
"final",
"Widget",
"widget",
")",
"{",
"final",
"float",
"yaw",
"=",
"getMainCameraRigYaw",
"(",
")",
";",
"GVRTransform",
"t",
"=",
"getMainCameraRig",
"(",
")",
".",
"getHeadTransform",
"(",
")",
";",
"widget",
".",
"rotateWithPivot",
"(",
"t",
".",
"getRotationW",
"(",
")",
",",
"0",
",",
"t",
".",
"getRotationY",
"(",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"return",
"yaw",
";",
"}"
] | Apply the necessary rotation to the transform so that it is in front of
the camera. The actual rotation is performed not using the yaw angle but
using equivalent quaternion values for better accuracy. But the yaw angle
is still returned for backward compatibility.
@param widget The transform to modify.
@return The camera's yaw in degrees. | [
"Apply",
"the",
"necessary",
"rotation",
"to",
"the",
"transform",
"so",
"that",
"it",
"is",
"in",
"front",
"of",
"the",
"camera",
".",
"The",
"actual",
"rotation",
"is",
"performed",
"not",
"using",
"the",
"yaw",
"angle",
"but",
"using",
"equivalent",
"quaternion",
"values",
"for",
"better",
"accuracy",
".",
"But",
"the",
"yaw",
"angle",
"is",
"still",
"returned",
"for",
"backward",
"compatibility",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java#L482-L487 |
161,585 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java | MainScene.updateFrontFacingRotation | public void updateFrontFacingRotation(float rotation) {
if (!Float.isNaN(rotation) && !equal(rotation, frontFacingRotation)) {
final float oldRotation = frontFacingRotation;
frontFacingRotation = rotation % 360;
for (OnFrontRotationChangedListener listener : mOnFrontRotationChangedListeners) {
try {
listener.onFrontRotationChanged(this, frontFacingRotation, oldRotation);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e, "updateFrontFacingRotation()");
}
}
}
} | java | public void updateFrontFacingRotation(float rotation) {
if (!Float.isNaN(rotation) && !equal(rotation, frontFacingRotation)) {
final float oldRotation = frontFacingRotation;
frontFacingRotation = rotation % 360;
for (OnFrontRotationChangedListener listener : mOnFrontRotationChangedListeners) {
try {
listener.onFrontRotationChanged(this, frontFacingRotation, oldRotation);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e, "updateFrontFacingRotation()");
}
}
}
} | [
"public",
"void",
"updateFrontFacingRotation",
"(",
"float",
"rotation",
")",
"{",
"if",
"(",
"!",
"Float",
".",
"isNaN",
"(",
"rotation",
")",
"&&",
"!",
"equal",
"(",
"rotation",
",",
"frontFacingRotation",
")",
")",
"{",
"final",
"float",
"oldRotation",
"=",
"frontFacingRotation",
";",
"frontFacingRotation",
"=",
"rotation",
"%",
"360",
";",
"for",
"(",
"OnFrontRotationChangedListener",
"listener",
":",
"mOnFrontRotationChangedListeners",
")",
"{",
"try",
"{",
"listener",
".",
"onFrontRotationChanged",
"(",
"this",
",",
"frontFacingRotation",
",",
"oldRotation",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"Log",
".",
"e",
"(",
"TAG",
",",
"e",
",",
"\"updateFrontFacingRotation()\"",
")",
";",
"}",
"}",
"}",
"}"
] | Set new front facing rotation
@param rotation | [
"Set",
"new",
"front",
"facing",
"rotation"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java#L503-L516 |
161,586 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java | MainScene.rotateToFront | public void rotateToFront() {
GVRTransform transform = mSceneRootObject.getTransform();
transform.setRotation(1, 0, 0, 0);
transform.rotateByAxisWithPivot(-frontFacingRotation + 180, 0, 1, 0, 0, 0, 0);
} | java | public void rotateToFront() {
GVRTransform transform = mSceneRootObject.getTransform();
transform.setRotation(1, 0, 0, 0);
transform.rotateByAxisWithPivot(-frontFacingRotation + 180, 0, 1, 0, 0, 0, 0);
} | [
"public",
"void",
"rotateToFront",
"(",
")",
"{",
"GVRTransform",
"transform",
"=",
"mSceneRootObject",
".",
"getTransform",
"(",
")",
";",
"transform",
".",
"setRotation",
"(",
"1",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"transform",
".",
"rotateByAxisWithPivot",
"(",
"-",
"frontFacingRotation",
"+",
"180",
",",
"0",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"}"
] | Rotate root widget to make it facing to the front of the scene | [
"Rotate",
"root",
"widget",
"to",
"make",
"it",
"facing",
"to",
"the",
"front",
"of",
"the",
"scene"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java#L537-L541 |
161,587 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java | MainScene.setScale | public void setScale(final float scale) {
if (equal(mScale, scale) != true) {
Log.d(TAG, "setScale(): old: %.2f, new: %.2f", mScale, scale);
mScale = scale;
setScale(mSceneRootObject, scale);
setScale(mMainCameraRootObject, scale);
setScale(mLeftCameraRootObject, scale);
setScale(mRightCameraRootObject, scale);
for (OnScaledListener listener : mOnScaledListeners) {
try {
listener.onScaled(scale);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e, "setScale()");
}
}
}
} | java | public void setScale(final float scale) {
if (equal(mScale, scale) != true) {
Log.d(TAG, "setScale(): old: %.2f, new: %.2f", mScale, scale);
mScale = scale;
setScale(mSceneRootObject, scale);
setScale(mMainCameraRootObject, scale);
setScale(mLeftCameraRootObject, scale);
setScale(mRightCameraRootObject, scale);
for (OnScaledListener listener : mOnScaledListeners) {
try {
listener.onScaled(scale);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, e, "setScale()");
}
}
}
} | [
"public",
"void",
"setScale",
"(",
"final",
"float",
"scale",
")",
"{",
"if",
"(",
"equal",
"(",
"mScale",
",",
"scale",
")",
"!=",
"true",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"setScale(): old: %.2f, new: %.2f\"",
",",
"mScale",
",",
"scale",
")",
";",
"mScale",
"=",
"scale",
";",
"setScale",
"(",
"mSceneRootObject",
",",
"scale",
")",
";",
"setScale",
"(",
"mMainCameraRootObject",
",",
"scale",
")",
";",
"setScale",
"(",
"mLeftCameraRootObject",
",",
"scale",
")",
";",
"setScale",
"(",
"mRightCameraRootObject",
",",
"scale",
")",
";",
"for",
"(",
"OnScaledListener",
"listener",
":",
"mOnScaledListeners",
")",
"{",
"try",
"{",
"listener",
".",
"onScaled",
"(",
"scale",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"Log",
".",
"e",
"(",
"TAG",
",",
"e",
",",
"\"setScale()\"",
")",
";",
"}",
"}",
"}",
"}"
] | Scale all widgets in Main Scene hierarchy
@param scale | [
"Scale",
"all",
"widgets",
"in",
"Main",
"Scene",
"hierarchy"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/main/MainScene.java#L566-L583 |
161,588 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java | GVRAnimation.setRepeatMode | public GVRAnimation setRepeatMode(int repeatMode) {
if (GVRRepeatMode.invalidRepeatMode(repeatMode)) {
throw new IllegalArgumentException(repeatMode
+ " is not a valid repetition type");
}
mRepeatMode = repeatMode;
return this;
} | java | public GVRAnimation setRepeatMode(int repeatMode) {
if (GVRRepeatMode.invalidRepeatMode(repeatMode)) {
throw new IllegalArgumentException(repeatMode
+ " is not a valid repetition type");
}
mRepeatMode = repeatMode;
return this;
} | [
"public",
"GVRAnimation",
"setRepeatMode",
"(",
"int",
"repeatMode",
")",
"{",
"if",
"(",
"GVRRepeatMode",
".",
"invalidRepeatMode",
"(",
"repeatMode",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"repeatMode",
"+",
"\" is not a valid repetition type\"",
")",
";",
"}",
"mRepeatMode",
"=",
"repeatMode",
";",
"return",
"this",
";",
"}"
] | Set the repeat type.
In the default {@linkplain GVRRepeatMode#ONCE run-once} mode, animations
run once, ignoring the {@linkplain #getRepeatCount() repeat count.} In
{@linkplain GVRRepeatMode#PINGPONG ping pong} and
{@linkplain GVRRepeatMode#REPEATED repeated} modes, animations do honor
the repeat count, which {@linkplain #DEFAULT_REPEAT_COUNT defaults} to 2.
@param repeatMode
One of the {@link GVRRepeatMode} constants
@return {@code this}, so you can chain setProperty() calls.
@throws IllegalArgumentException
If {@code repetitionType} is not one of the
{@link GVRRepeatMode} constants | [
"Set",
"the",
"repeat",
"type",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java#L211-L218 |
161,589 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java | GVRAnimation.setOffset | public GVRAnimation setOffset(float startOffset)
{
if(startOffset<0 || startOffset>mDuration){
throw new IllegalArgumentException("offset should not be either negative or greater than duration");
}
animationOffset = startOffset;
mDuration = mDuration-animationOffset;
return this;
} | java | public GVRAnimation setOffset(float startOffset)
{
if(startOffset<0 || startOffset>mDuration){
throw new IllegalArgumentException("offset should not be either negative or greater than duration");
}
animationOffset = startOffset;
mDuration = mDuration-animationOffset;
return this;
} | [
"public",
"GVRAnimation",
"setOffset",
"(",
"float",
"startOffset",
")",
"{",
"if",
"(",
"startOffset",
"<",
"0",
"||",
"startOffset",
">",
"mDuration",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"offset should not be either negative or greater than duration\"",
")",
";",
"}",
"animationOffset",
"=",
"startOffset",
";",
"mDuration",
"=",
"mDuration",
"-",
"animationOffset",
";",
"return",
"this",
";",
"}"
] | Sets the offset for the animation.
@param startOffset animation will start at the specified offset value
@return {@code this}, so you can chain setProperty() calls.
@throws IllegalArgumentException
If {@code startOffset} is either negative or greater than
the animation duration | [
"Sets",
"the",
"offset",
"for",
"the",
"animation",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java#L263-L271 |
161,590 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java | GVRAnimation.setDuration | public GVRAnimation setDuration(float start, float end)
{
if(start>end || start<0 || end>mDuration){
throw new IllegalArgumentException("start and end values are wrong");
}
animationOffset = start;
mDuration = end-start;
return this;
} | java | public GVRAnimation setDuration(float start, float end)
{
if(start>end || start<0 || end>mDuration){
throw new IllegalArgumentException("start and end values are wrong");
}
animationOffset = start;
mDuration = end-start;
return this;
} | [
"public",
"GVRAnimation",
"setDuration",
"(",
"float",
"start",
",",
"float",
"end",
")",
"{",
"if",
"(",
"start",
">",
"end",
"||",
"start",
"<",
"0",
"||",
"end",
">",
"mDuration",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"start and end values are wrong\"",
")",
";",
"}",
"animationOffset",
"=",
"start",
";",
"mDuration",
"=",
"end",
"-",
"start",
";",
"return",
"this",
";",
"}"
] | Sets the duration for the animation to be played.
@param start the animation will start playing from the specified time
@param end the animation will stop playing at the specified time
@return {@code this}, so you can chain setProperty() calls.
@throws IllegalArgumentException
If {@code start} is either negative value, greater than
{@code end} value or {@code end} is greater than duration | [
"Sets",
"the",
"duration",
"for",
"the",
"animation",
"to",
"be",
"played",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java#L301-L309 |
161,591 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java | GVRAnimation.setOnFinish | public GVRAnimation setOnFinish(GVROnFinish callback) {
mOnFinish = callback;
// Do the instance-of test at set-time, not at use-time
mOnRepeat = callback instanceof GVROnRepeat ? (GVROnRepeat) callback
: null;
if (mOnRepeat != null) {
mRepeatCount = -1; // loop until iterate() returns false
}
return this;
} | java | public GVRAnimation setOnFinish(GVROnFinish callback) {
mOnFinish = callback;
// Do the instance-of test at set-time, not at use-time
mOnRepeat = callback instanceof GVROnRepeat ? (GVROnRepeat) callback
: null;
if (mOnRepeat != null) {
mRepeatCount = -1; // loop until iterate() returns false
}
return this;
} | [
"public",
"GVRAnimation",
"setOnFinish",
"(",
"GVROnFinish",
"callback",
")",
"{",
"mOnFinish",
"=",
"callback",
";",
"// Do the instance-of test at set-time, not at use-time",
"mOnRepeat",
"=",
"callback",
"instanceof",
"GVROnRepeat",
"?",
"(",
"GVROnRepeat",
")",
"callback",
":",
"null",
";",
"if",
"(",
"mOnRepeat",
"!=",
"null",
")",
"{",
"mRepeatCount",
"=",
"-",
"1",
";",
"// loop until iterate() returns false",
"}",
"return",
"this",
";",
"}"
] | Set the on-finish callback.
The basic {@link GVROnFinish} callback will notify you when the animation
runs to completion. This is a good time to do things like removing
now-invisible objects from the scene graph.
<p>
The extended {@link GVROnRepeat} callback will be called after every
iteration of an indefinite (repeat count less than 0) animation, giving
you a way to stop the animation when it's not longer appropriate.
@param callback
A {@link GVROnFinish} or {@link GVROnRepeat} implementation.
<p>
<em>Note</em>: Supplying a {@link GVROnRepeat} callback will
{@linkplain #setRepeatCount(int) set the repeat count} to a
negative number. Calling {@link #setRepeatCount(int)} with a
non-negative value after setting a {@link GVROnRepeat}
callback will effectively convert the callback to a
{@link GVROnFinish}.
@return {@code this}, so you can chain setProperty() calls. | [
"Set",
"the",
"on",
"-",
"finish",
"callback",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRAnimation.java#L333-L343 |
161,592 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java | GVRRenderData.bindShader | public synchronized void bindShader(GVRScene scene, boolean isMultiview)
{
GVRRenderPass pass = mRenderPassList.get(0);
GVRShaderId shader = pass.getMaterial().getShaderType();
GVRShader template = shader.getTemplate(getGVRContext());
if (template != null)
{
template.bindShader(getGVRContext(), this, scene, isMultiview);
}
for (int i = 1; i < mRenderPassList.size(); ++i)
{
pass = mRenderPassList.get(i);
shader = pass.getMaterial().getShaderType();
template = shader.getTemplate(getGVRContext());
if (template != null)
{
template.bindShader(getGVRContext(), pass, scene, isMultiview);
}
}
} | java | public synchronized void bindShader(GVRScene scene, boolean isMultiview)
{
GVRRenderPass pass = mRenderPassList.get(0);
GVRShaderId shader = pass.getMaterial().getShaderType();
GVRShader template = shader.getTemplate(getGVRContext());
if (template != null)
{
template.bindShader(getGVRContext(), this, scene, isMultiview);
}
for (int i = 1; i < mRenderPassList.size(); ++i)
{
pass = mRenderPassList.get(i);
shader = pass.getMaterial().getShaderType();
template = shader.getTemplate(getGVRContext());
if (template != null)
{
template.bindShader(getGVRContext(), pass, scene, isMultiview);
}
}
} | [
"public",
"synchronized",
"void",
"bindShader",
"(",
"GVRScene",
"scene",
",",
"boolean",
"isMultiview",
")",
"{",
"GVRRenderPass",
"pass",
"=",
"mRenderPassList",
".",
"get",
"(",
"0",
")",
";",
"GVRShaderId",
"shader",
"=",
"pass",
".",
"getMaterial",
"(",
")",
".",
"getShaderType",
"(",
")",
";",
"GVRShader",
"template",
"=",
"shader",
".",
"getTemplate",
"(",
"getGVRContext",
"(",
")",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"template",
".",
"bindShader",
"(",
"getGVRContext",
"(",
")",
",",
"this",
",",
"scene",
",",
"isMultiview",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"mRenderPassList",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"pass",
"=",
"mRenderPassList",
".",
"get",
"(",
"i",
")",
";",
"shader",
"=",
"pass",
".",
"getMaterial",
"(",
")",
".",
"getShaderType",
"(",
")",
";",
"template",
"=",
"shader",
".",
"getTemplate",
"(",
"getGVRContext",
"(",
")",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"template",
".",
"bindShader",
"(",
"getGVRContext",
"(",
")",
",",
"pass",
",",
"scene",
",",
"isMultiview",
")",
";",
"}",
"}",
"}"
] | Selects a specific vertex and fragment shader to use for rendering.
If a shader template has been specified, it is used to generate
a vertex and fragment shader based on mesh attributes, bound textures
and light sources. If the textures bound to the material are changed
or a new light source is added, this function must be called again
to select the appropriate shaders. This function may cause recompilation
of shaders which is quite slow.
@param scene scene being rendered
@see GVRShaderTemplate GVRMaterialShader.getShaderType | [
"Selects",
"a",
"specific",
"vertex",
"and",
"fragment",
"shader",
"to",
"use",
"for",
"rendering",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java#L264-L283 |
161,593 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java | GVRRenderData.setCullFace | public GVRRenderData setCullFace(GVRCullFaceEnum cullFace, int passIndex) {
if (passIndex < mRenderPassList.size()) {
mRenderPassList.get(passIndex).setCullFace(cullFace);
} else {
Log.e(TAG, "Trying to set cull face to a invalid pass. Pass " + passIndex + " was not created.");
}
return this;
} | java | public GVRRenderData setCullFace(GVRCullFaceEnum cullFace, int passIndex) {
if (passIndex < mRenderPassList.size()) {
mRenderPassList.get(passIndex).setCullFace(cullFace);
} else {
Log.e(TAG, "Trying to set cull face to a invalid pass. Pass " + passIndex + " was not created.");
}
return this;
} | [
"public",
"GVRRenderData",
"setCullFace",
"(",
"GVRCullFaceEnum",
"cullFace",
",",
"int",
"passIndex",
")",
"{",
"if",
"(",
"passIndex",
"<",
"mRenderPassList",
".",
"size",
"(",
")",
")",
"{",
"mRenderPassList",
".",
"get",
"(",
"passIndex",
")",
".",
"setCullFace",
"(",
"cullFace",
")",
";",
"}",
"else",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Trying to set cull face to a invalid pass. Pass \"",
"+",
"passIndex",
"+",
"\" was not created.\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Set the face to be culled
@param cullFace
{@code GVRCullFaceEnum.Back} Tells Graphics API to discard
back faces, {@code GVRCullFaceEnum.Front} Tells Graphics API
to discard front faces, {@code GVRCullFaceEnum.None} Tells
Graphics API to not discard any face
@param passIndex
The rendering pass to set cull face state | [
"Set",
"the",
"face",
"to",
"be",
"culled"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java#L494-L501 |
161,594 | Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java | GVRRenderData.setDrawMode | public GVRRenderData setDrawMode(int drawMode) {
if (drawMode != GL_POINTS && drawMode != GL_LINES
&& drawMode != GL_LINE_STRIP && drawMode != GL_LINE_LOOP
&& drawMode != GL_TRIANGLES && drawMode != GL_TRIANGLE_STRIP
&& drawMode != GL_TRIANGLE_FAN) {
throw new IllegalArgumentException(
"drawMode must be one of GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP.");
}
NativeRenderData.setDrawMode(getNative(), drawMode);
return this;
} | java | public GVRRenderData setDrawMode(int drawMode) {
if (drawMode != GL_POINTS && drawMode != GL_LINES
&& drawMode != GL_LINE_STRIP && drawMode != GL_LINE_LOOP
&& drawMode != GL_TRIANGLES && drawMode != GL_TRIANGLE_STRIP
&& drawMode != GL_TRIANGLE_FAN) {
throw new IllegalArgumentException(
"drawMode must be one of GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP.");
}
NativeRenderData.setDrawMode(getNative(), drawMode);
return this;
} | [
"public",
"GVRRenderData",
"setDrawMode",
"(",
"int",
"drawMode",
")",
"{",
"if",
"(",
"drawMode",
"!=",
"GL_POINTS",
"&&",
"drawMode",
"!=",
"GL_LINES",
"&&",
"drawMode",
"!=",
"GL_LINE_STRIP",
"&&",
"drawMode",
"!=",
"GL_LINE_LOOP",
"&&",
"drawMode",
"!=",
"GL_TRIANGLES",
"&&",
"drawMode",
"!=",
"GL_TRIANGLE_STRIP",
"&&",
"drawMode",
"!=",
"GL_TRIANGLE_FAN",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"drawMode must be one of GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP.\"",
")",
";",
"}",
"NativeRenderData",
".",
"setDrawMode",
"(",
"getNative",
"(",
")",
",",
"drawMode",
")",
";",
"return",
"this",
";",
"}"
] | Set the draw mode for this mesh. Default is GL_TRIANGLES.
@param drawMode | [
"Set",
"the",
"draw",
"mode",
"for",
"this",
"mesh",
".",
"Default",
"is",
"GL_TRIANGLES",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRRenderData.java#L749-L759 |
161,595 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java | LayoutScroller.fling | public boolean fling(float velocityX, float velocityY, float velocityZ) {
boolean scrolled = true;
float viewportX = mScrollable.getViewPortWidth();
if (Float.isNaN(viewportX)) {
viewportX = 0;
}
float maxX = Math.min(MAX_SCROLLING_DISTANCE,
viewportX * MAX_VIEWPORT_LENGTHS);
float viewportY = mScrollable.getViewPortHeight();
if (Float.isNaN(viewportY)) {
viewportY = 0;
}
float maxY = Math.min(MAX_SCROLLING_DISTANCE,
viewportY * MAX_VIEWPORT_LENGTHS);
float xOffset = (maxX * velocityX)/VELOCITY_MAX;
float yOffset = (maxY * velocityY)/VELOCITY_MAX;
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "fling() velocity = [%f, %f, %f] offset = [%f, %f]",
velocityX, velocityY, velocityZ,
xOffset, yOffset);
if (equal(xOffset, 0)) {
xOffset = Float.NaN;
}
if (equal(yOffset, 0)) {
yOffset = Float.NaN;
}
// TODO: Think about Z-scrolling
mScrollable.scrollByOffset(xOffset, yOffset, Float.NaN, mInternalScrollListener);
return scrolled;
} | java | public boolean fling(float velocityX, float velocityY, float velocityZ) {
boolean scrolled = true;
float viewportX = mScrollable.getViewPortWidth();
if (Float.isNaN(viewportX)) {
viewportX = 0;
}
float maxX = Math.min(MAX_SCROLLING_DISTANCE,
viewportX * MAX_VIEWPORT_LENGTHS);
float viewportY = mScrollable.getViewPortHeight();
if (Float.isNaN(viewportY)) {
viewportY = 0;
}
float maxY = Math.min(MAX_SCROLLING_DISTANCE,
viewportY * MAX_VIEWPORT_LENGTHS);
float xOffset = (maxX * velocityX)/VELOCITY_MAX;
float yOffset = (maxY * velocityY)/VELOCITY_MAX;
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "fling() velocity = [%f, %f, %f] offset = [%f, %f]",
velocityX, velocityY, velocityZ,
xOffset, yOffset);
if (equal(xOffset, 0)) {
xOffset = Float.NaN;
}
if (equal(yOffset, 0)) {
yOffset = Float.NaN;
}
// TODO: Think about Z-scrolling
mScrollable.scrollByOffset(xOffset, yOffset, Float.NaN, mInternalScrollListener);
return scrolled;
} | [
"public",
"boolean",
"fling",
"(",
"float",
"velocityX",
",",
"float",
"velocityY",
",",
"float",
"velocityZ",
")",
"{",
"boolean",
"scrolled",
"=",
"true",
";",
"float",
"viewportX",
"=",
"mScrollable",
".",
"getViewPortWidth",
"(",
")",
";",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"viewportX",
")",
")",
"{",
"viewportX",
"=",
"0",
";",
"}",
"float",
"maxX",
"=",
"Math",
".",
"min",
"(",
"MAX_SCROLLING_DISTANCE",
",",
"viewportX",
"*",
"MAX_VIEWPORT_LENGTHS",
")",
";",
"float",
"viewportY",
"=",
"mScrollable",
".",
"getViewPortHeight",
"(",
")",
";",
"if",
"(",
"Float",
".",
"isNaN",
"(",
"viewportY",
")",
")",
"{",
"viewportY",
"=",
"0",
";",
"}",
"float",
"maxY",
"=",
"Math",
".",
"min",
"(",
"MAX_SCROLLING_DISTANCE",
",",
"viewportY",
"*",
"MAX_VIEWPORT_LENGTHS",
")",
";",
"float",
"xOffset",
"=",
"(",
"maxX",
"*",
"velocityX",
")",
"/",
"VELOCITY_MAX",
";",
"float",
"yOffset",
"=",
"(",
"maxY",
"*",
"velocityY",
")",
"/",
"VELOCITY_MAX",
";",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"fling() velocity = [%f, %f, %f] offset = [%f, %f]\"",
",",
"velocityX",
",",
"velocityY",
",",
"velocityZ",
",",
"xOffset",
",",
"yOffset",
")",
";",
"if",
"(",
"equal",
"(",
"xOffset",
",",
"0",
")",
")",
"{",
"xOffset",
"=",
"Float",
".",
"NaN",
";",
"}",
"if",
"(",
"equal",
"(",
"yOffset",
",",
"0",
")",
")",
"{",
"yOffset",
"=",
"Float",
".",
"NaN",
";",
"}",
"// TODO: Think about Z-scrolling",
"mScrollable",
".",
"scrollByOffset",
"(",
"xOffset",
",",
"yOffset",
",",
"Float",
".",
"NaN",
",",
"mInternalScrollListener",
")",
";",
"return",
"scrolled",
";",
"}"
] | Fling the content
@param velocityX The initial velocity in the X direction. Positive numbers mean that the
finger/cursor is moving to the left on the screen, which means we want to
scroll towards the beginning.
@param velocityY The initial velocity in the Y direction. Positive numbers mean that the
finger/cursor is moving down the screen, which means we want to scroll
towards the top.
@param velocityZ TODO: Z-scrolling is currently not supported
@return | [
"Fling",
"the",
"content"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java#L207-L242 |
161,596 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java | LayoutScroller.scrollToNextPage | public int scrollToNextPage() {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToNextPage getCurrentPage() = %d currentIndex = %d",
getCurrentPage(), mCurrentItemIndex);
if (mSupportScrollByPage) {
scrollToPage(getCurrentPage() + 1);
} else {
Log.w(TAG, "Pagination is not enabled!");
}
return mCurrentItemIndex;
} | java | public int scrollToNextPage() {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToNextPage getCurrentPage() = %d currentIndex = %d",
getCurrentPage(), mCurrentItemIndex);
if (mSupportScrollByPage) {
scrollToPage(getCurrentPage() + 1);
} else {
Log.w(TAG, "Pagination is not enabled!");
}
return mCurrentItemIndex;
} | [
"public",
"int",
"scrollToNextPage",
"(",
")",
"{",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"scrollToNextPage getCurrentPage() = %d currentIndex = %d\"",
",",
"getCurrentPage",
"(",
")",
",",
"mCurrentItemIndex",
")",
";",
"if",
"(",
"mSupportScrollByPage",
")",
"{",
"scrollToPage",
"(",
"getCurrentPage",
"(",
")",
"+",
"1",
")",
";",
"}",
"else",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Pagination is not enabled!\"",
")",
";",
"}",
"return",
"mCurrentItemIndex",
";",
"}"
] | Scroll to the next page. To process the scrolling by pages LayoutScroller must be constructed
with a pageSize greater than zero.
@return the new current item after the scrolling processed. | [
"Scroll",
"to",
"the",
"next",
"page",
".",
"To",
"process",
"the",
"scrolling",
"by",
"pages",
"LayoutScroller",
"must",
"be",
"constructed",
"with",
"a",
"pageSize",
"greater",
"than",
"zero",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java#L249-L260 |
161,597 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java | LayoutScroller.scrollToPage | public int scrollToPage(int pageNumber) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToPage pageNumber = %d mPageCount = %d",
pageNumber, mPageCount);
if (mSupportScrollByPage &&
(mScrollOver || (pageNumber >= 0 && pageNumber <= mPageCount - 1))) {
scrollToItem(getFirstItemIndexOnPage(pageNumber));
} else {
Log.w(TAG, "Pagination is not enabled!");
}
return mCurrentItemIndex;
} | java | public int scrollToPage(int pageNumber) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToPage pageNumber = %d mPageCount = %d",
pageNumber, mPageCount);
if (mSupportScrollByPage &&
(mScrollOver || (pageNumber >= 0 && pageNumber <= mPageCount - 1))) {
scrollToItem(getFirstItemIndexOnPage(pageNumber));
} else {
Log.w(TAG, "Pagination is not enabled!");
}
return mCurrentItemIndex;
} | [
"public",
"int",
"scrollToPage",
"(",
"int",
"pageNumber",
")",
"{",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"scrollToPage pageNumber = %d mPageCount = %d\"",
",",
"pageNumber",
",",
"mPageCount",
")",
";",
"if",
"(",
"mSupportScrollByPage",
"&&",
"(",
"mScrollOver",
"||",
"(",
"pageNumber",
">=",
"0",
"&&",
"pageNumber",
"<=",
"mPageCount",
"-",
"1",
")",
")",
")",
"{",
"scrollToItem",
"(",
"getFirstItemIndexOnPage",
"(",
"pageNumber",
")",
")",
";",
"}",
"else",
"{",
"Log",
".",
"w",
"(",
"TAG",
",",
"\"Pagination is not enabled!\"",
")",
";",
"}",
"return",
"mCurrentItemIndex",
";",
"}"
] | Scroll to specific page. The final page might be different from the requested one if the
requested page is larger than the last page. To process the scrolling by pages
LayoutScroller must be constructed with a pageSize greater than zero.
@param pageNumber page to scroll to
@return the new current item after the scrolling processed. | [
"Scroll",
"to",
"specific",
"page",
".",
"The",
"final",
"page",
"might",
"be",
"different",
"from",
"the",
"requested",
"one",
"if",
"the",
"requested",
"page",
"is",
"larger",
"than",
"the",
"last",
"page",
".",
"To",
"process",
"the",
"scrolling",
"by",
"pages",
"LayoutScroller",
"must",
"be",
"constructed",
"with",
"a",
"pageSize",
"greater",
"than",
"zero",
"."
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java#L286-L297 |
161,598 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java | LayoutScroller.scrollToItem | public int scrollToItem(int position) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToItem position = %d", position);
scrollToPosition(position);
return mCurrentItemIndex;
} | java | public int scrollToItem(int position) {
Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "scrollToItem position = %d", position);
scrollToPosition(position);
return mCurrentItemIndex;
} | [
"public",
"int",
"scrollToItem",
"(",
"int",
"position",
")",
"{",
"Log",
".",
"d",
"(",
"Log",
".",
"SUBSYSTEM",
".",
"LAYOUT",
",",
"TAG",
",",
"\"scrollToItem position = %d\"",
",",
"position",
")",
";",
"scrollToPosition",
"(",
"position",
")",
";",
"return",
"mCurrentItemIndex",
";",
"}"
] | Scroll to the specific position
@param position
@return the new current item after the scrolling processed. | [
"Scroll",
"to",
"the",
"specific",
"position"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java#L336-L340 |
161,599 | Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java | LayoutScroller.getCurrentPage | public int getCurrentPage() {
int currentPage = 1;
int count = mScrollable.getScrollingItemsCount();
if (mSupportScrollByPage && mCurrentItemIndex >= 0 &&
mCurrentItemIndex < count) {
currentPage = (Math.min(mCurrentItemIndex + mPageSize - 1, count - 1)/mPageSize);
}
return currentPage;
} | java | public int getCurrentPage() {
int currentPage = 1;
int count = mScrollable.getScrollingItemsCount();
if (mSupportScrollByPage && mCurrentItemIndex >= 0 &&
mCurrentItemIndex < count) {
currentPage = (Math.min(mCurrentItemIndex + mPageSize - 1, count - 1)/mPageSize);
}
return currentPage;
} | [
"public",
"int",
"getCurrentPage",
"(",
")",
"{",
"int",
"currentPage",
"=",
"1",
";",
"int",
"count",
"=",
"mScrollable",
".",
"getScrollingItemsCount",
"(",
")",
";",
"if",
"(",
"mSupportScrollByPage",
"&&",
"mCurrentItemIndex",
">=",
"0",
"&&",
"mCurrentItemIndex",
"<",
"count",
")",
"{",
"currentPage",
"=",
"(",
"Math",
".",
"min",
"(",
"mCurrentItemIndex",
"+",
"mPageSize",
"-",
"1",
",",
"count",
"-",
"1",
")",
"/",
"mPageSize",
")",
";",
"}",
"return",
"currentPage",
";",
"}"
] | Gets the current page
@return | [
"Gets",
"the",
"current",
"page"
] | 05034d465a7b0a494fabb9e9f2971ac19392f32d | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/layout/LayoutScroller.java#L346-L354 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.