repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckForAll.java
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.impl; public class FsSecurityCheckForAll implements FsSecurityChecker { boolean _locked = false; boolean _readable = true; boolean _writable = true; public boolean isLocked() { return _locked; } @Override
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckForAll.java import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.impl; public class FsSecurityCheckForAll implements FsSecurityChecker { boolean _locked = false; boolean _readable = true; boolean _writable = true; public boolean isLocked() { return _locked; } @Override
public boolean isLocked(FsService fsService, FsItem fsi)
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckForAll.java
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.impl; public class FsSecurityCheckForAll implements FsSecurityChecker { boolean _locked = false; boolean _readable = true; boolean _writable = true; public boolean isLocked() { return _locked; } @Override
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckForAll.java import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.impl; public class FsSecurityCheckForAll implements FsSecurityChecker { boolean _locked = false; boolean _readable = true; boolean _writable = true; public boolean isLocked() { return _locked; } @Override
public boolean isLocked(FsService fsService, FsItem fsi)
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/controller/executors/SearchCommandExecutor.java
// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java // public interface CommandExecutor // { // void execute(CommandExecutionContext commandExecutionContext) // throws Exception; // } // // Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java // public abstract class FsItemFilterUtils // { // public static FsItemFilter FILTER_ALL = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return true; // } // }; // // public static FsItemFilter FILTER_FOLDER = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.isFolder(); // } // }; // // public static FsItemFilter createFileNameKeywordFilter(final String keyword) // { // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.getName().contains(keyword); // } // }; // } // // public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles, // FsItemFilter filter) // { // List<FsItemEx> filtered = new ArrayList<FsItemEx>(); // for (FsItemEx file : sourceFiles) // { // if (filter.accepts(file)) // filtered.add(file); // } // // return filtered.toArray(new FsItemEx[0]); // } // // /** // * returns a FsItemFilter according to given mimeFilters // * // * @param mimeFilters // * An array of MIME types, if <code>null</code> no filtering is // * done // * @return A filter that only accepts the supplied MIME types. // */ // public static FsItemFilter createMimeFilter(final String[] mimeFilters) // { // if (mimeFilters == null || mimeFilters.length == 0) // return FILTER_ALL; // // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // String mimeType = item.getMimeType().toUpperCase(); // // for (String mf : mimeFilters) // { // mf = mf.toUpperCase(); // if (mimeType.startsWith(mf + "/") || mimeType.equals(mf)) // return true; // } // return false; // } // }; // } // // } // // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java // public abstract class AbstractJsonCommandExecutor extends // AbstractCommandExecutor // { // @Override // final public void execute(FsService fsService, HttpServletRequest request, // HttpServletResponse response, ServletContext servletContext) // throws Exception // { // JSONObject json = new JSONObject(); // try // { // execute(fsService, request, servletContext, json); // } // catch (ErrorException e) // { // if (e.getArgs() == null || e.getArgs().length == 0) // { // json.put("error", e.getError()); // } // else // { // JSONArray errors = new JSONArray(); // errors.put(e.getError()); // for (String arg : e.getArgs()) // { // errors.put(arg); // } // json.put("error", errors); // } // } // catch (Exception e) // { // e.printStackTrace(); // json.put("error", e.getMessage()); // } // finally // { // // response.setContentType("application/json; charset=UTF-8"); // response.setContentType("text/html; charset=UTF-8"); // // PrintWriter writer = response.getWriter(); // json.write(writer); // writer.flush(); // writer.close(); // } // } // // protected abstract void execute(FsService fsService, // HttpServletRequest request, ServletContext servletContext, // JSONObject json) throws Exception; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.grapheco.elfinder.controller.executor.CommandExecutor; import org.grapheco.elfinder.util.FsItemFilterUtils; import org.json.JSONObject; import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.controller.executors; public class SearchCommandExecutor extends AbstractJsonCommandExecutor implements CommandExecutor { @Override
// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java // public interface CommandExecutor // { // void execute(CommandExecutionContext commandExecutionContext) // throws Exception; // } // // Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java // public abstract class FsItemFilterUtils // { // public static FsItemFilter FILTER_ALL = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return true; // } // }; // // public static FsItemFilter FILTER_FOLDER = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.isFolder(); // } // }; // // public static FsItemFilter createFileNameKeywordFilter(final String keyword) // { // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.getName().contains(keyword); // } // }; // } // // public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles, // FsItemFilter filter) // { // List<FsItemEx> filtered = new ArrayList<FsItemEx>(); // for (FsItemEx file : sourceFiles) // { // if (filter.accepts(file)) // filtered.add(file); // } // // return filtered.toArray(new FsItemEx[0]); // } // // /** // * returns a FsItemFilter according to given mimeFilters // * // * @param mimeFilters // * An array of MIME types, if <code>null</code> no filtering is // * done // * @return A filter that only accepts the supplied MIME types. // */ // public static FsItemFilter createMimeFilter(final String[] mimeFilters) // { // if (mimeFilters == null || mimeFilters.length == 0) // return FILTER_ALL; // // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // String mimeType = item.getMimeType().toUpperCase(); // // for (String mf : mimeFilters) // { // mf = mf.toUpperCase(); // if (mimeType.startsWith(mf + "/") || mimeType.equals(mf)) // return true; // } // return false; // } // }; // } // // } // // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java // public abstract class AbstractJsonCommandExecutor extends // AbstractCommandExecutor // { // @Override // final public void execute(FsService fsService, HttpServletRequest request, // HttpServletResponse response, ServletContext servletContext) // throws Exception // { // JSONObject json = new JSONObject(); // try // { // execute(fsService, request, servletContext, json); // } // catch (ErrorException e) // { // if (e.getArgs() == null || e.getArgs().length == 0) // { // json.put("error", e.getError()); // } // else // { // JSONArray errors = new JSONArray(); // errors.put(e.getError()); // for (String arg : e.getArgs()) // { // errors.put(arg); // } // json.put("error", errors); // } // } // catch (Exception e) // { // e.printStackTrace(); // json.put("error", e.getMessage()); // } // finally // { // // response.setContentType("application/json; charset=UTF-8"); // response.setContentType("text/html; charset=UTF-8"); // // PrintWriter writer = response.getWriter(); // json.write(writer); // writer.flush(); // writer.close(); // } // } // // protected abstract void execute(FsService fsService, // HttpServletRequest request, ServletContext servletContext, // JSONObject json) throws Exception; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/controller/executors/SearchCommandExecutor.java import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.grapheco.elfinder.controller.executor.CommandExecutor; import org.grapheco.elfinder.util.FsItemFilterUtils; import org.json.JSONObject; import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.controller.executors; public class SearchCommandExecutor extends AbstractJsonCommandExecutor implements CommandExecutor { @Override
public void execute(FsService fsService, HttpServletRequest request,
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/controller/executors/SearchCommandExecutor.java
// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java // public interface CommandExecutor // { // void execute(CommandExecutionContext commandExecutionContext) // throws Exception; // } // // Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java // public abstract class FsItemFilterUtils // { // public static FsItemFilter FILTER_ALL = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return true; // } // }; // // public static FsItemFilter FILTER_FOLDER = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.isFolder(); // } // }; // // public static FsItemFilter createFileNameKeywordFilter(final String keyword) // { // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.getName().contains(keyword); // } // }; // } // // public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles, // FsItemFilter filter) // { // List<FsItemEx> filtered = new ArrayList<FsItemEx>(); // for (FsItemEx file : sourceFiles) // { // if (filter.accepts(file)) // filtered.add(file); // } // // return filtered.toArray(new FsItemEx[0]); // } // // /** // * returns a FsItemFilter according to given mimeFilters // * // * @param mimeFilters // * An array of MIME types, if <code>null</code> no filtering is // * done // * @return A filter that only accepts the supplied MIME types. // */ // public static FsItemFilter createMimeFilter(final String[] mimeFilters) // { // if (mimeFilters == null || mimeFilters.length == 0) // return FILTER_ALL; // // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // String mimeType = item.getMimeType().toUpperCase(); // // for (String mf : mimeFilters) // { // mf = mf.toUpperCase(); // if (mimeType.startsWith(mf + "/") || mimeType.equals(mf)) // return true; // } // return false; // } // }; // } // // } // // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java // public abstract class AbstractJsonCommandExecutor extends // AbstractCommandExecutor // { // @Override // final public void execute(FsService fsService, HttpServletRequest request, // HttpServletResponse response, ServletContext servletContext) // throws Exception // { // JSONObject json = new JSONObject(); // try // { // execute(fsService, request, servletContext, json); // } // catch (ErrorException e) // { // if (e.getArgs() == null || e.getArgs().length == 0) // { // json.put("error", e.getError()); // } // else // { // JSONArray errors = new JSONArray(); // errors.put(e.getError()); // for (String arg : e.getArgs()) // { // errors.put(arg); // } // json.put("error", errors); // } // } // catch (Exception e) // { // e.printStackTrace(); // json.put("error", e.getMessage()); // } // finally // { // // response.setContentType("application/json; charset=UTF-8"); // response.setContentType("text/html; charset=UTF-8"); // // PrintWriter writer = response.getWriter(); // json.write(writer); // writer.flush(); // writer.close(); // } // } // // protected abstract void execute(FsService fsService, // HttpServletRequest request, ServletContext servletContext, // JSONObject json) throws Exception; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.grapheco.elfinder.controller.executor.CommandExecutor; import org.grapheco.elfinder.util.FsItemFilterUtils; import org.json.JSONObject; import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.controller.executors; public class SearchCommandExecutor extends AbstractJsonCommandExecutor implements CommandExecutor { @Override public void execute(FsService fsService, HttpServletRequest request, ServletContext servletContext, JSONObject json) throws Exception { json.put( "files",
// Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutor.java // public interface CommandExecutor // { // void execute(CommandExecutionContext commandExecutionContext) // throws Exception; // } // // Path: src/main/java/org/grapheco/elfinder/util/FsItemFilterUtils.java // public abstract class FsItemFilterUtils // { // public static FsItemFilter FILTER_ALL = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return true; // } // }; // // public static FsItemFilter FILTER_FOLDER = new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.isFolder(); // } // }; // // public static FsItemFilter createFileNameKeywordFilter(final String keyword) // { // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // return item.getName().contains(keyword); // } // }; // } // // public static FsItemEx[] filterFiles(FsItemEx[] sourceFiles, // FsItemFilter filter) // { // List<FsItemEx> filtered = new ArrayList<FsItemEx>(); // for (FsItemEx file : sourceFiles) // { // if (filter.accepts(file)) // filtered.add(file); // } // // return filtered.toArray(new FsItemEx[0]); // } // // /** // * returns a FsItemFilter according to given mimeFilters // * // * @param mimeFilters // * An array of MIME types, if <code>null</code> no filtering is // * done // * @return A filter that only accepts the supplied MIME types. // */ // public static FsItemFilter createMimeFilter(final String[] mimeFilters) // { // if (mimeFilters == null || mimeFilters.length == 0) // return FILTER_ALL; // // return new FsItemFilter() // { // @Override // public boolean accepts(FsItemEx item) // { // String mimeType = item.getMimeType().toUpperCase(); // // for (String mf : mimeFilters) // { // mf = mf.toUpperCase(); // if (mimeType.startsWith(mf + "/") || mimeType.equals(mf)) // return true; // } // return false; // } // }; // } // // } // // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java // public abstract class AbstractJsonCommandExecutor extends // AbstractCommandExecutor // { // @Override // final public void execute(FsService fsService, HttpServletRequest request, // HttpServletResponse response, ServletContext servletContext) // throws Exception // { // JSONObject json = new JSONObject(); // try // { // execute(fsService, request, servletContext, json); // } // catch (ErrorException e) // { // if (e.getArgs() == null || e.getArgs().length == 0) // { // json.put("error", e.getError()); // } // else // { // JSONArray errors = new JSONArray(); // errors.put(e.getError()); // for (String arg : e.getArgs()) // { // errors.put(arg); // } // json.put("error", errors); // } // } // catch (Exception e) // { // e.printStackTrace(); // json.put("error", e.getMessage()); // } // finally // { // // response.setContentType("application/json; charset=UTF-8"); // response.setContentType("text/html; charset=UTF-8"); // // PrintWriter writer = response.getWriter(); // json.write(writer); // writer.flush(); // writer.close(); // } // } // // protected abstract void execute(FsService fsService, // HttpServletRequest request, ServletContext servletContext, // JSONObject json) throws Exception; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/controller/executors/SearchCommandExecutor.java import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.grapheco.elfinder.controller.executor.CommandExecutor; import org.grapheco.elfinder.util.FsItemFilterUtils; import org.json.JSONObject; import org.grapheco.elfinder.controller.executor.AbstractJsonCommandExecutor; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.controller.executors; public class SearchCommandExecutor extends AbstractJsonCommandExecutor implements CommandExecutor { @Override public void execute(FsService fsService, HttpServletRequest request, ServletContext servletContext, JSONObject json) throws Exception { json.put( "files",
files2JsonArray(request, FsItemFilterUtils.filterFiles(
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java
// Path: src/main/java/org/grapheco/elfinder/controller/ErrorException.java // public class ErrorException extends RuntimeException // { // // private final String error; // private final String[] args; // // /** // * See /elfinder/js/i18n/elfinder.??.js for error codes. // * // * @param error // * The error code. // * @param args // * Any arguments needed by the error message. // */ // public ErrorException(String error, String... args) // { // this.error = error; // this.args = args; // } // // /** // * @return The error code that will translated by elfinder to a nice // * message. // */ // public String getError() // { // return error; // } // // /** // * @return The arguments needed by the error message. // */ // public String[] getArgs() // { // return args; // } // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.controller.ErrorException; import org.json.JSONArray; import org.json.JSONObject; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.controller.executor; public abstract class AbstractJsonCommandExecutor extends AbstractCommandExecutor { @Override
// Path: src/main/java/org/grapheco/elfinder/controller/ErrorException.java // public class ErrorException extends RuntimeException // { // // private final String error; // private final String[] args; // // /** // * See /elfinder/js/i18n/elfinder.??.js for error codes. // * // * @param error // * The error code. // * @param args // * Any arguments needed by the error message. // */ // public ErrorException(String error, String... args) // { // this.error = error; // this.args = args; // } // // /** // * @return The error code that will translated by elfinder to a nice // * message. // */ // public String getError() // { // return error; // } // // /** // * @return The arguments needed by the error message. // */ // public String[] getArgs() // { // return args; // } // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.controller.ErrorException; import org.json.JSONArray; import org.json.JSONObject; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.controller.executor; public abstract class AbstractJsonCommandExecutor extends AbstractCommandExecutor { @Override
final public void execute(FsService fsService, HttpServletRequest request,
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java
// Path: src/main/java/org/grapheco/elfinder/controller/ErrorException.java // public class ErrorException extends RuntimeException // { // // private final String error; // private final String[] args; // // /** // * See /elfinder/js/i18n/elfinder.??.js for error codes. // * // * @param error // * The error code. // * @param args // * Any arguments needed by the error message. // */ // public ErrorException(String error, String... args) // { // this.error = error; // this.args = args; // } // // /** // * @return The error code that will translated by elfinder to a nice // * message. // */ // public String getError() // { // return error; // } // // /** // * @return The arguments needed by the error message. // */ // public String[] getArgs() // { // return args; // } // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.controller.ErrorException; import org.json.JSONArray; import org.json.JSONObject; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.controller.executor; public abstract class AbstractJsonCommandExecutor extends AbstractCommandExecutor { @Override final public void execute(FsService fsService, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { JSONObject json = new JSONObject(); try { execute(fsService, request, servletContext, json); }
// Path: src/main/java/org/grapheco/elfinder/controller/ErrorException.java // public class ErrorException extends RuntimeException // { // // private final String error; // private final String[] args; // // /** // * See /elfinder/js/i18n/elfinder.??.js for error codes. // * // * @param error // * The error code. // * @param args // * Any arguments needed by the error message. // */ // public ErrorException(String error, String... args) // { // this.error = error; // this.args = args; // } // // /** // * @return The error code that will translated by elfinder to a nice // * message. // */ // public String getError() // { // return error; // } // // /** // * @return The arguments needed by the error message. // */ // public String[] getArgs() // { // return args; // } // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/controller/executor/AbstractJsonCommandExecutor.java import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.controller.ErrorException; import org.json.JSONArray; import org.json.JSONObject; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.controller.executor; public abstract class AbstractJsonCommandExecutor extends AbstractCommandExecutor { @Override final public void execute(FsService fsService, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { JSONObject json = new JSONObject(); try { execute(fsService, request, servletContext, json); }
catch (ErrorException e)
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckFilterMapping.java
// Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // }
import java.util.regex.Pattern; import org.grapheco.elfinder.service.FsSecurityChecker;
package org.grapheco.elfinder.impl; public class FsSecurityCheckFilterMapping {
// Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // Path: src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckFilterMapping.java import java.util.regex.Pattern; import org.grapheco.elfinder.service.FsSecurityChecker; package org.grapheco.elfinder.impl; public class FsSecurityCheckFilterMapping {
FsSecurityChecker _checker;
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckerChain.java
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import java.io.IOException; import java.util.List; import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.impl; public class FsSecurityCheckerChain implements FsSecurityChecker { private static final FsSecurityChecker DEFAULT_SECURITY_CHECKER = new FsSecurityCheckForAll(); List<FsSecurityCheckFilterMapping> _filterMappings;
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckerChain.java import java.io.IOException; import java.util.List; import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.impl; public class FsSecurityCheckerChain implements FsSecurityChecker { private static final FsSecurityChecker DEFAULT_SECURITY_CHECKER = new FsSecurityCheckForAll(); List<FsSecurityCheckFilterMapping> _filterMappings;
private FsSecurityChecker getChecker(FsService fsService, FsItem fsi)
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckerChain.java
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // }
import java.io.IOException; import java.util.List; import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService;
package org.grapheco.elfinder.impl; public class FsSecurityCheckerChain implements FsSecurityChecker { private static final FsSecurityChecker DEFAULT_SECURITY_CHECKER = new FsSecurityCheckForAll(); List<FsSecurityCheckFilterMapping> _filterMappings;
// Path: src/main/java/org/grapheco/elfinder/service/FsItem.java // public interface FsItem // { // FsVolume getVolume(); // } // // Path: src/main/java/org/grapheco/elfinder/service/FsSecurityChecker.java // public interface FsSecurityChecker // { // // boolean isLocked(FsService fsService, FsItem fsi) throws IOException; // // boolean isReadable(FsService fsService, FsItem fsi) throws IOException; // // boolean isWritable(FsService fsService, FsItem fsi) throws IOException; // // } // // Path: src/main/java/org/grapheco/elfinder/service/FsService.java // public interface FsService // { // FsItem fromHash(String hash) throws IOException; // // String getHash(FsItem item) throws IOException; // // FsSecurityChecker getSecurityChecker(); // // String getVolumeId(FsVolume volume); // // FsVolume[] getVolumes(); // // FsServiceConfig getServiceConfig(); // // /** // * find files by name pattern, this provides a simple recursively iteration // * based method lucene engines can be introduced to improve it! This // * searches across all volumes. // * // * @param filter // * The filter to apply to select files. // * @return A collection of files that match the filter and gave the root as // * a parent. // */ // // TODO: bad designs: FsItemEx should not used here top level interfaces // // should only know FsItem instead of FsItemEx // FsItemEx[] find(FsItemFilter filter); // } // Path: src/main/java/org/grapheco/elfinder/impl/FsSecurityCheckerChain.java import java.io.IOException; import java.util.List; import org.grapheco.elfinder.service.FsItem; import org.grapheco.elfinder.service.FsSecurityChecker; import org.grapheco.elfinder.service.FsService; package org.grapheco.elfinder.impl; public class FsSecurityCheckerChain implements FsSecurityChecker { private static final FsSecurityChecker DEFAULT_SECURITY_CHECKER = new FsSecurityCheckForAll(); List<FsSecurityCheckFilterMapping> _filterMappings;
private FsSecurityChecker getChecker(FsService fsService, FsItem fsi)
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/service/FsItemFilter.java
// Path: src/main/java/org/grapheco/elfinder/controller/executor/FsItemEx.java // public class FsItemEx // { // private FsItem _f; // // private FsService _s; // // private FsVolume _v; // // public FsItemEx(FsItem fsi, FsService fsService) // { // _f = fsi; // _v = fsi.getVolume(); // _s = fsService; // } // // public FsItemEx(FsItemEx parent, String name) throws IOException // { // _v = parent._v; // _s = parent._s; // // Directories may already have a trailing slash on them so we make sure // // we don't double up // String path = _v.getPath(parent._f); // if (path != null) // { // if (!path.endsWith("/")) // { // path = path + "/"; // } // path = path + name; // } // else // { // path = name; // } // _f = _v.fromPath(path); // } // // public FsItemEx createChild(String name) throws IOException // { // return new FsItemEx(this, name); // } // // public void createFile() throws IOException // { // _v.createFile(_f); // } // // public void createFolder() throws IOException // { // _v.createFolder(_f); // } // // public void delete() throws IOException // { // if (_v.isFolder(_f)) // { // _v.deleteFolder(_f); // } // else // { // _v.deleteFile(_f); // } // } // // public void deleteFile() throws IOException // { // _v.deleteFile(_f); // } // // public void deleteFolder() throws IOException // { // _v.deleteFolder(_f); // } // // public boolean exists() // { // return _v.exists(_f); // } // // public String getHash() throws IOException // { // return _s.getHash(_f); // } // // public long getLastModified() // { // return _v.getLastModified(_f); // } // // public String getMimeType() // { // return _v.getMimeType(_f); // } // // public String getName() // { // return _v.getName(_f); // } // // public FsItemEx getParent() // { // return new FsItemEx(_v.getParent(_f), _s); // } // // public String getPath() throws IOException // { // return _v.getPath(_f); // } // // public long getSize() throws IOException // { // return _v.getSize(_f); // } // // public String getVolumeId() // { // return _s.getVolumeId(_v); // } // // public String getVolumnName() // { // return _v.getName(); // } // // public boolean hasChildFolder() // { // return _v.hasChildFolder(_f); // } // // public boolean isFolder() // { // return _v.isFolder(_f); // } // // public boolean isLocked(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isLocked(_s, _f); // } // // public boolean isReadable(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isReadable(_s, _f); // } // // public boolean isRoot() // { // return _v.isRoot(_f); // } // // public boolean isWritable(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isWritable(_s, _f); // } // // public List<FsItemEx> listChildren() // { // List<FsItemEx> list = new ArrayList<FsItemEx>(); // for (FsItem child : _v.listChildren(_f)) // { // list.add(new FsItemEx(child, _s)); // } // return list; // } // // public InputStream openInputStream() throws IOException // { // return _v.openInputStream(_f); // } // // public void writeStream(InputStream is) throws IOException // { // _v.writeStream(_f, is); // } // // public void renameTo(FsItemEx dst) throws IOException // { // _v.rename(_f, dst._f); // } // // public List<FsItemEx> listChildren(FsItemFilter filter) // { // List<FsItemEx> list = new ArrayList<FsItemEx>(); // for (FsItem child : _v.listChildren(_f)) // { // FsItemEx childEx = new FsItemEx(child, _s); // if (filter.accepts(childEx)) // { // list.add(childEx); // } // } // return list; // } // // public String getURL() // { // return _v.getURL(_f); // } // // public void filterOptions(Map<String, Object> map) // { // _v.filterOptions(_f, map); // } // }
import org.grapheco.elfinder.controller.executor.FsItemEx;
package org.grapheco.elfinder.service; /** * A FsItemFilter tells if a FsItem is matched or not * * @author bluejoe * */ public interface FsItemFilter { // TODO: bad designs: FsItemEx should not used here // top level interfaces should only know FsItem instead of FsItemEx
// Path: src/main/java/org/grapheco/elfinder/controller/executor/FsItemEx.java // public class FsItemEx // { // private FsItem _f; // // private FsService _s; // // private FsVolume _v; // // public FsItemEx(FsItem fsi, FsService fsService) // { // _f = fsi; // _v = fsi.getVolume(); // _s = fsService; // } // // public FsItemEx(FsItemEx parent, String name) throws IOException // { // _v = parent._v; // _s = parent._s; // // Directories may already have a trailing slash on them so we make sure // // we don't double up // String path = _v.getPath(parent._f); // if (path != null) // { // if (!path.endsWith("/")) // { // path = path + "/"; // } // path = path + name; // } // else // { // path = name; // } // _f = _v.fromPath(path); // } // // public FsItemEx createChild(String name) throws IOException // { // return new FsItemEx(this, name); // } // // public void createFile() throws IOException // { // _v.createFile(_f); // } // // public void createFolder() throws IOException // { // _v.createFolder(_f); // } // // public void delete() throws IOException // { // if (_v.isFolder(_f)) // { // _v.deleteFolder(_f); // } // else // { // _v.deleteFile(_f); // } // } // // public void deleteFile() throws IOException // { // _v.deleteFile(_f); // } // // public void deleteFolder() throws IOException // { // _v.deleteFolder(_f); // } // // public boolean exists() // { // return _v.exists(_f); // } // // public String getHash() throws IOException // { // return _s.getHash(_f); // } // // public long getLastModified() // { // return _v.getLastModified(_f); // } // // public String getMimeType() // { // return _v.getMimeType(_f); // } // // public String getName() // { // return _v.getName(_f); // } // // public FsItemEx getParent() // { // return new FsItemEx(_v.getParent(_f), _s); // } // // public String getPath() throws IOException // { // return _v.getPath(_f); // } // // public long getSize() throws IOException // { // return _v.getSize(_f); // } // // public String getVolumeId() // { // return _s.getVolumeId(_v); // } // // public String getVolumnName() // { // return _v.getName(); // } // // public boolean hasChildFolder() // { // return _v.hasChildFolder(_f); // } // // public boolean isFolder() // { // return _v.isFolder(_f); // } // // public boolean isLocked(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isLocked(_s, _f); // } // // public boolean isReadable(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isReadable(_s, _f); // } // // public boolean isRoot() // { // return _v.isRoot(_f); // } // // public boolean isWritable(FsItemEx fsi) throws IOException // { // return _s.getSecurityChecker().isWritable(_s, _f); // } // // public List<FsItemEx> listChildren() // { // List<FsItemEx> list = new ArrayList<FsItemEx>(); // for (FsItem child : _v.listChildren(_f)) // { // list.add(new FsItemEx(child, _s)); // } // return list; // } // // public InputStream openInputStream() throws IOException // { // return _v.openInputStream(_f); // } // // public void writeStream(InputStream is) throws IOException // { // _v.writeStream(_f, is); // } // // public void renameTo(FsItemEx dst) throws IOException // { // _v.rename(_f, dst._f); // } // // public List<FsItemEx> listChildren(FsItemFilter filter) // { // List<FsItemEx> list = new ArrayList<FsItemEx>(); // for (FsItem child : _v.listChildren(_f)) // { // FsItemEx childEx = new FsItemEx(child, _s); // if (filter.accepts(childEx)) // { // list.add(childEx); // } // } // return list; // } // // public String getURL() // { // return _v.getURL(_f); // } // // public void filterOptions(Map<String, Object> map) // { // _v.filterOptions(_f, map); // } // } // Path: src/main/java/org/grapheco/elfinder/service/FsItemFilter.java import org.grapheco.elfinder.controller.executor.FsItemEx; package org.grapheco.elfinder.service; /** * A FsItemFilter tells if a FsItem is matched or not * * @author bluejoe * */ public interface FsItemFilter { // TODO: bad designs: FsItemEx should not used here // top level interfaces should only know FsItem instead of FsItemEx
public boolean accepts(FsItemEx item);
bluejoe2008/elfinder-2.x-servlet
src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutionContext.java
// Path: src/main/java/org/grapheco/elfinder/service/FsServiceFactory.java // public interface FsServiceFactory // { // /** // * sometimes a FsService should be constructed dynamically according to // * current web request. e.g users may own separated file spaces in a net // * disk service platform, in this case, getFileService() get user principal // * from current request and offers him/her different file view. // * // * @param request // * The current HttpServletRequest. // * @param servletContext // * The servlet context. // * @return The {@link FsService} for the current request. // */ // FsService getFileService(HttpServletRequest request, // ServletContext servletContext); // // }
import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.service.FsServiceFactory;
package org.grapheco.elfinder.controller.executor; public interface CommandExecutionContext {
// Path: src/main/java/org/grapheco/elfinder/service/FsServiceFactory.java // public interface FsServiceFactory // { // /** // * sometimes a FsService should be constructed dynamically according to // * current web request. e.g users may own separated file spaces in a net // * disk service platform, in this case, getFileService() get user principal // * from current request and offers him/her different file view. // * // * @param request // * The current HttpServletRequest. // * @param servletContext // * The servlet context. // * @return The {@link FsService} for the current request. // */ // FsService getFileService(HttpServletRequest request, // ServletContext servletContext); // // } // Path: src/main/java/org/grapheco/elfinder/controller/executor/CommandExecutionContext.java import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.grapheco.elfinder.service.FsServiceFactory; package org.grapheco.elfinder.controller.executor; public interface CommandExecutionContext {
FsServiceFactory getFsServiceFactory();
mobialia/gwt-android-emu
androidemu/src/main/java/android/widget/ListView.java
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // }
import android.database.DataSetObserver; import android.view.View; import android.widget.AdapterView.OnItemClickListener; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener;
package android.widget; public class ListView extends View { Adapter mAdapter; OnItemClickListener listener;
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // Path: androidemu/src/main/java/android/widget/ListView.java import android.database.DataSetObserver; import android.view.View; import android.widget.AdapterView.OnItemClickListener; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; package android.widget; public class ListView extends View { Adapter mAdapter; OnItemClickListener listener;
DataSetObserver mDataSetObserver;
mobialia/gwt-android-emu
androidemu/src/main/java/android/app/ProgressDialog.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/DialogInterface.java // public interface DialogInterface { // // public static final int BUTTON_NEGATIVE = -2; // public static final int BUTTON_NEUTRAL = -3; // public static final int BUTTON_POSITIVE = -1; // // public abstract void cancel(); // // public abstract void dismiss(); // // public interface OnClickListener { // public void onClick(DialogInterface dialog, int which); // } // }
import android.Res; import android.content.Context; import android.content.DialogInterface; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.VerticalPanel;
package android.app; public class ProgressDialog extends Dialog implements DialogInterface { private SimplePanel titleLabelContainer, messageLabelContainer; private Label titleLabel, messageLabel; public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate) { return new ProgressDialog(title, message, false); } public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { return new ProgressDialog(title, message, cancelable); } public ProgressDialog(CharSequence title, CharSequence message, boolean cancelable) { super(cancelable); VerticalPanel vp = new VerticalPanel(); titleLabelContainer = new SimplePanel(); messageLabelContainer = new SimplePanel(); vp.add(titleLabelContainer); vp.add(messageLabelContainer); setTitle(title); setMessage(message); popupPanel.add(vp); } public void setTitle(CharSequence title) { if (titleLabel == null && title != null && !"".equals(title)) { titleLabel = new Label();
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/DialogInterface.java // public interface DialogInterface { // // public static final int BUTTON_NEGATIVE = -2; // public static final int BUTTON_NEUTRAL = -3; // public static final int BUTTON_POSITIVE = -1; // // public abstract void cancel(); // // public abstract void dismiss(); // // public interface OnClickListener { // public void onClick(DialogInterface dialog, int which); // } // } // Path: androidemu/src/main/java/android/app/ProgressDialog.java import android.Res; import android.content.Context; import android.content.DialogInterface; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.VerticalPanel; package android.app; public class ProgressDialog extends Dialog implements DialogInterface { private SimplePanel titleLabelContainer, messageLabelContainer; private Label titleLabel, messageLabel; public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate) { return new ProgressDialog(title, message, false); } public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { return new ProgressDialog(title, message, cancelable); } public ProgressDialog(CharSequence title, CharSequence message, boolean cancelable) { super(cancelable); VerticalPanel vp = new VerticalPanel(); titleLabelContainer = new SimplePanel(); messageLabelContainer = new SimplePanel(); vp.add(titleLabelContainer); vp.add(messageLabelContainer); setTitle(title); setMessage(message); popupPanel.add(vp); } public void setTitle(CharSequence title) { if (titleLabel == null && title != null && !"".equals(title)) { titleLabel = new Label();
titleLabel.setStyleName(Res.R.style().dialogTitle());
mobialia/gwt-android-emu
androidemu/src/main/java/android/widget/Adapter.java
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // }
import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup;
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * An Adapter object acts as a bridge between an {@link AdapterView} and the * underlying data for that view. The Adapter provides access to the data items. * The Adapter is also responsible for making a {@link android.view.View} for * each item in the data set. * * @see android.widget.ArrayAdapter * @see android.widget.CursorAdapter * @see android.widget.SimpleCursorAdapter */ public interface Adapter { /** * Register an observer that is called when changes happen to the data used * by this adapter. * * @param observer the object that gets notified when the data set changes. */ void registerDataSetObserver(DataSetObserver observer); /** * Unregister an observer that has previously been registered with this * adapter via {@link #registerDataSetObserver}. * * @param observer the object to unregister. */ void unregisterDataSetObserver(DataSetObserver observer); /** * How many items are in the data set represented by this Adapter. * * @return Count of items. */ int getCount(); /** * Get the data item associated with the specified position in the data set. * * @param position Position of the item whose data we want within the adapter's * data set. * @return The data at the specified position. */ Object getItem(int position); /** * Get the row id associated with the specified position in the list. * * @param position The position of the item within the adapter's data set whose * row id we want. * @return The id of the item at the specified position. */ long getItemId(int position); /** * Indicated whether the item ids are stable across changes to the * underlying data. * * @return True if the same id always refers to the same object. */ boolean hasStableIds(); /** * Get a View that displays the data at the specified position in the data * set. You can either create a View manually or inflate it from an XML * layout file. When the View is inflated, the parent View (GridView, * ListView...) will apply default layout parameters unless you use * {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} * to specify a root view and to prevent attachment to the root. * * @param position The position of the item within the adapter's data set of the * item whose view we want. * @param convertView The old view to reuse, if possible. Note: You should check * that this view is non-null and of an appropriate type before * using. If it is not possible to convert this view to display * the correct data, this method can create a new view. * @param parent The parent that this view will eventually be attached to * @return A View corresponding to the data at the specified position. */
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // Path: androidemu/src/main/java/android/widget/Adapter.java import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * An Adapter object acts as a bridge between an {@link AdapterView} and the * underlying data for that view. The Adapter provides access to the data items. * The Adapter is also responsible for making a {@link android.view.View} for * each item in the data set. * * @see android.widget.ArrayAdapter * @see android.widget.CursorAdapter * @see android.widget.SimpleCursorAdapter */ public interface Adapter { /** * Register an observer that is called when changes happen to the data used * by this adapter. * * @param observer the object that gets notified when the data set changes. */ void registerDataSetObserver(DataSetObserver observer); /** * Unregister an observer that has previously been registered with this * adapter via {@link #registerDataSetObserver}. * * @param observer the object to unregister. */ void unregisterDataSetObserver(DataSetObserver observer); /** * How many items are in the data set represented by this Adapter. * * @return Count of items. */ int getCount(); /** * Get the data item associated with the specified position in the data set. * * @param position Position of the item whose data we want within the adapter's * data set. * @return The data at the specified position. */ Object getItem(int position); /** * Get the row id associated with the specified position in the list. * * @param position The position of the item within the adapter's data set whose * row id we want. * @return The id of the item at the specified position. */ long getItemId(int position); /** * Indicated whether the item ids are stable across changes to the * underlying data. * * @return True if the same id always refers to the same object. */ boolean hasStableIds(); /** * Get a View that displays the data at the specified position in the data * set. You can either create a View manually or inflate it from an XML * layout file. When the View is inflated, the parent View (GridView, * ListView...) will apply default layout parameters unless you use * {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} * to specify a root view and to prevent attachment to the root. * * @param position The position of the item within the adapter's data set of the * item whose view we want. * @param convertView The old view to reuse, if possible. Note: You should check * that this view is non-null and of an appropriate type before * using. If it is not possible to convert this view to display * the correct data, this method can create a new view. * @param parent The parent that this view will eventually be attached to * @return A View corresponding to the data at the specified position. */
View getView(int position, View convertView, ViewGroup parent);
mobialia/gwt-android-emu
androidemu/src/main/java/android/app/Dialog.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/DialogInterface.java // public interface DialogInterface { // // public static final int BUTTON_NEGATIVE = -2; // public static final int BUTTON_NEUTRAL = -3; // public static final int BUTTON_POSITIVE = -1; // // public abstract void cancel(); // // public abstract void dismiss(); // // public interface OnClickListener { // public void onClick(DialogInterface dialog, int which); // } // }
import android.Res; import android.content.DialogInterface; import com.google.gwt.user.client.ui.PopupPanel;
package android.app; public class Dialog implements DialogInterface { PopupPanel popupPanel; public Dialog(boolean cancelable) { popupPanel = new PopupPanel(cancelable);
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/DialogInterface.java // public interface DialogInterface { // // public static final int BUTTON_NEGATIVE = -2; // public static final int BUTTON_NEUTRAL = -3; // public static final int BUTTON_POSITIVE = -1; // // public abstract void cancel(); // // public abstract void dismiss(); // // public interface OnClickListener { // public void onClick(DialogInterface dialog, int which); // } // } // Path: androidemu/src/main/java/android/app/Dialog.java import android.Res; import android.content.DialogInterface; import com.google.gwt.user.client.ui.PopupPanel; package android.app; public class Dialog implements DialogInterface { PopupPanel popupPanel; public Dialog(boolean cancelable) { popupPanel = new PopupPanel(cancelable);
popupPanel.setStyleName(Res.R.style().dialog());
mobialia/gwt-android-emu
androidemu/src/main/java/android/app/ListActivity.java
// Path: androidemu/src/main/java/android/widget/ListAdapter.java // public interface ListAdapter extends Adapter { // // /** // * Are all items in this ListAdapter enabled? If yes it means all items are // * selectable and clickable. // * // * @return True if all items are enabled // */ // public boolean areAllItemsEnabled(); // // /** // * Returns true if the item at the specified position is not a separator. (A // * separator is a non-selectable, non-clickable item). // * // * @param position Index of the item // * @return True if the item is not a separator // */ // boolean isEnabled(int position); // } // // Path: androidemu/src/main/java/android/widget/ListView.java // public class ListView extends View { // // Adapter mAdapter; // OnItemClickListener listener; // DataSetObserver mDataSetObserver; // // public ListView(Element element) { // super(element); // // mDataSetObserver = new DataSetObserver() { // @Override // public void onChanged() { // ListView.this.draw(); // } // // @Override // public void onInvalidated() { // ListView.this.draw(); // } // }; // } // // public void setOnItemClickListener(OnItemClickListener listener) { // this.listener = listener; // } // // public void setAdapter(Adapter adapter) { // if (mAdapter != null && mDataSetObserver != null) { // mAdapter.unregisterDataSetObserver(mDataSetObserver); // } // // this.mAdapter = adapter; // mAdapter.registerDataSetObserver(mDataSetObserver); // mDataSetObserver.onInvalidated(); // } // // public Adapter getAdapter() { // return mAdapter; // } // // public void setSelection(int index) { // // TODO // } // // private void draw() { // while (element.getFirstChild() != null) { // element.removeChild(element.getFirstChild()); // } // // for (int i = 0; i < mAdapter.getCount(); i++) { // final View v = mAdapter.getView(i, null, null); // final int index = i; // final long id = mAdapter.getItemId(i); // // Event.setEventListener(v.getElement(), new EventListener() { // @Override // public void onBrowserEvent(Event event) { // if (listener != null) { // listener.onItemClick(null, v, index, id); // } // } // }); // Event.sinkEvents(v.getElement(), Event.ONCLICK); // // element.appendChild(v.getElement()); // } // } // }
import android.widget.ListAdapter; import android.widget.ListView;
package android.app; public class ListActivity extends Activity { ListView listView;
// Path: androidemu/src/main/java/android/widget/ListAdapter.java // public interface ListAdapter extends Adapter { // // /** // * Are all items in this ListAdapter enabled? If yes it means all items are // * selectable and clickable. // * // * @return True if all items are enabled // */ // public boolean areAllItemsEnabled(); // // /** // * Returns true if the item at the specified position is not a separator. (A // * separator is a non-selectable, non-clickable item). // * // * @param position Index of the item // * @return True if the item is not a separator // */ // boolean isEnabled(int position); // } // // Path: androidemu/src/main/java/android/widget/ListView.java // public class ListView extends View { // // Adapter mAdapter; // OnItemClickListener listener; // DataSetObserver mDataSetObserver; // // public ListView(Element element) { // super(element); // // mDataSetObserver = new DataSetObserver() { // @Override // public void onChanged() { // ListView.this.draw(); // } // // @Override // public void onInvalidated() { // ListView.this.draw(); // } // }; // } // // public void setOnItemClickListener(OnItemClickListener listener) { // this.listener = listener; // } // // public void setAdapter(Adapter adapter) { // if (mAdapter != null && mDataSetObserver != null) { // mAdapter.unregisterDataSetObserver(mDataSetObserver); // } // // this.mAdapter = adapter; // mAdapter.registerDataSetObserver(mDataSetObserver); // mDataSetObserver.onInvalidated(); // } // // public Adapter getAdapter() { // return mAdapter; // } // // public void setSelection(int index) { // // TODO // } // // private void draw() { // while (element.getFirstChild() != null) { // element.removeChild(element.getFirstChild()); // } // // for (int i = 0; i < mAdapter.getCount(); i++) { // final View v = mAdapter.getView(i, null, null); // final int index = i; // final long id = mAdapter.getItemId(i); // // Event.setEventListener(v.getElement(), new EventListener() { // @Override // public void onBrowserEvent(Event event) { // if (listener != null) { // listener.onItemClick(null, v, index, id); // } // } // }); // Event.sinkEvents(v.getElement(), Event.ONCLICK); // // element.appendChild(v.getElement()); // } // } // } // Path: androidemu/src/main/java/android/app/ListActivity.java import android.widget.ListAdapter; import android.widget.ListView; package android.app; public class ListActivity extends Activity { ListView listView;
ListAdapter adapter;
mobialia/gwt-android-emu
demo/src/main/java/android/demo/NotificationsFragment.java
// Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/Toast.java // public class Toast { // // public final static int LENGTH_LONG = 1; // public final static int LENGTH_SHORT = 0; // // String message; // int gravity = Gravity.BOTTOM; // int duration; // // public static Toast makeText(Context context, int message, int duration) { // return makeText(context, Context.resources.getString(message), duration); // } // // public static Toast makeText(Context context, String message, int duration) { // Toast toast = new Toast(); // toast.setMessage(message); // toast.setDuration(duration); // return toast; // } // // public void show() { // final PopupPanel panel = new PopupPanel(); // panel.setStyleName(Res.R.style().toast()); // // HTML label = new HTML(message.replace("\n", "<br/>")); // panel.setWidget(label); // panel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { // public void setPosition(int offsetWidth, int offsetHeight) { // int left = (Window.getClientWidth() - offsetWidth) / 2; // int top = 0; // switch (gravity) { // case Gravity.TOP: // top = (Window.getClientHeight() - offsetHeight) / 10; // break; // case Gravity.CENTER: // top = (Window.getClientHeight() - offsetHeight) / 2; // break; // case Gravity.BOTTOM: // top = 9 * (Window.getClientHeight() - offsetHeight) / 10; // break; // } // panel.setPopupPosition(left, top); // } // }); // // // Create a new timer that calls hide(). // Timer t = new Timer() { // public void run() { // panel.hide(); // } // }; // // if (duration == LENGTH_SHORT) { // t.schedule(2500); // } else { // t.schedule(4000); // } // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getDuration() { // return duration; // } // // public void setDuration(int duration) { // this.duration = duration; // } // // public void setGravity(int gravity) { // this.gravity = gravity; // } // // public int getGravity() { // return gravity; // } // // public void setGravity(int gravity, int xOffset, int yOffset) { // this.gravity = gravity; // } // }
import android.app.AlertDialog; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast;
package android.demo; public class NotificationsFragment extends Fragment { static final String TAG = NotificationsFragment.class.getSimpleName(); View view; @Override
// Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/Toast.java // public class Toast { // // public final static int LENGTH_LONG = 1; // public final static int LENGTH_SHORT = 0; // // String message; // int gravity = Gravity.BOTTOM; // int duration; // // public static Toast makeText(Context context, int message, int duration) { // return makeText(context, Context.resources.getString(message), duration); // } // // public static Toast makeText(Context context, String message, int duration) { // Toast toast = new Toast(); // toast.setMessage(message); // toast.setDuration(duration); // return toast; // } // // public void show() { // final PopupPanel panel = new PopupPanel(); // panel.setStyleName(Res.R.style().toast()); // // HTML label = new HTML(message.replace("\n", "<br/>")); // panel.setWidget(label); // panel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { // public void setPosition(int offsetWidth, int offsetHeight) { // int left = (Window.getClientWidth() - offsetWidth) / 2; // int top = 0; // switch (gravity) { // case Gravity.TOP: // top = (Window.getClientHeight() - offsetHeight) / 10; // break; // case Gravity.CENTER: // top = (Window.getClientHeight() - offsetHeight) / 2; // break; // case Gravity.BOTTOM: // top = 9 * (Window.getClientHeight() - offsetHeight) / 10; // break; // } // panel.setPopupPosition(left, top); // } // }); // // // Create a new timer that calls hide(). // Timer t = new Timer() { // public void run() { // panel.hide(); // } // }; // // if (duration == LENGTH_SHORT) { // t.schedule(2500); // } else { // t.schedule(4000); // } // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getDuration() { // return duration; // } // // public void setDuration(int duration) { // this.duration = duration; // } // // public void setGravity(int gravity) { // this.gravity = gravity; // } // // public int getGravity() { // return gravity; // } // // public void setGravity(int gravity, int xOffset, int yOffset) { // this.gravity = gravity; // } // } // Path: demo/src/main/java/android/demo/NotificationsFragment.java import android.app.AlertDialog; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; package android.demo; public class NotificationsFragment extends Fragment { static final String TAG = NotificationsFragment.class.getSimpleName(); View view; @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
mobialia/gwt-android-emu
demo/src/main/java/android/demo/NotificationsFragment.java
// Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/Toast.java // public class Toast { // // public final static int LENGTH_LONG = 1; // public final static int LENGTH_SHORT = 0; // // String message; // int gravity = Gravity.BOTTOM; // int duration; // // public static Toast makeText(Context context, int message, int duration) { // return makeText(context, Context.resources.getString(message), duration); // } // // public static Toast makeText(Context context, String message, int duration) { // Toast toast = new Toast(); // toast.setMessage(message); // toast.setDuration(duration); // return toast; // } // // public void show() { // final PopupPanel panel = new PopupPanel(); // panel.setStyleName(Res.R.style().toast()); // // HTML label = new HTML(message.replace("\n", "<br/>")); // panel.setWidget(label); // panel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { // public void setPosition(int offsetWidth, int offsetHeight) { // int left = (Window.getClientWidth() - offsetWidth) / 2; // int top = 0; // switch (gravity) { // case Gravity.TOP: // top = (Window.getClientHeight() - offsetHeight) / 10; // break; // case Gravity.CENTER: // top = (Window.getClientHeight() - offsetHeight) / 2; // break; // case Gravity.BOTTOM: // top = 9 * (Window.getClientHeight() - offsetHeight) / 10; // break; // } // panel.setPopupPosition(left, top); // } // }); // // // Create a new timer that calls hide(). // Timer t = new Timer() { // public void run() { // panel.hide(); // } // }; // // if (duration == LENGTH_SHORT) { // t.schedule(2500); // } else { // t.schedule(4000); // } // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getDuration() { // return duration; // } // // public void setDuration(int duration) { // this.duration = duration; // } // // public void setGravity(int gravity) { // this.gravity = gravity; // } // // public int getGravity() { // return gravity; // } // // public void setGravity(int gravity, int xOffset, int yOffset) { // this.gravity = gravity; // } // }
import android.app.AlertDialog; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast;
package android.demo; public class NotificationsFragment extends Fragment { static final String TAG = NotificationsFragment.class.getSimpleName(); View view; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } view = inflater.inflate(R.layout.notifications_fragment, container, false); view.findViewById(R.id.AlertButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // AlertDialog usage sample AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.dialog_title); builder.setMessage(R.string.dialog_message); builder.setPositiveButton(R.string.dialog_yes, null); builder.setNegativeButton(R.string.dialog_no, null); builder.create().show(); } }); view.findViewById(R.id.ToastButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Toast usage sample, gravities and durations work!
// Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/Toast.java // public class Toast { // // public final static int LENGTH_LONG = 1; // public final static int LENGTH_SHORT = 0; // // String message; // int gravity = Gravity.BOTTOM; // int duration; // // public static Toast makeText(Context context, int message, int duration) { // return makeText(context, Context.resources.getString(message), duration); // } // // public static Toast makeText(Context context, String message, int duration) { // Toast toast = new Toast(); // toast.setMessage(message); // toast.setDuration(duration); // return toast; // } // // public void show() { // final PopupPanel panel = new PopupPanel(); // panel.setStyleName(Res.R.style().toast()); // // HTML label = new HTML(message.replace("\n", "<br/>")); // panel.setWidget(label); // panel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { // public void setPosition(int offsetWidth, int offsetHeight) { // int left = (Window.getClientWidth() - offsetWidth) / 2; // int top = 0; // switch (gravity) { // case Gravity.TOP: // top = (Window.getClientHeight() - offsetHeight) / 10; // break; // case Gravity.CENTER: // top = (Window.getClientHeight() - offsetHeight) / 2; // break; // case Gravity.BOTTOM: // top = 9 * (Window.getClientHeight() - offsetHeight) / 10; // break; // } // panel.setPopupPosition(left, top); // } // }); // // // Create a new timer that calls hide(). // Timer t = new Timer() { // public void run() { // panel.hide(); // } // }; // // if (duration == LENGTH_SHORT) { // t.schedule(2500); // } else { // t.schedule(4000); // } // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getDuration() { // return duration; // } // // public void setDuration(int duration) { // this.duration = duration; // } // // public void setGravity(int gravity) { // this.gravity = gravity; // } // // public int getGravity() { // return gravity; // } // // public void setGravity(int gravity, int xOffset, int yOffset) { // this.gravity = gravity; // } // } // Path: demo/src/main/java/android/demo/NotificationsFragment.java import android.app.AlertDialog; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; package android.demo; public class NotificationsFragment extends Fragment { static final String TAG = NotificationsFragment.class.getSimpleName(); View view; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; } view = inflater.inflate(R.layout.notifications_fragment, container, false); view.findViewById(R.id.AlertButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // AlertDialog usage sample AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.dialog_title); builder.setMessage(R.string.dialog_message); builder.setPositiveButton(R.string.dialog_yes, null); builder.setNegativeButton(R.string.dialog_no, null); builder.create().show(); } }); view.findViewById(R.id.ToastButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Toast usage sample, gravities and durations work!
Toast toast = Toast.makeText(getActivity(), R.string.toast_text, Toast.LENGTH_SHORT);
mobialia/gwt-android-emu
androidemu/src/main/java/android/widget/Toast.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // }
import android.Res; import android.content.Context; import android.view.Gravity; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.PopupPanel;
package android.widget; public class Toast { public final static int LENGTH_LONG = 1; public final static int LENGTH_SHORT = 0; String message; int gravity = Gravity.BOTTOM; int duration; public static Toast makeText(Context context, int message, int duration) { return makeText(context, Context.resources.getString(message), duration); } public static Toast makeText(Context context, String message, int duration) { Toast toast = new Toast(); toast.setMessage(message); toast.setDuration(duration); return toast; } public void show() { final PopupPanel panel = new PopupPanel();
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // Path: androidemu/src/main/java/android/widget/Toast.java import android.Res; import android.content.Context; import android.view.Gravity; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.PopupPanel; package android.widget; public class Toast { public final static int LENGTH_LONG = 1; public final static int LENGTH_SHORT = 0; String message; int gravity = Gravity.BOTTOM; int duration; public static Toast makeText(Context context, int message, int duration) { return makeText(context, Context.resources.getString(message), duration); } public static Toast makeText(Context context, String message, int duration) { Toast toast = new Toast(); toast.setMessage(message); toast.setDuration(duration); return toast; } public void show() { final PopupPanel panel = new PopupPanel();
panel.setStyleName(Res.R.style().toast());
mobialia/gwt-android-emu
androidemu/src/main/java/android/app/Service.java
// Path: androidemu/src/main/java/android/os/IBinder.java // public interface IBinder { // int FIRST_CALL_TRANSACTION = 0x00000001; // int LAST_CALL_TRANSACTION = 0x00ffffff; // int PING_TRANSACTION = ('_' << 24) | ('P' << 16) | ('N' << 8) | 'G'; // int DUMP_TRANSACTION = ('_' << 24) | ('D' << 16) | ('M' << 8) | 'P'; // int INTERFACE_TRANSACTION = ('_' << 24) | ('N' << 16) | ('T' << 8) | 'F'; // int TWEET_TRANSACTION = ('_' << 24) | ('T' << 16) | ('W' << 8) | 'T'; // int LIKE_TRANSACTION = ('_' << 24) | ('L' << 16) | ('I' << 8) | 'K'; // int SYSPROPS_TRANSACTION = ('_' << 24) | ('S' << 16) | ('P' << 8) | 'R'; // int FLAG_ONEWAY = 0x00000001; // // public String getInterfaceDescriptor() throws RemoteException; // // public boolean pingBinder(); // // public boolean isBinderAlive(); // // public IInterface queryLocalInterface(String descriptor); // // public boolean transact(int code, Parcel data, Parcel reply, int flags) // throws RemoteException; // // public interface DeathRecipient { // public void binderDied(); // } // // public void linkToDeath(DeathRecipient recipient, int flags) // throws RemoteException; // // public boolean unlinkToDeath(DeathRecipient recipient, int flags); // }
import android.content.Intent; import android.os.IBinder;
package android.app; public abstract class Service extends ContextWrapper { public static final int START_CONTINUATION_MASK = 0x0000000f; public static final int START_FLAG_REDELIVERY = 0x00000001; public static final int START_FLAG_RETRY = 0x00000002; public static final int START_NOT_STICKY = 0x00000002; public static final int START_REDELIVER_INTENT = 0x00000003; public static final int START_STICKY = 0x00000001; public static final int START_STICKY_COMPATIBILITY = 0x00000000; public int status = ServiceManager.STATUS_NEW;
// Path: androidemu/src/main/java/android/os/IBinder.java // public interface IBinder { // int FIRST_CALL_TRANSACTION = 0x00000001; // int LAST_CALL_TRANSACTION = 0x00ffffff; // int PING_TRANSACTION = ('_' << 24) | ('P' << 16) | ('N' << 8) | 'G'; // int DUMP_TRANSACTION = ('_' << 24) | ('D' << 16) | ('M' << 8) | 'P'; // int INTERFACE_TRANSACTION = ('_' << 24) | ('N' << 16) | ('T' << 8) | 'F'; // int TWEET_TRANSACTION = ('_' << 24) | ('T' << 16) | ('W' << 8) | 'T'; // int LIKE_TRANSACTION = ('_' << 24) | ('L' << 16) | ('I' << 8) | 'K'; // int SYSPROPS_TRANSACTION = ('_' << 24) | ('S' << 16) | ('P' << 8) | 'R'; // int FLAG_ONEWAY = 0x00000001; // // public String getInterfaceDescriptor() throws RemoteException; // // public boolean pingBinder(); // // public boolean isBinderAlive(); // // public IInterface queryLocalInterface(String descriptor); // // public boolean transact(int code, Parcel data, Parcel reply, int flags) // throws RemoteException; // // public interface DeathRecipient { // public void binderDied(); // } // // public void linkToDeath(DeathRecipient recipient, int flags) // throws RemoteException; // // public boolean unlinkToDeath(DeathRecipient recipient, int flags); // } // Path: androidemu/src/main/java/android/app/Service.java import android.content.Intent; import android.os.IBinder; package android.app; public abstract class Service extends ContextWrapper { public static final int START_CONTINUATION_MASK = 0x0000000f; public static final int START_FLAG_REDELIVERY = 0x00000001; public static final int START_FLAG_RETRY = 0x00000002; public static final int START_NOT_STICKY = 0x00000002; public static final int START_REDELIVER_INTENT = 0x00000003; public static final int START_STICKY = 0x00000001; public static final int START_STICKY_COMPATIBILITY = 0x00000000; public int status = ServiceManager.STATUS_NEW;
public abstract IBinder onBind(Intent intent);
mobialia/gwt-android-emu
androidemu/src/main/java/android/preference/PreferencesBuilder.java
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // }
import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener;
package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText);
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // } // Path: androidemu/src/main/java/android/preference/PreferencesBuilder.java import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText);
labelE.addClassName(Res.R.style().dialogTitle());
mobialia/gwt-android-emu
androidemu/src/main/java/android/preference/PreferencesBuilder.java
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // }
import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener;
package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText); labelE.addClassName(Res.R.style().dialogTitle()); panel.appendChild(labelE); }
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // } // Path: androidemu/src/main/java/android/preference/PreferencesBuilder.java import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText); labelE.addClassName(Res.R.style().dialogTitle()); panel.appendChild(labelE); }
public static void addListPreference(Element panel, final SharedPreferences sharedPrefs, final String key, int label, int summary,
mobialia/gwt-android-emu
androidemu/src/main/java/android/preference/PreferencesBuilder.java
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // }
import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener;
package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText); labelE.addClassName(Res.R.style().dialogTitle()); panel.appendChild(labelE); } public static void addListPreference(Element panel, final SharedPreferences sharedPrefs, final String key, int label, int summary, final int values, int labels, String defaultValue) { addListPreference(panel, sharedPrefs, key, Context.resources.getString(label), Context.resources.getString(summary), Context.resources.getStringArray(values), Context.resources.getStringArray(labels), defaultValue); } public static void addListPreference(Element panel, final SharedPreferences sharedPrefs, final String key, String label, String summary, final String[] values, String[] labels, String defaultValue) { String value = sharedPrefs.getString(key, defaultValue); Element inputLabel = DOM.createLabel(); inputLabel.addClassName(Res.R.style().preferencesElement()); final Element listBoxE = DOM.createSelect(); listBoxE.addClassName(Res.R.style().preferencesListBox()); listBoxE.addClassName(Res.R.style().materialSelect());
// Path: androidemu/src/main/java/android/MobialiaUtil.java // public class MobialiaUtil { // // public static int arrayPosition(String array[], String value) { // for (int i = 0; i < array.length; i++) { // if (array[i].equals(value)) { // return i; // } // } // return 0; // } // // public static String ifNullBlank(String in) { // return (in == null ? "" : in); // } // } // // Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/content/SharedPreferences.java // public class SharedPreferences { // // Storage storage; // // public SharedPreferences() { // storage = Storage.getLocalStorageIfSupported(); // } // // public String getString(String key, String defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return out; // } // // public int getInt(String key, int defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Integer.valueOf(out); // } // // public long getLong(String key, long defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Long.valueOf(out); // } // // public boolean getBoolean(String key, boolean defaultValue) { // if (storage == null) { // return defaultValue; // } // String out = storage.getItem(key); // if (out == null) { // return defaultValue; // } // return Boolean.valueOf(out); // } // // public Editor edit() { // return new Editor(this); // } // // public class Editor { // // SharedPreferences prefs; // // public Editor(SharedPreferences prefs) { // this.prefs = prefs; // } // // public void putString(String key, String value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, value); // } // } // // public void putInt(String key, int value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putLong(String key, long value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void putBoolean(String key, boolean value) { // if (prefs.storage != null) { // prefs.storage.setItem(key, String.valueOf(value)); // } // } // // public void commit() { // // } // } // // } // Path: androidemu/src/main/java/android/preference/PreferencesBuilder.java import android.MobialiaUtil; import android.Res; import android.content.Context; import android.content.SharedPreferences; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.InputElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; package android.preference; public class PreferencesBuilder { public static void addGroupLabel(Element panel, int labelText) { addGroupLabel(panel, Context.resources.getString(labelText)); } public static void addGroupLabel(Element panel, String labelText) { Element labelE = DOM.createDiv(); labelE.setInnerHTML(labelText); labelE.addClassName(Res.R.style().dialogTitle()); panel.appendChild(labelE); } public static void addListPreference(Element panel, final SharedPreferences sharedPrefs, final String key, int label, int summary, final int values, int labels, String defaultValue) { addListPreference(panel, sharedPrefs, key, Context.resources.getString(label), Context.resources.getString(summary), Context.resources.getStringArray(values), Context.resources.getStringArray(labels), defaultValue); } public static void addListPreference(Element panel, final SharedPreferences sharedPrefs, final String key, String label, String summary, final String[] values, String[] labels, String defaultValue) { String value = sharedPrefs.getString(key, defaultValue); Element inputLabel = DOM.createLabel(); inputLabel.addClassName(Res.R.style().preferencesElement()); final Element listBoxE = DOM.createSelect(); listBoxE.addClassName(Res.R.style().preferencesListBox()); listBoxE.addClassName(Res.R.style().materialSelect());
int selectedPosition = MobialiaUtil.arrayPosition(values, value);
mobialia/gwt-android-emu
androidemu/src/main/java/android/support/v7/widget/PopupMenu.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // }
import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel;
package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener;
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // } // Path: androidemu/src/main/java/android/support/v7/widget/PopupMenu.java import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel; package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener;
private LinearLayout menuLayout;
mobialia/gwt-android-emu
androidemu/src/main/java/android/support/v7/widget/PopupMenu.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // }
import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel;
package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener; private LinearLayout menuLayout; boolean isShowing = false; public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; }
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // } // Path: androidemu/src/main/java/android/support/v7/widget/PopupMenu.java import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel; package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener; private LinearLayout menuLayout; boolean isShowing = false; public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; }
public MenuInflater getMenuInflater() {
mobialia/gwt-android-emu
androidemu/src/main/java/android/support/v7/widget/PopupMenu.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // }
import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel;
package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener; private LinearLayout menuLayout; boolean isShowing = false; public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; } public MenuInflater getMenuInflater() { return new MenuInflater(); } public void show() { if (menuLayout == null) { menuLayout = new LinearLayout(context);
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // } // Path: androidemu/src/main/java/android/support/v7/widget/PopupMenu.java import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel; package android.support.v7.widget; public class PopupMenu { Context context; View anchor; Menu menu; OnMenuItemClickListener mMenuItemClickListener; private LinearLayout menuLayout; boolean isShowing = false; public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; } public MenuInflater getMenuInflater() { return new MenuInflater(); } public void show() { if (menuLayout == null) { menuLayout = new LinearLayout(context);
menuLayout.getElement().addClassName(Res.R.style().dialog());
mobialia/gwt-android-emu
androidemu/src/main/java/android/support/v7/widget/PopupMenu.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // }
import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel;
public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; } public MenuInflater getMenuInflater() { return new MenuInflater(); } public void show() { if (menuLayout == null) { menuLayout = new LinearLayout(context); menuLayout.getElement().addClassName(Res.R.style().dialog()); menuLayout.getElement().addClassName(Res.R.style().gone()); for (final MenuItem item : menu.menuItems) {
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/MenuInflater.java // public class MenuInflater { // // public void inflate(int menuId, Menu menu) { // Menu toAdd = Context.resources.getMenu(menuId); // for (MenuItem item : toAdd.menuItems) { // menu.add(item); // } // } // } // // Path: androidemu/src/main/java/android/widget/Button.java // public class Button extends View { // // public Button(Context context) { // super(DOM.createButton()); // } // // public Button(Element element) { // super(element); // } // // public void setText(int stringId) { // setText(Context.resources.getString(stringId)); // } // // public void setText(String string) { // element.setInnerHTML(string != null ? string.replace("\n", "<br/>") : ""); // } // } // // Path: androidemu/src/main/java/android/widget/LinearLayout.java // public class LinearLayout extends ViewGroup { // // public LinearLayout(Context context) { // super(DOM.createDiv()); // } // // public LinearLayout(Element element) { // super(element); // } // // } // Path: androidemu/src/main/java/android/support/v7/widget/PopupMenu.java import android.Res; import android.content.Context; import android.view.Gravity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import com.google.gwt.user.client.ui.RootPanel; public PopupMenu(Context context, View anchor) { this(context, anchor, Gravity.NO_GRAVITY); } public PopupMenu(Context context, View anchor, int gravity) { this.context = context; this.anchor = anchor; menu = new Menu(); } public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mMenuItemClickListener = listener; } public Menu getMenu() { return menu; } public MenuInflater getMenuInflater() { return new MenuInflater(); } public void show() { if (menuLayout == null) { menuLayout = new LinearLayout(context); menuLayout.getElement().addClassName(Res.R.style().dialog()); menuLayout.getElement().addClassName(Res.R.style().gone()); for (final MenuItem item : menu.menuItems) {
Button b = new Button(context);
mobialia/gwt-android-emu
androidemu/src/main/java/android/support/v4/widget/DrawerLayout.java
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // }
import android.Res; import android.util.Log; import android.view.View; import android.view.ViewGroup; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener;
public DrawerLayout(Element element) { super(element); for (int i = 0; i < element.getChildCount(); i++) { if (element.getChild(i) instanceof Element) { Element child = (Element) element.getChild(i); if ("DrawerOverLay".equals(child.getId())) { drawerOverlay = new View(child); } else if ("Drawer".equals(child.getId())) { drawer = new View(child); } } } drawerOverlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { closeDrawer(0); } }); closeDrawer(0); } public void setDrawerListener(DrawerLayout.DrawerListener listener) { this.listener = listener; } public boolean isDrawerOpen(View drawer) { return isOpen; } public void openDrawer(int gravity) {
// Path: androidemu/src/main/java/android/Res.java // public interface Res extends ClientBundle { // public static final Res R = GWT.create(Res.class); // // @Source("Style.gss") // public Style style(); // // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // Path: androidemu/src/main/java/android/support/v4/widget/DrawerLayout.java import android.Res; import android.util.Log; import android.view.View; import android.view.ViewGroup; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; public DrawerLayout(Element element) { super(element); for (int i = 0; i < element.getChildCount(); i++) { if (element.getChild(i) instanceof Element) { Element child = (Element) element.getChild(i); if ("DrawerOverLay".equals(child.getId())) { drawerOverlay = new View(child); } else if ("Drawer".equals(child.getId())) { drawer = new View(child); } } } drawerOverlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { closeDrawer(0); } }); closeDrawer(0); } public void setDrawerListener(DrawerLayout.DrawerListener listener) { this.listener = listener; } public boolean isDrawerOpen(View drawer) { return isOpen; } public void openDrawer(int gravity) {
drawerOverlay.getElement().addClassName(Res.R.style().drawerOverlayOpened());
mobialia/gwt-android-emu
androidemu/src/main/java/android/widget/BaseAdapter.java
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // }
import android.database.DataSetObservable; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup;
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * Common base class of common implementation for an {@link Adapter} that can be * used in both {@link ListView} (by implementing the specialized * {@link ListAdapter} interface} and {@link Spinner} (by implementing the * specialized {@link SpinnerAdapter} interface. */ public abstract class BaseAdapter implements ListAdapter, SpinnerAdapter { private final DataSetObservable mDataSetObservable = new DataSetObservable(); public boolean hasStableIds() { return false; }
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // Path: androidemu/src/main/java/android/widget/BaseAdapter.java import android.database.DataSetObservable; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * Common base class of common implementation for an {@link Adapter} that can be * used in both {@link ListView} (by implementing the specialized * {@link ListAdapter} interface} and {@link Spinner} (by implementing the * specialized {@link SpinnerAdapter} interface. */ public abstract class BaseAdapter implements ListAdapter, SpinnerAdapter { private final DataSetObservable mDataSetObservable = new DataSetObservable(); public boolean hasStableIds() { return false; }
public void registerDataSetObserver(DataSetObserver observer) {
mobialia/gwt-android-emu
androidemu/src/main/java/android/widget/BaseAdapter.java
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // }
import android.database.DataSetObservable; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup;
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * Common base class of common implementation for an {@link Adapter} that can be * used in both {@link ListView} (by implementing the specialized * {@link ListAdapter} interface} and {@link Spinner} (by implementing the * specialized {@link SpinnerAdapter} interface. */ public abstract class BaseAdapter implements ListAdapter, SpinnerAdapter { private final DataSetObservable mDataSetObservable = new DataSetObservable(); public boolean hasStableIds() { return false; } public void registerDataSetObserver(DataSetObserver observer) { mDataSetObservable.registerObserver(observer); } public void unregisterDataSetObserver(DataSetObserver observer) { mDataSetObservable.unregisterObserver(observer); } /** * Notifies the attached View that the underlying data has been changed and * it should refresh itself. */ public void notifyDataSetChanged() { mDataSetObservable.notifyChanged(); } public void notifyDataSetInvalidated() { mDataSetObservable.notifyInvalidated(); } public boolean areAllItemsEnabled() { return true; } public boolean isEnabled(int position) { return true; }
// Path: androidemu/src/main/java/android/database/DataSetObserver.java // public abstract class DataSetObserver { // // public void onChanged() { // // Do nothing // } // // public void onInvalidated() { // // Do nothing // } // } // // Path: androidemu/src/main/java/android/view/ViewGroup.java // public class ViewGroup extends View { // // static final String TAG = "ViewGroup"; // // ArrayList<View> childViews = new ArrayList<View>(); // // public ViewGroup(Element element) { // super(element); // } // // public void addView(View v) { // element.appendChild(v.getElement()); // childViews.add(v); // } // // public View getChildAt(int index) { // return childViews.get(index); // } // // public int getChildCount() { // return childViews.size(); // } // // public void removeAllViews() { // element.removeAllChildren(); // } // } // Path: androidemu/src/main/java/android/widget/BaseAdapter.java import android.database.DataSetObservable; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.widget; /** * Common base class of common implementation for an {@link Adapter} that can be * used in both {@link ListView} (by implementing the specialized * {@link ListAdapter} interface} and {@link Spinner} (by implementing the * specialized {@link SpinnerAdapter} interface. */ public abstract class BaseAdapter implements ListAdapter, SpinnerAdapter { private final DataSetObservable mDataSetObservable = new DataSetObservable(); public boolean hasStableIds() { return false; } public void registerDataSetObserver(DataSetObserver observer) { mDataSetObservable.registerObserver(observer); } public void unregisterDataSetObserver(DataSetObserver observer) { mDataSetObservable.unregisterObserver(observer); } /** * Notifies the attached View that the underlying data has been changed and * it should refresh itself. */ public void notifyDataSetChanged() { mDataSetObservable.notifyChanged(); } public void notifyDataSetInvalidated() { mDataSetObservable.notifyInvalidated(); } public boolean areAllItemsEnabled() { return true; } public boolean isEnabled(int position) { return true; }
public View getDropDownView(int position, View convertView, ViewGroup parent) {
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/MediaActionSwitchView.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // /** // * This method converts dp unit to equivalent pixels, depending on device density. // * // * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels // * @return A float value to represent px equivalent to dp depending on device density // */ // public static int convertDpToPixel(int dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; import android.view.View; import androidx.annotation.IntDef; import androidx.appcompat.widget.AppCompatImageButton; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.utils.Utils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;
private int padding = 5; public MediaActionSwitchView(Context context) { this(context, null); } public MediaActionSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public MediaActionSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = DrawableCompat.wrap(photoDrawable); DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp); videoDrawable = DrawableCompat.wrap(videoDrawable); DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); // setBackgroundResource(R.drawable.circle_frame_background); setOnClickListener(new MediaActionClickListener()); setIcons();
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // /** // * This method converts dp unit to equivalent pixels, depending on device density. // * // * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels // * @return A float value to represent px equivalent to dp depending on device density // */ // public static int convertDpToPixel(int dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/MediaActionSwitchView.java import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; import android.view.View; import androidx.annotation.IntDef; import androidx.appcompat.widget.AppCompatImageButton; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.utils.Utils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; private int padding = 5; public MediaActionSwitchView(Context context) { this(context, null); } public MediaActionSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public MediaActionSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = DrawableCompat.wrap(photoDrawable); DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp); videoDrawable = DrawableCompat.wrap(videoDrawable); DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); // setBackgroundResource(R.drawable.circle_frame_background); setOnClickListener(new MediaActionClickListener()); setIcons();
padding = Utils.convertDpToPixel(padding);
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/CameraSwitchView.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // /** // * This method converts dp unit to equivalent pixels, depending on device density. // * // * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels // * @return A float value to represent px equivalent to dp depending on device density // */ // public static int convertDpToPixel(int dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; import androidx.annotation.IntDef; import androidx.appcompat.widget.AppCompatImageButton; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.utils.Utils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;
private @CameraType int currentCameraType = CAMERA_TYPE_REAR; public CameraSwitchView(Context context) { this(context, null); } public CameraSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); setOnClickListener(new CameraTypeClickListener()); setIcons();
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // /** // * This method converts dp unit to equivalent pixels, depending on device density. // * // * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels // * @return A float value to represent px equivalent to dp depending on device density // */ // public static int convertDpToPixel(int dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/CameraSwitchView.java import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; import androidx.annotation.IntDef; import androidx.appcompat.widget.AppCompatImageButton; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.utils.Utils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; private @CameraType int currentCameraType = CAMERA_TYPE_REAR; public CameraSwitchView(Context context) { this(context, null); } public CameraSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); setOnClickListener(new CameraTypeClickListener()); setIcons();
padding = Utils.convertDpToPixel(padding);
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/CameraHelper.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // }
import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraManager; import android.media.CamcorderProfile; import android.os.Build; import android.text.TextUtils; import android.util.Log; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale;
public static boolean hasCamera2(Context context) { if (context == null) return false; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return false; try { CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); String[] idList = manager.getCameraIdList(); boolean notNull = true; if (idList.length == 0) { notNull = false; } else { for (final String str : idList) { if (str == null || str.trim().isEmpty()) { notNull = false; break; } final CameraCharacteristics characteristics = manager.getCameraCharacteristics(str); final int supportLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL); if (supportLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) { notNull = false; break; } } } return notNull; } catch (Throwable ignore) { return false; } }
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/utils/CameraHelper.java import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraManager; import android.media.CamcorderProfile; import android.os.Build; import android.text.TextUtils; import android.util.Log; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale; public static boolean hasCamera2(Context context) { if (context == null) return false; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return false; try { CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); String[] idList = manager.getCameraIdList(); boolean notNull = true; if (idList.length == 0) { notNull = false; } else { for (final String str : idList) { if (str == null || str.trim().isEmpty()) { notNull = false; break; } final CameraCharacteristics characteristics = manager.getCameraCharacteristics(str); final int supportLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL); if (supportLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) { notNull = false; break; } } } return notNull; } catch (Throwable ignore) { return false; } }
public static File getOutputMediaFile(Context context, @CameraConfiguration.MediaAction int mediaAction) {
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/controller/CameraController.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/manager/CameraManager.java // public interface CameraManager<CameraId, SurfaceListener> { // // void initializeCameraManager(ConfigurationProvider configurationProvider, Context context); // // void openCamera(CameraId cameraId, CameraOpenListener<CameraId, SurfaceListener> cameraOpenListener); // // void closeCamera(CameraCloseListener<CameraId> cameraCloseListener); // // void takePhoto(File photoFile, CameraPhotoListener cameraPhotoListener); // // void startVideoRecord(File videoFile, CameraVideoListener cameraVideoListener); // // Size getPhotoSizeForQuality(@CameraConfiguration.MediaQuality int mediaQuality); // // void setFlashMode(@CameraConfiguration.FlashMode int flashMode); // // void stopVideoRecord(); // // void releaseCameraManager(); // // CameraId getCurrentCameraId(); // // CameraId getFaceFrontCameraId(); // // CameraId getFaceBackCameraId(); // // int getNumberOfCameras(); // // int getFaceFrontCameraOrientation(); // // int getFaceBackCameraOrientation(); // // boolean isVideoRecording(); // }
import android.os.Bundle; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import com.sandrios.sandriosCamera.internal.manager.CameraManager; import java.io.File;
package com.sandrios.sandriosCamera.internal.controller; /** * Created by Arpit Gandhi on 7/6/16. */ public interface CameraController<CameraId> { void onCreate(Bundle savedInstanceState); void onResume(); void onPause(); void onDestroy(); void takePhoto(); void startVideoRecord(); void stopVideoRecord(); boolean isVideoRecording();
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/manager/CameraManager.java // public interface CameraManager<CameraId, SurfaceListener> { // // void initializeCameraManager(ConfigurationProvider configurationProvider, Context context); // // void openCamera(CameraId cameraId, CameraOpenListener<CameraId, SurfaceListener> cameraOpenListener); // // void closeCamera(CameraCloseListener<CameraId> cameraCloseListener); // // void takePhoto(File photoFile, CameraPhotoListener cameraPhotoListener); // // void startVideoRecord(File videoFile, CameraVideoListener cameraVideoListener); // // Size getPhotoSizeForQuality(@CameraConfiguration.MediaQuality int mediaQuality); // // void setFlashMode(@CameraConfiguration.FlashMode int flashMode); // // void stopVideoRecord(); // // void releaseCameraManager(); // // CameraId getCurrentCameraId(); // // CameraId getFaceFrontCameraId(); // // CameraId getFaceBackCameraId(); // // int getNumberOfCameras(); // // int getFaceFrontCameraOrientation(); // // int getFaceBackCameraOrientation(); // // boolean isVideoRecording(); // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/controller/CameraController.java import android.os.Bundle; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import com.sandrios.sandriosCamera.internal.manager.CameraManager; import java.io.File; package com.sandrios.sandriosCamera.internal.controller; /** * Created by Arpit Gandhi on 7/6/16. */ public interface CameraController<CameraId> { void onCreate(Bundle savedInstanceState); void onResume(); void onPause(); void onDestroy(); void takePhoto(); void startVideoRecord(); void stopVideoRecord(); boolean isVideoRecording();
void switchCamera(@CameraConfiguration.CameraFace int cameraFace);
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/controller/CameraController.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/manager/CameraManager.java // public interface CameraManager<CameraId, SurfaceListener> { // // void initializeCameraManager(ConfigurationProvider configurationProvider, Context context); // // void openCamera(CameraId cameraId, CameraOpenListener<CameraId, SurfaceListener> cameraOpenListener); // // void closeCamera(CameraCloseListener<CameraId> cameraCloseListener); // // void takePhoto(File photoFile, CameraPhotoListener cameraPhotoListener); // // void startVideoRecord(File videoFile, CameraVideoListener cameraVideoListener); // // Size getPhotoSizeForQuality(@CameraConfiguration.MediaQuality int mediaQuality); // // void setFlashMode(@CameraConfiguration.FlashMode int flashMode); // // void stopVideoRecord(); // // void releaseCameraManager(); // // CameraId getCurrentCameraId(); // // CameraId getFaceFrontCameraId(); // // CameraId getFaceBackCameraId(); // // int getNumberOfCameras(); // // int getFaceFrontCameraOrientation(); // // int getFaceBackCameraOrientation(); // // boolean isVideoRecording(); // }
import android.os.Bundle; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import com.sandrios.sandriosCamera.internal.manager.CameraManager; import java.io.File;
package com.sandrios.sandriosCamera.internal.controller; /** * Created by Arpit Gandhi on 7/6/16. */ public interface CameraController<CameraId> { void onCreate(Bundle savedInstanceState); void onResume(); void onPause(); void onDestroy(); void takePhoto(); void startVideoRecord(); void stopVideoRecord(); boolean isVideoRecording(); void switchCamera(@CameraConfiguration.CameraFace int cameraFace); void switchQuality(); int getNumberOfCameras(); @CameraConfiguration.MediaAction int getMediaAction(); CameraId getCurrentCameraId(); File getOutputFile();
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/manager/CameraManager.java // public interface CameraManager<CameraId, SurfaceListener> { // // void initializeCameraManager(ConfigurationProvider configurationProvider, Context context); // // void openCamera(CameraId cameraId, CameraOpenListener<CameraId, SurfaceListener> cameraOpenListener); // // void closeCamera(CameraCloseListener<CameraId> cameraCloseListener); // // void takePhoto(File photoFile, CameraPhotoListener cameraPhotoListener); // // void startVideoRecord(File videoFile, CameraVideoListener cameraVideoListener); // // Size getPhotoSizeForQuality(@CameraConfiguration.MediaQuality int mediaQuality); // // void setFlashMode(@CameraConfiguration.FlashMode int flashMode); // // void stopVideoRecord(); // // void releaseCameraManager(); // // CameraId getCurrentCameraId(); // // CameraId getFaceFrontCameraId(); // // CameraId getFaceBackCameraId(); // // int getNumberOfCameras(); // // int getFaceFrontCameraOrientation(); // // int getFaceBackCameraOrientation(); // // boolean isVideoRecording(); // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/controller/CameraController.java import android.os.Bundle; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import com.sandrios.sandriosCamera.internal.manager.CameraManager; import java.io.File; package com.sandrios.sandriosCamera.internal.controller; /** * Created by Arpit Gandhi on 7/6/16. */ public interface CameraController<CameraId> { void onCreate(Bundle savedInstanceState); void onResume(); void onPause(); void onDestroy(); void takePhoto(); void startVideoRecord(); void stopVideoRecord(); boolean isVideoRecording(); void switchCamera(@CameraConfiguration.CameraFace int cameraFace); void switchQuality(); int getNumberOfCameras(); @CameraConfiguration.MediaAction int getMediaAction(); CameraId getCurrentCameraId(); File getOutputFile();
CameraManager getCameraManager();
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/VideoQualityOption.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // }
import android.media.CamcorderProfile; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import java.util.concurrent.TimeUnit;
package com.sandrios.sandriosCamera.internal.ui.model; /** * Created by Arpit Gandhi on 12/1/16. */ public class VideoQualityOption implements CharSequence { private String title;
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/configuration/CameraConfiguration.java // public final class CameraConfiguration { // // public static final int MEDIA_QUALITY_AUTO = 10; // public static final int MEDIA_QUALITY_LOWEST = 15; // public static final int MEDIA_QUALITY_LOW = 11; // public static final int MEDIA_QUALITY_MEDIUM = 12; // public static final int MEDIA_QUALITY_HIGH = 13; // public static final int MEDIA_QUALITY_HIGHEST = 14; // // public static final int MEDIA_ACTION_VIDEO = 100; // public static final int MEDIA_ACTION_PHOTO = 101; // public static final int MEDIA_ACTION_BOTH = 102; // // public static final int CAMERA_FACE_FRONT = 0x6; // public static final int CAMERA_FACE_REAR = 0x7; // // public static final int SENSOR_POSITION_UP = 90; // public static final int SENSOR_POSITION_LEFT = 0; // public static final int SENSOR_POSITION_RIGHT = 180; // public static final int SENSOR_POSITION_UNSPECIFIED = -1; // public static final int ORIENTATION_PORTRAIT = 0x111; // public static final int ORIENTATION_LANDSCAPE = 0x222; // public static final int FLASH_MODE_ON = 1; // public static final int FLASH_MODE_OFF = 2; // public static final int FLASH_MODE_AUTO = 3; // static final int DISPLAY_ROTATION_0 = 0; // static final int DISPLAY_ROTATION_90 = 90; // static final int DISPLAY_ROTATION_180 = 180; // static final int DISPLAY_ROTATION_270 = 270; // // public interface Arguments { // String MEDIA_ACTION = "com.sandrios.sandriosCamera.media_action"; // String MEDIA_QUALITY = "com.sandrios.sandriosCamera.camera_media_quality"; // String VIDEO_DURATION = "com.sandrios.sandriosCamera.video_duration"; // String MINIMUM_VIDEO_DURATION = "com.sandrios.sandriosCamera.minimum.video_duration"; // String VIDEO_FILE_SIZE = "com.sandrios.sandriosCamera.camera_video_file_size"; // String FLASH_MODE = "com.sandrios.sandriosCamera.camera_flash_mode"; // String SHOW_PICKER = "com.sandrios.sandriosCamera.show_picker"; // String ENABLE_CROP = "com.sandrios.sandriosCamera.enable_crop"; // String AUTO_RECORD = "com.sandrios.sandriosCamera.auto_record"; // } // // @IntDef({MEDIA_QUALITY_AUTO, MEDIA_QUALITY_LOWEST, MEDIA_QUALITY_LOW, MEDIA_QUALITY_MEDIUM, MEDIA_QUALITY_HIGH, MEDIA_QUALITY_HIGHEST}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaQuality { // } // // @IntDef({MEDIA_ACTION_VIDEO, MEDIA_ACTION_PHOTO, MEDIA_ACTION_BOTH}) // @Retention(RetentionPolicy.SOURCE) // public @interface MediaAction { // } // // @IntDef({CAMERA_FACE_FRONT, CAMERA_FACE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraFace { // } // // @IntDef({SENSOR_POSITION_UP, SENSOR_POSITION_LEFT, SENSOR_POSITION_RIGHT, SENSOR_POSITION_UNSPECIFIED}) // @Retention(RetentionPolicy.SOURCE) // public @interface SensorPosition { // } // // @IntDef({DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270}) // @Retention(RetentionPolicy.SOURCE) // public @interface DisplayRotation { // } // // @IntDef({ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE}) // @Retention(RetentionPolicy.SOURCE) // public @interface DeviceDefaultOrientation { // } // // @IntDef({FLASH_MODE_ON, FLASH_MODE_OFF, FLASH_MODE_AUTO}) // @Retention(RetentionPolicy.SOURCE) // public @interface FlashMode { // } // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/VideoQualityOption.java import android.media.CamcorderProfile; import com.sandrios.sandriosCamera.internal.configuration.CameraConfiguration; import java.util.concurrent.TimeUnit; package com.sandrios.sandriosCamera.internal.ui.model; /** * Created by Arpit Gandhi on 12/1/16. */ public class VideoQualityOption implements CharSequence { private String title;
@CameraConfiguration.MediaQuality
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/GalleryAdapter.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/SandriosCamera.java // public class SandriosCamera { // // public static int RESULT_CODE = 956; // public static String MEDIA = "media"; // private static SandriosCamera mInstance = null; // private int mediaAction = CameraConfiguration.MEDIA_ACTION_BOTH; // private boolean showPicker = true; // private boolean autoRecord = false; // private boolean enableImageCrop = false; // private long videoSize = -1; // // public static SandriosCamera with() { // if (mInstance == null) { // mInstance = new SandriosCamera(); // } // return mInstance; // } // // public SandriosCamera setShowPicker(boolean showPicker) { // this.showPicker = showPicker; // return mInstance; // } // // public SandriosCamera setMediaAction(int mediaAction) { // this.mediaAction = mediaAction; // return mInstance; // } // // public SandriosCamera enableImageCropping(boolean enableImageCrop) { // this.enableImageCrop = enableImageCrop; // return mInstance; // } // // @SuppressWarnings("SameParameterValue") // public SandriosCamera setVideoFileSize(int fileSize) { // this.videoSize = fileSize; // return mInstance; // } // // /** // * Only works if Media Action is set to Video // */ // public SandriosCamera setAutoRecord() { // autoRecord = true; // return mInstance; // } // // public void launchCamera(Activity activity) { // if (CameraHelper.hasCamera(activity)) { // Intent cameraIntent; // if (CameraHelper.hasCamera2(activity)) { // cameraIntent = new Intent(activity, Camera2Activity.class); // } else { // cameraIntent = new Intent(activity, Camera1Activity.class); // } // cameraIntent.putExtra(CameraConfiguration.Arguments.SHOW_PICKER, showPicker); // cameraIntent.putExtra(CameraConfiguration.Arguments.MEDIA_ACTION, mediaAction); // cameraIntent.putExtra(CameraConfiguration.Arguments.ENABLE_CROP, enableImageCrop); // cameraIntent.putExtra(CameraConfiguration.Arguments.AUTO_RECORD, autoRecord); // // if (videoSize > 0) { // cameraIntent.putExtra(CameraConfiguration.Arguments.VIDEO_FILE_SIZE, videoSize * 1024 * 1024); // } // activity.startActivityForResult(cameraIntent, RESULT_CODE); // } // } // // public class MediaType { // public static final int PHOTO = 0; // public static final int VIDEO = 1; // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/Media.java // public class Media implements Serializable { // private int type; // private String path; // // public Media(int type, String path) { // this.type = type; // this.path = path; // } // // public Media() { // } // // public String getPath() { // return path; // } // // public void setPath(String path) { // this.path = path; // } // // /** // * User media type @link{MediaType} // * // * @return // */ // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // }
import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.SandriosCamera; import com.sandrios.sandriosCamera.internal.ui.model.Media; import java.util.List;
package com.sandrios.sandriosCamera.internal.ui.view; /** * Created by Arpit Gandhi */ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.GalleryViewHolder> { final static int SMALL = 0; final static int LARGE = 1;
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/SandriosCamera.java // public class SandriosCamera { // // public static int RESULT_CODE = 956; // public static String MEDIA = "media"; // private static SandriosCamera mInstance = null; // private int mediaAction = CameraConfiguration.MEDIA_ACTION_BOTH; // private boolean showPicker = true; // private boolean autoRecord = false; // private boolean enableImageCrop = false; // private long videoSize = -1; // // public static SandriosCamera with() { // if (mInstance == null) { // mInstance = new SandriosCamera(); // } // return mInstance; // } // // public SandriosCamera setShowPicker(boolean showPicker) { // this.showPicker = showPicker; // return mInstance; // } // // public SandriosCamera setMediaAction(int mediaAction) { // this.mediaAction = mediaAction; // return mInstance; // } // // public SandriosCamera enableImageCropping(boolean enableImageCrop) { // this.enableImageCrop = enableImageCrop; // return mInstance; // } // // @SuppressWarnings("SameParameterValue") // public SandriosCamera setVideoFileSize(int fileSize) { // this.videoSize = fileSize; // return mInstance; // } // // /** // * Only works if Media Action is set to Video // */ // public SandriosCamera setAutoRecord() { // autoRecord = true; // return mInstance; // } // // public void launchCamera(Activity activity) { // if (CameraHelper.hasCamera(activity)) { // Intent cameraIntent; // if (CameraHelper.hasCamera2(activity)) { // cameraIntent = new Intent(activity, Camera2Activity.class); // } else { // cameraIntent = new Intent(activity, Camera1Activity.class); // } // cameraIntent.putExtra(CameraConfiguration.Arguments.SHOW_PICKER, showPicker); // cameraIntent.putExtra(CameraConfiguration.Arguments.MEDIA_ACTION, mediaAction); // cameraIntent.putExtra(CameraConfiguration.Arguments.ENABLE_CROP, enableImageCrop); // cameraIntent.putExtra(CameraConfiguration.Arguments.AUTO_RECORD, autoRecord); // // if (videoSize > 0) { // cameraIntent.putExtra(CameraConfiguration.Arguments.VIDEO_FILE_SIZE, videoSize * 1024 * 1024); // } // activity.startActivityForResult(cameraIntent, RESULT_CODE); // } // } // // public class MediaType { // public static final int PHOTO = 0; // public static final int VIDEO = 1; // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/Media.java // public class Media implements Serializable { // private int type; // private String path; // // public Media(int type, String path) { // this.type = type; // this.path = path; // } // // public Media() { // } // // public String getPath() { // return path; // } // // public void setPath(String path) { // this.path = path; // } // // /** // * User media type @link{MediaType} // * // * @return // */ // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/GalleryAdapter.java import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.SandriosCamera; import com.sandrios.sandriosCamera.internal.ui.model.Media; import java.util.List; package com.sandrios.sandriosCamera.internal.ui.view; /** * Created by Arpit Gandhi */ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.GalleryViewHolder> { final static int SMALL = 0; final static int LARGE = 1;
private List<Media> pickerTiles;
sandrios/sandriosCamera
sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/GalleryAdapter.java
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/SandriosCamera.java // public class SandriosCamera { // // public static int RESULT_CODE = 956; // public static String MEDIA = "media"; // private static SandriosCamera mInstance = null; // private int mediaAction = CameraConfiguration.MEDIA_ACTION_BOTH; // private boolean showPicker = true; // private boolean autoRecord = false; // private boolean enableImageCrop = false; // private long videoSize = -1; // // public static SandriosCamera with() { // if (mInstance == null) { // mInstance = new SandriosCamera(); // } // return mInstance; // } // // public SandriosCamera setShowPicker(boolean showPicker) { // this.showPicker = showPicker; // return mInstance; // } // // public SandriosCamera setMediaAction(int mediaAction) { // this.mediaAction = mediaAction; // return mInstance; // } // // public SandriosCamera enableImageCropping(boolean enableImageCrop) { // this.enableImageCrop = enableImageCrop; // return mInstance; // } // // @SuppressWarnings("SameParameterValue") // public SandriosCamera setVideoFileSize(int fileSize) { // this.videoSize = fileSize; // return mInstance; // } // // /** // * Only works if Media Action is set to Video // */ // public SandriosCamera setAutoRecord() { // autoRecord = true; // return mInstance; // } // // public void launchCamera(Activity activity) { // if (CameraHelper.hasCamera(activity)) { // Intent cameraIntent; // if (CameraHelper.hasCamera2(activity)) { // cameraIntent = new Intent(activity, Camera2Activity.class); // } else { // cameraIntent = new Intent(activity, Camera1Activity.class); // } // cameraIntent.putExtra(CameraConfiguration.Arguments.SHOW_PICKER, showPicker); // cameraIntent.putExtra(CameraConfiguration.Arguments.MEDIA_ACTION, mediaAction); // cameraIntent.putExtra(CameraConfiguration.Arguments.ENABLE_CROP, enableImageCrop); // cameraIntent.putExtra(CameraConfiguration.Arguments.AUTO_RECORD, autoRecord); // // if (videoSize > 0) { // cameraIntent.putExtra(CameraConfiguration.Arguments.VIDEO_FILE_SIZE, videoSize * 1024 * 1024); // } // activity.startActivityForResult(cameraIntent, RESULT_CODE); // } // } // // public class MediaType { // public static final int PHOTO = 0; // public static final int VIDEO = 1; // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/Media.java // public class Media implements Serializable { // private int type; // private String path; // // public Media(int type, String path) { // this.type = type; // this.path = path; // } // // public Media() { // } // // public String getPath() { // return path; // } // // public void setPath(String path) { // this.path = path; // } // // /** // * User media type @link{MediaType} // * // * @return // */ // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // }
import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.SandriosCamera; import com.sandrios.sandriosCamera.internal.ui.model.Media; import java.util.List;
package com.sandrios.sandriosCamera.internal.ui.view; /** * Created by Arpit Gandhi */ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.GalleryViewHolder> { final static int SMALL = 0; final static int LARGE = 1; private List<Media> pickerTiles; private Context context; private int type; GalleryAdapter(Context context, int type, List<Media> pickerTiles) { this.context = context; this.type = type; this.pickerTiles = pickerTiles; } @NonNull @Override public GalleryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view; if (type == SMALL) { view = LayoutInflater.from(context).inflate(R.layout.gallery_item_small, parent, false); } else { view = LayoutInflater.from(context).inflate(R.layout.gallery_item_large, parent, false); } return new GalleryViewHolder(view); } @Override public void onBindViewHolder(@NonNull final GalleryViewHolder holder, @SuppressLint("RecyclerView") final int position) { Media media = pickerTiles.get(position);
// Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/SandriosCamera.java // public class SandriosCamera { // // public static int RESULT_CODE = 956; // public static String MEDIA = "media"; // private static SandriosCamera mInstance = null; // private int mediaAction = CameraConfiguration.MEDIA_ACTION_BOTH; // private boolean showPicker = true; // private boolean autoRecord = false; // private boolean enableImageCrop = false; // private long videoSize = -1; // // public static SandriosCamera with() { // if (mInstance == null) { // mInstance = new SandriosCamera(); // } // return mInstance; // } // // public SandriosCamera setShowPicker(boolean showPicker) { // this.showPicker = showPicker; // return mInstance; // } // // public SandriosCamera setMediaAction(int mediaAction) { // this.mediaAction = mediaAction; // return mInstance; // } // // public SandriosCamera enableImageCropping(boolean enableImageCrop) { // this.enableImageCrop = enableImageCrop; // return mInstance; // } // // @SuppressWarnings("SameParameterValue") // public SandriosCamera setVideoFileSize(int fileSize) { // this.videoSize = fileSize; // return mInstance; // } // // /** // * Only works if Media Action is set to Video // */ // public SandriosCamera setAutoRecord() { // autoRecord = true; // return mInstance; // } // // public void launchCamera(Activity activity) { // if (CameraHelper.hasCamera(activity)) { // Intent cameraIntent; // if (CameraHelper.hasCamera2(activity)) { // cameraIntent = new Intent(activity, Camera2Activity.class); // } else { // cameraIntent = new Intent(activity, Camera1Activity.class); // } // cameraIntent.putExtra(CameraConfiguration.Arguments.SHOW_PICKER, showPicker); // cameraIntent.putExtra(CameraConfiguration.Arguments.MEDIA_ACTION, mediaAction); // cameraIntent.putExtra(CameraConfiguration.Arguments.ENABLE_CROP, enableImageCrop); // cameraIntent.putExtra(CameraConfiguration.Arguments.AUTO_RECORD, autoRecord); // // if (videoSize > 0) { // cameraIntent.putExtra(CameraConfiguration.Arguments.VIDEO_FILE_SIZE, videoSize * 1024 * 1024); // } // activity.startActivityForResult(cameraIntent, RESULT_CODE); // } // } // // public class MediaType { // public static final int PHOTO = 0; // public static final int VIDEO = 1; // } // } // // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/model/Media.java // public class Media implements Serializable { // private int type; // private String path; // // public Media(int type, String path) { // this.type = type; // this.path = path; // } // // public Media() { // } // // public String getPath() { // return path; // } // // public void setPath(String path) { // this.path = path; // } // // /** // * User media type @link{MediaType} // * // * @return // */ // public int getType() { // return type; // } // // public void setType(int type) { // this.type = type; // } // } // Path: sandriosCamera/src/main/java/com/sandrios/sandriosCamera/internal/ui/view/GalleryAdapter.java import android.annotation.SuppressLint; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.sandrios.sandriosCamera.R; import com.sandrios.sandriosCamera.internal.SandriosCamera; import com.sandrios.sandriosCamera.internal.ui.model.Media; import java.util.List; package com.sandrios.sandriosCamera.internal.ui.view; /** * Created by Arpit Gandhi */ public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.GalleryViewHolder> { final static int SMALL = 0; final static int LARGE = 1; private List<Media> pickerTiles; private Context context; private int type; GalleryAdapter(Context context, int type, List<Media> pickerTiles) { this.context = context; this.type = type; this.pickerTiles = pickerTiles; } @NonNull @Override public GalleryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view; if (type == SMALL) { view = LayoutInflater.from(context).inflate(R.layout.gallery_item_small, parent, false); } else { view = LayoutInflater.from(context).inflate(R.layout.gallery_item_large, parent, false); } return new GalleryViewHolder(view); } @Override public void onBindViewHolder(@NonNull final GalleryViewHolder holder, @SuppressLint("RecyclerView") final int position) { Media media = pickerTiles.get(position);
if (media.getType() == SandriosCamera.MediaType.PHOTO) {
Chicken-Bones/CodeChickenLib
src/codechicken/lib/render/TextureFX.java
// Path: src/codechicken/lib/render/SpriteSheetManager.java // @SideOnly(Side.CLIENT) // public static class SpriteSheet implements IIconRegister // { // private int tilesX; // private int tilesY; // private ArrayList<Integer> newSprites = new ArrayList<Integer>(); // private TextureSpecial[] sprites; // private ResourceLocation resource; // private TextureDataHolder texture; // private int spriteWidth; // private int spriteHeight; // // public int atlasIndex; // // private SpriteSheet(int tilesX, int tilesY, ResourceLocation textureFile) { // this.tilesX = tilesX; // this.tilesY = tilesY; // this.resource = textureFile; // sprites = new TextureSpecial[tilesX * tilesY]; // } // // public void requestIndicies(int... indicies) { // for (int i : indicies) // setupSprite(i); // } // // @Override // public void registerIcons(TextureMap textureMap) { // if (TextureUtils.refreshTexture(textureMap, resource.getResourcePath())) { // reloadTexture(); // for (TextureSpecial sprite : sprites) // if (sprite != null) // textureMap.setTextureEntry(sprite.getIconName(), sprite); // } else { // for (int i : newSprites) // textureMap.setTextureEntry(sprites[i].getIconName(), sprites[i]); // } // newSprites.clear(); // } // // public TextureSpecial setupSprite(int i) { // if (sprites[i] == null) { // String name = resource + "_" + i; // sprites[i] = new TextureSpecial(name).baseFromSheet(this, i); // newSprites.add(i); // } // return sprites[i]; // } // // private void reloadTexture() { // texture = TextureUtils.loadTexture(resource); // spriteWidth = texture.width / tilesX; // spriteHeight = texture.height / tilesY; // } // // public TextureAtlasSprite getSprite(int index) { // TextureAtlasSprite i = sprites[index]; // if (i == null) // throw new IllegalArgumentException("Sprite at index: " + index + " from texture file " + resource + " was not preloaded."); // return i; // } // // public TextureDataHolder createSprite(int spriteIndex) { // int sx = spriteIndex % tilesX; // int sy = spriteIndex / tilesX; // TextureDataHolder sprite = new TextureDataHolder(spriteWidth, spriteHeight); // TextureUtils.copySubImg(texture.data, texture.width, sx * spriteWidth, sy * spriteHeight, // spriteWidth, spriteHeight, // sprite.data, spriteWidth, 0, 0); // return sprite; // } // // public int spriteWidth() { // return spriteWidth; // } // // public int spriteHeight() { // return spriteHeight; // } // // public TextureSpecial bindTextureFX(int i, TextureFX textureFX) { // return setupSprite(i).addTextureFX(textureFX); // } // // public SpriteSheet selfRegister(int atlas) { // TextureUtils.addIconRegister(this); // return this; // } // }
import codechicken.lib.render.SpriteSheetManager.SpriteSheet; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft;
package codechicken.lib.render; @SideOnly(Side.CLIENT) public class TextureFX { public int[] imageData; public int tileSizeBase = 16; public int tileSizeSquare = 256; public int tileSizeMask = 15; public int tileSizeSquareMask = 255; public boolean anaglyphEnabled; public TextureSpecial texture;
// Path: src/codechicken/lib/render/SpriteSheetManager.java // @SideOnly(Side.CLIENT) // public static class SpriteSheet implements IIconRegister // { // private int tilesX; // private int tilesY; // private ArrayList<Integer> newSprites = new ArrayList<Integer>(); // private TextureSpecial[] sprites; // private ResourceLocation resource; // private TextureDataHolder texture; // private int spriteWidth; // private int spriteHeight; // // public int atlasIndex; // // private SpriteSheet(int tilesX, int tilesY, ResourceLocation textureFile) { // this.tilesX = tilesX; // this.tilesY = tilesY; // this.resource = textureFile; // sprites = new TextureSpecial[tilesX * tilesY]; // } // // public void requestIndicies(int... indicies) { // for (int i : indicies) // setupSprite(i); // } // // @Override // public void registerIcons(TextureMap textureMap) { // if (TextureUtils.refreshTexture(textureMap, resource.getResourcePath())) { // reloadTexture(); // for (TextureSpecial sprite : sprites) // if (sprite != null) // textureMap.setTextureEntry(sprite.getIconName(), sprite); // } else { // for (int i : newSprites) // textureMap.setTextureEntry(sprites[i].getIconName(), sprites[i]); // } // newSprites.clear(); // } // // public TextureSpecial setupSprite(int i) { // if (sprites[i] == null) { // String name = resource + "_" + i; // sprites[i] = new TextureSpecial(name).baseFromSheet(this, i); // newSprites.add(i); // } // return sprites[i]; // } // // private void reloadTexture() { // texture = TextureUtils.loadTexture(resource); // spriteWidth = texture.width / tilesX; // spriteHeight = texture.height / tilesY; // } // // public TextureAtlasSprite getSprite(int index) { // TextureAtlasSprite i = sprites[index]; // if (i == null) // throw new IllegalArgumentException("Sprite at index: " + index + " from texture file " + resource + " was not preloaded."); // return i; // } // // public TextureDataHolder createSprite(int spriteIndex) { // int sx = spriteIndex % tilesX; // int sy = spriteIndex / tilesX; // TextureDataHolder sprite = new TextureDataHolder(spriteWidth, spriteHeight); // TextureUtils.copySubImg(texture.data, texture.width, sx * spriteWidth, sy * spriteHeight, // spriteWidth, spriteHeight, // sprite.data, spriteWidth, 0, 0); // return sprite; // } // // public int spriteWidth() { // return spriteWidth; // } // // public int spriteHeight() { // return spriteHeight; // } // // public TextureSpecial bindTextureFX(int i, TextureFX textureFX) { // return setupSprite(i).addTextureFX(textureFX); // } // // public SpriteSheet selfRegister(int atlas) { // TextureUtils.addIconRegister(this); // return this; // } // } // Path: src/codechicken/lib/render/TextureFX.java import codechicken.lib.render.SpriteSheetManager.SpriteSheet; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; package codechicken.lib.render; @SideOnly(Side.CLIENT) public class TextureFX { public int[] imageData; public int tileSizeBase = 16; public int tileSizeSquare = 256; public int tileSizeMask = 15; public int tileSizeSquareMask = 255; public boolean anaglyphEnabled; public TextureSpecial texture;
public TextureFX(int spriteIndex, SpriteSheet sheet) {
Chicken-Bones/CodeChickenLib
src/codechicken/lib/render/SpriteSheetManager.java
// Path: src/codechicken/lib/render/TextureUtils.java // public static interface IIconRegister // { // public void registerIcons(TextureMap textureMap); // }
import codechicken.lib.render.TextureUtils.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.HashMap;
package codechicken.lib.render; public class SpriteSheetManager { @SideOnly(Side.CLIENT)
// Path: src/codechicken/lib/render/TextureUtils.java // public static interface IIconRegister // { // public void registerIcons(TextureMap textureMap); // } // Path: src/codechicken/lib/render/SpriteSheetManager.java import codechicken.lib.render.TextureUtils.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.HashMap; package codechicken.lib.render; public class SpriteSheetManager { @SideOnly(Side.CLIENT)
public static class SpriteSheet implements IIconRegister
Chicken-Bones/CodeChickenLib
src/codechicken/lib/render/TextureSpecial.java
// Path: src/codechicken/lib/render/SpriteSheetManager.java // @SideOnly(Side.CLIENT) // public static class SpriteSheet implements IIconRegister // { // private int tilesX; // private int tilesY; // private ArrayList<Integer> newSprites = new ArrayList<Integer>(); // private TextureSpecial[] sprites; // private ResourceLocation resource; // private TextureDataHolder texture; // private int spriteWidth; // private int spriteHeight; // // public int atlasIndex; // // private SpriteSheet(int tilesX, int tilesY, ResourceLocation textureFile) { // this.tilesX = tilesX; // this.tilesY = tilesY; // this.resource = textureFile; // sprites = new TextureSpecial[tilesX * tilesY]; // } // // public void requestIndicies(int... indicies) { // for (int i : indicies) // setupSprite(i); // } // // @Override // public void registerIcons(TextureMap textureMap) { // if (TextureUtils.refreshTexture(textureMap, resource.getResourcePath())) { // reloadTexture(); // for (TextureSpecial sprite : sprites) // if (sprite != null) // textureMap.setTextureEntry(sprite.getIconName(), sprite); // } else { // for (int i : newSprites) // textureMap.setTextureEntry(sprites[i].getIconName(), sprites[i]); // } // newSprites.clear(); // } // // public TextureSpecial setupSprite(int i) { // if (sprites[i] == null) { // String name = resource + "_" + i; // sprites[i] = new TextureSpecial(name).baseFromSheet(this, i); // newSprites.add(i); // } // return sprites[i]; // } // // private void reloadTexture() { // texture = TextureUtils.loadTexture(resource); // spriteWidth = texture.width / tilesX; // spriteHeight = texture.height / tilesY; // } // // public TextureAtlasSprite getSprite(int index) { // TextureAtlasSprite i = sprites[index]; // if (i == null) // throw new IllegalArgumentException("Sprite at index: " + index + " from texture file " + resource + " was not preloaded."); // return i; // } // // public TextureDataHolder createSprite(int spriteIndex) { // int sx = spriteIndex % tilesX; // int sy = spriteIndex / tilesX; // TextureDataHolder sprite = new TextureDataHolder(spriteWidth, spriteHeight); // TextureUtils.copySubImg(texture.data, texture.width, sx * spriteWidth, sy * spriteHeight, // spriteWidth, spriteHeight, // sprite.data, spriteWidth, 0, 0); // return sprite; // } // // public int spriteWidth() { // return spriteWidth; // } // // public int spriteHeight() { // return spriteHeight; // } // // public TextureSpecial bindTextureFX(int i, TextureFX textureFX) { // return setupSprite(i).addTextureFX(textureFX); // } // // public SpriteSheet selfRegister(int atlas) { // TextureUtils.addIconRegister(this); // return this; // } // } // // Path: src/codechicken/lib/render/TextureUtils.java // public static interface IIconRegister // { // public void registerIcons(TextureMap textureMap); // }
import codechicken.lib.render.SpriteSheetManager.SpriteSheet; import codechicken.lib.render.TextureUtils.IIconRegister; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.data.AnimationMetadataSection; import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList;
package codechicken.lib.render; @SideOnly(Side.CLIENT) public class TextureSpecial extends TextureAtlasSprite implements IIconRegister { //sprite sheet fields private int spriteIndex;
// Path: src/codechicken/lib/render/SpriteSheetManager.java // @SideOnly(Side.CLIENT) // public static class SpriteSheet implements IIconRegister // { // private int tilesX; // private int tilesY; // private ArrayList<Integer> newSprites = new ArrayList<Integer>(); // private TextureSpecial[] sprites; // private ResourceLocation resource; // private TextureDataHolder texture; // private int spriteWidth; // private int spriteHeight; // // public int atlasIndex; // // private SpriteSheet(int tilesX, int tilesY, ResourceLocation textureFile) { // this.tilesX = tilesX; // this.tilesY = tilesY; // this.resource = textureFile; // sprites = new TextureSpecial[tilesX * tilesY]; // } // // public void requestIndicies(int... indicies) { // for (int i : indicies) // setupSprite(i); // } // // @Override // public void registerIcons(TextureMap textureMap) { // if (TextureUtils.refreshTexture(textureMap, resource.getResourcePath())) { // reloadTexture(); // for (TextureSpecial sprite : sprites) // if (sprite != null) // textureMap.setTextureEntry(sprite.getIconName(), sprite); // } else { // for (int i : newSprites) // textureMap.setTextureEntry(sprites[i].getIconName(), sprites[i]); // } // newSprites.clear(); // } // // public TextureSpecial setupSprite(int i) { // if (sprites[i] == null) { // String name = resource + "_" + i; // sprites[i] = new TextureSpecial(name).baseFromSheet(this, i); // newSprites.add(i); // } // return sprites[i]; // } // // private void reloadTexture() { // texture = TextureUtils.loadTexture(resource); // spriteWidth = texture.width / tilesX; // spriteHeight = texture.height / tilesY; // } // // public TextureAtlasSprite getSprite(int index) { // TextureAtlasSprite i = sprites[index]; // if (i == null) // throw new IllegalArgumentException("Sprite at index: " + index + " from texture file " + resource + " was not preloaded."); // return i; // } // // public TextureDataHolder createSprite(int spriteIndex) { // int sx = spriteIndex % tilesX; // int sy = spriteIndex / tilesX; // TextureDataHolder sprite = new TextureDataHolder(spriteWidth, spriteHeight); // TextureUtils.copySubImg(texture.data, texture.width, sx * spriteWidth, sy * spriteHeight, // spriteWidth, spriteHeight, // sprite.data, spriteWidth, 0, 0); // return sprite; // } // // public int spriteWidth() { // return spriteWidth; // } // // public int spriteHeight() { // return spriteHeight; // } // // public TextureSpecial bindTextureFX(int i, TextureFX textureFX) { // return setupSprite(i).addTextureFX(textureFX); // } // // public SpriteSheet selfRegister(int atlas) { // TextureUtils.addIconRegister(this); // return this; // } // } // // Path: src/codechicken/lib/render/TextureUtils.java // public static interface IIconRegister // { // public void registerIcons(TextureMap textureMap); // } // Path: src/codechicken/lib/render/TextureSpecial.java import codechicken.lib.render.SpriteSheetManager.SpriteSheet; import codechicken.lib.render.TextureUtils.IIconRegister; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.data.AnimationMetadataSection; import net.minecraft.client.settings.GameSettings; import net.minecraft.util.ResourceLocation; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList; package codechicken.lib.render; @SideOnly(Side.CLIENT) public class TextureSpecial extends TextureAtlasSprite implements IIconRegister { //sprite sheet fields private int spriteIndex;
private SpriteSheet spriteSheet;
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable {
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable {
activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() {
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
fadeIn(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view).subscribe(o);
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class FadeAnimationsTest extends BaseAnimationsTest { @Test public void testFadeIn() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view).subscribe(o);
assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
public void testFadeInWithDuration() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; public void testFadeInWithDuration() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
fadeInQuickly(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o);
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeIn(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o);
assertTestObserverCompletedAfterDuration(DURATION_QUICK);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; public void testFadeInWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
fadeInSlowly(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
// TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInSlowly(view).subscribe(o);
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; // TODO Find a way to test interpolator. } @Test public void testFadeInQuickly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInSlowly(view).subscribe(o);
assertTestObserverCompletedAfterDuration(DURATION_SLOW);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInSlowly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_SLOW); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInSlowlyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOut() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; public void testFadeInQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeInSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } }); fadeInSlowly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_SLOW); assertEquals(1f, view.getAlpha(), 0f); } @Test public void testFadeInSlowlyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOut() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } });
fadeOut(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
fadeOut(view).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutWithDuration() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } }); fadeOut(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutQuickly() throws Throwable {
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; fadeOut(view).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutWithDuration() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } }); fadeOut(view, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutQuickly() throws Throwable {
fadeOutQuickly(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
@Test public void testFadeOutWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutQuickly() throws Throwable { fadeOutQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; @Test public void testFadeOutWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutQuickly() throws Throwable { fadeOutQuickly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_QUICK); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } });
fadeOutSlowly(view).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // }
import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals;
public void testFadeOutQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } }); fadeOutSlowly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_SLOW); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutSlowlyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeToAlpha() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/AnimationConstants.java // public static final long DURATION_SLOW = DURATION_DEFAULT * 3; // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInQuickly(@NonNull View view) { // return fadeIn(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeInSlowly(@NonNull View view) { // return fadeIn(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutQuickly(@NonNull View view) { // return fadeOut(view, DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOutSlowly(@NonNull View view) { // return fadeOut(view, DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) { // return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/FadeAnimationsTest.java import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK; import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha; import static org.junit.Assert.assertEquals; public void testFadeOutQuicklyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeOutSlowly() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(1f); } }); fadeOutSlowly(view).subscribe(o); assertTestObserverCompletedAfterDuration(DURATION_SLOW); assertEquals(0f, view.getAlpha(), 0f); } @Test public void testFadeOutSlowlyWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testFadeToAlpha() throws Throwable { activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() { @Override public void perform(TestActivity activity) { view.setAlpha(0f); } });
fadeToAlpha(view, .7f).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // }
import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List;
package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // } // Path: vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List; package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override
public void onMainMenuItemClicked(@NonNull MainMenuItem item) {
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // }
import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List;
package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override public void onMainMenuItemClicked(@NonNull MainMenuItem item) { startActivity(new Intent(this, item.getActivityClass())); } @NonNull public List<MainMenuItem> getMainMenuItems() { List<MainMenuItem> items = new ArrayList<>();
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // } // Path: vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List; package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override public void onMainMenuItemClicked(@NonNull MainMenuItem item) { startActivity(new Intent(this, item.getActivityClass())); } @NonNull public List<MainMenuItem> getMainMenuItems() { List<MainMenuItem> items = new ArrayList<>();
items.add(new MainMenuItem("Fade animation", "Showcases the fade in/out animation", SingleFadeAnimationActivity.class));
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // }
import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List;
package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override public void onMainMenuItemClicked(@NonNull MainMenuItem item) { startActivity(new Intent(this, item.getActivityClass())); } @NonNull public List<MainMenuItem> getMainMenuItems() { List<MainMenuItem> items = new ArrayList<>(); items.add(new MainMenuItem("Fade animation", "Showcases the fade in/out animation", SingleFadeAnimationActivity.class));
// Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuAdapter.java // public class MainMenuAdapter extends ArrayAdapter<MainMenuItem> { // // @Nullable // private OnMainMenuItemClickListener listener; // // public MainMenuAdapter(@NonNull Context context, List<MainMenuItem> items) { // super(context, 0, items); // } // // @NonNull // @Override // public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // final MainMenuItem item = getItem(position); // if (item == null) return super.getView(position, convertView, parent); // // if (convertView == null) { // convertView = LayoutInflater.from(getContext()).inflate( // R.layout.layout_main_menu_item, parent, false); // } // // final TextView itemTitle = convertView.findViewById(R.id.itemTitle); // final TextView itemDesc = convertView.findViewById(R.id.itemDesc); // // itemTitle.setText(item.getTitle()); // itemDesc.setText(item.getDesc()); // // final LinearLayout itemLayout = convertView.findViewById(R.id.itemLayout); // itemLayout.setOnClickListener(v -> { // if (listener != null) { // listener.onMainMenuItemClicked(item); // } // }); // // return convertView; // } // // public void setOnMainMenuItemClickListener(@Nullable OnMainMenuItemClickListener listener) { // this.listener = listener; // } // // public interface OnMainMenuItemClickListener { // void onMainMenuItemClicked(@NonNull MainMenuItem item); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/menu/MainMenuItem.java // public class MainMenuItem<T extends Activity> { // // @NonNull // private final String title; // // @NonNull // private final String desc; // // @NonNull // private final Class<T> activityClass; // // public MainMenuItem(@NonNull String title, @NonNull String desc, @NonNull Class<T> activityClass) { // this.title = title; // this.desc = desc; // this.activityClass = activityClass; // } // // @NonNull // String getTitle() { // return title; // } // // @NonNull // String getDesc() { // return desc; // } // // @NonNull // public Class<T> getActivityClass() { // return activityClass; // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java // public class SingleFadeAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // fadeOut(fab) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(fadeIn(fab)) // .subscribe(); // } // // } // // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java // public class SingleRotateAnimationActivity extends SingleAnimationActivity { // // @Override // protected void onFabClicked(final FloatingActionButton fab) { // rotateBy(fab, 360) // .doOnAnimationStart(view -> fab.setEnabled(false)) // .doOnAnimationEnd(view -> fab.setEnabled(true)) // .andThen(rotateBy(fab, -360)) // .subscribe(); // } // } // Path: vangogh-sample/src/main/java/com/example/vangogh/MainActivity.java import android.content.Intent; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ListView; import com.example.vangogh.menu.MainMenuAdapter; import com.example.vangogh.menu.MainMenuItem; import com.example.vangogh.samples.SingleFadeAnimationActivity; import com.example.vangogh.samples.SingleRotateAnimationActivity; import java.util.ArrayList; import java.util.List; package com.example.vangogh; public class MainActivity extends AppCompatActivity implements MainMenuAdapter.OnMainMenuItemClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView mainMenuList = findViewById(R.id.mainMenu); MainMenuAdapter adapter = new MainMenuAdapter(this, getMainMenuItems()); adapter.setOnMainMenuItemClickListener(this); mainMenuList.setAdapter(adapter); } @Override public void onMainMenuItemClicked(@NonNull MainMenuItem item) { startActivity(new Intent(this, item.getActivityClass())); } @NonNull public List<MainMenuItem> getMainMenuItems() { List<MainMenuItem> items = new ArrayList<>(); items.add(new MainMenuItem("Fade animation", "Showcases the fade in/out animation", SingleFadeAnimationActivity.class));
items.add(new MainMenuItem("Rotate animation", "Showcases the rotation animation", SingleRotateAnimationActivity.class));
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/BaseAnimationsTest.java
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // }
import android.view.View; import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import io.reactivex.annotations.NonNull; import io.reactivex.observers.TestObserver; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.runner.RunWith; import java.util.concurrent.TimeUnit;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public abstract class BaseAnimationsTest { /** Used for testing animations with custom duration. */ static final long CUSTOM_TEST_DURATION_MS = 1300L; /** Activity rule for the {@link TestActivity} that holds the view to be animated. */ @Rule
// Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/view/TestActivity.java // public class TestActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test); // } // // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/BaseAnimationsTest.java import android.view.View; import com.pspdfkit.labs.vangogh.view.TestActivity; import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import io.reactivex.annotations.NonNull; import io.reactivex.observers.TestObserver; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.runner.RunWith; import java.util.concurrent.TimeUnit; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public abstract class BaseAnimationsTest { /** Used for testing animations with custom duration. */ static final long CUSTOM_TEST_DURATION_MS = 1300L; /** Activity rule for the {@link TestActivity} that holds the view to be animated. */ @Rule
public ActivityScenarioRule<TestActivity> activityScenarioRule = new ActivityScenarioRule<>(TestActivity.class);
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/RotateAnimations.java // public static AnimationCompletable rotateBy(@NonNull View view, float degrees) { // return rotateBy(view, degrees, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.RotateAnimations.rotateBy;
package com.example.vangogh.samples; public class SingleRotateAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/RotateAnimations.java // public static AnimationCompletable rotateBy(@NonNull View view, float degrees) { // return rotateBy(view, degrees, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleRotateAnimationActivity.java import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.RotateAnimations.rotateBy; package com.example.vangogh.samples; public class SingleRotateAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) {
rotateBy(fab, 360)
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // }
import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut;
package com.example.vangogh.samples; public class SingleFadeAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; package com.example.vangogh.samples; public class SingleFadeAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) {
fadeOut(fab)
PSPDFKit-labs/VanGogh
vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // }
import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut;
package com.example.vangogh.samples; public class SingleFadeAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) { fadeOut(fab) .doOnAnimationStart(view -> fab.setEnabled(false)) .doOnAnimationEnd(view -> fab.setEnabled(true))
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeIn(@NonNull View view) { // return fadeToAlpha(view, ALPHA_VISIBLE); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/FadeAnimations.java // public static AnimationCompletable fadeOut(@NonNull View view) { // return fadeToAlpha(view, ALPHA_INVISIBLE); // } // Path: vangogh-sample/src/main/java/com/example/vangogh/samples/SingleFadeAnimationActivity.java import com.google.android.material.floatingactionbutton.FloatingActionButton; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn; import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut; package com.example.vangogh.samples; public class SingleFadeAnimationActivity extends SingleAnimationActivity { @Override protected void onFabClicked(final FloatingActionButton fab) { fadeOut(fab) .doOnAnimationStart(view -> fab.setEnabled(false)) .doOnAnimationEnd(view -> fab.setEnabled(true))
.andThen(fadeIn(fab))
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class TranslateAnimationsTest extends BaseAnimationsTest { private static final float TRANSLATE_TO_X_VALUE = 100f; private static final float TRANSLATE_TO_Y_VALUE = 150F; private static final float TRANSLATE_BY_X_VALUE = -10f; private static final float TRANSLATE_BY_Y_VALUE = 20f; @Test public void testTranslateTo() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class TranslateAnimationsTest extends BaseAnimationsTest { private static final float TRANSLATE_TO_X_VALUE = 100f; private static final float TRANSLATE_TO_Y_VALUE = 150F; private static final float TRANSLATE_BY_X_VALUE = -10f; private static final float TRANSLATE_BY_Y_VALUE = 20f; @Test public void testTranslateTo() throws InterruptedException {
translateTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class TranslateAnimationsTest extends BaseAnimationsTest { private static final float TRANSLATE_TO_X_VALUE = 100f; private static final float TRANSLATE_TO_Y_VALUE = 150F; private static final float TRANSLATE_BY_X_VALUE = -10f; private static final float TRANSLATE_BY_Y_VALUE = 20f; @Test public void testTranslateTo() throws InterruptedException { translateTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithDuration() throws InterruptedException { translateTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateToWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyTo() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; package com.pspdfkit.labs.vangogh.api; @RunWith(AndroidJUnit4.class) public class TranslateAnimationsTest extends BaseAnimationsTest { private static final float TRANSLATE_TO_X_VALUE = 100f; private static final float TRANSLATE_TO_Y_VALUE = 150F; private static final float TRANSLATE_BY_X_VALUE = -10f; private static final float TRANSLATE_BY_Y_VALUE = 20f; @Test public void testTranslateTo() throws InterruptedException { translateTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithDuration() throws InterruptedException { translateTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateToWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyTo() throws InterruptedException {
translateQuicklyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateToWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyTo() throws InterruptedException { translateQuicklyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyTo() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateToWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyTo() throws InterruptedException { translateQuicklyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyTo() throws InterruptedException {
translateSlowlyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
} @Test public void testTranslateQuicklyTo() throws InterruptedException { translateQuicklyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyTo() throws InterruptedException { translateSlowlyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_SLOW); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateSlowlyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateBy() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; } @Test public void testTranslateQuicklyTo() throws InterruptedException { translateQuicklyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyTo() throws InterruptedException { translateSlowlyTo(view, TRANSLATE_TO_X_VALUE, TRANSLATE_TO_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_SLOW); assertEquals(TRANSLATE_TO_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_TO_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateSlowlyToWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateBy() throws InterruptedException {
translateBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
} @Test public void testTranslateBy() throws InterruptedException { translateBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithDuration() throws InterruptedException { translateBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateByWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyBy() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; } @Test public void testTranslateBy() throws InterruptedException { translateBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithDuration() throws InterruptedException { translateBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE, CUSTOM_TEST_DURATION_MS).subscribe(o); assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateByWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyBy() throws InterruptedException {
translateQuicklyBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o);
PSPDFKit-labs/VanGogh
vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // }
import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals;
assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateByWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyBy() throws InterruptedException { translateQuicklyBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyBy() throws InterruptedException {
// Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateQuicklyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_QUICK); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyBy(@NonNull View view, float translationXBy, float translationYBy) { // return translateBy(view, translationXBy, translationYBy, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateSlowlyTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_SLOW); // } // // Path: vangogh/src/main/java/com/pspdfkit/labs/vangogh/api/TranslateAnimations.java // public static AnimationCompletable translateTo(@NonNull View view, float translationX, float translationY) { // return translateTo(view, translationX, translationY, AnimationConstants.DURATION_DEFAULT, AnimationConstants.INTERPOLATOR); // } // Path: vangogh/src/androidTest/java/com/pspdfkit/labs/vangogh/api/TranslateAnimationsTest.java import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateQuicklyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyBy; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateSlowlyTo; import static com.pspdfkit.labs.vangogh.api.TranslateAnimations.translateTo; import static org.junit.Assert.assertEquals; assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateByWithDurationAndInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateQuicklyBy() throws InterruptedException { translateQuicklyBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o); assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_QUICK); assertEquals(TRANSLATE_BY_X_VALUE, view.getTranslationX(), 0.1f); assertEquals(TRANSLATE_BY_Y_VALUE, view.getTranslationY(), 0.1f); } @Test public void testTranslateQuicklyByWithInterpolator() { // TODO Find a way to test interpolator. } @Test public void testTranslateSlowlyBy() throws InterruptedException {
translateSlowlyBy(view, TRANSLATE_BY_X_VALUE, TRANSLATE_BY_Y_VALUE).subscribe(o);
fwbrasil/zoot
zoot-core/src/main/java/net/fwbrasil/zoot/core/api/EndpointAnnotation.java
// Path: zoot-core/src/main/java/net/fwbrasil/zoot/core/request/RequestMethod.java // public class RequestMethod { // // public static final String GET = "GET"; // public static final String POST = "POST"; // public static final String PUT = "PUT"; // public static final String DELETE = "DELETE"; // public static final String OPTIONS = "OPTIONS"; // public static final String HEAD = "HEAD"; // public static final String TRACE = "TRACE"; // // public static final String[] values = { GET, POST, PUT, DELETE, OPTIONS, HEAD, // TRACE }; // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import net.fwbrasil.zoot.core.request.RequestMethod;
package net.fwbrasil.zoot.core.api; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface EndpointAnnotation {
// Path: zoot-core/src/main/java/net/fwbrasil/zoot/core/request/RequestMethod.java // public class RequestMethod { // // public static final String GET = "GET"; // public static final String POST = "POST"; // public static final String PUT = "PUT"; // public static final String DELETE = "DELETE"; // public static final String OPTIONS = "OPTIONS"; // public static final String HEAD = "HEAD"; // public static final String TRACE = "TRACE"; // // public static final String[] values = { GET, POST, PUT, DELETE, OPTIONS, HEAD, // TRACE }; // } // Path: zoot-core/src/main/java/net/fwbrasil/zoot/core/api/EndpointAnnotation.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import net.fwbrasil.zoot.core.request.RequestMethod; package net.fwbrasil.zoot.core.api; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface EndpointAnnotation {
String method() default RequestMethod.GET;
tinselspoon/intellij-kubernetes
src/com/github/tinselspoon/intellij/kubernetes/codeInsight/DuplicateKeyAnnotator.java
// Path: src/com/github/tinselspoon/intellij/kubernetes/KubernetesYamlPsiUtil.java // public final class KubernetesYamlPsiUtil { // // /** Static class private constructor. */ // private KubernetesYamlPsiUtil() { // // no construction // } // // /** // * Find the {@link ResourceTypeKey} for the current document. // * // * @param element an element within the document to check. // * @return the resource type key, or {@code null} if the "apiVersion" and "kind" fields are not present. // */ // @Nullable // public static ResourceTypeKey findResourceKey(final PsiElement element) { // // Get the top-level mapping // final YAMLMapping topLevelMapping = getTopLevelMapping(element); // final String apiVersion = getValueText(topLevelMapping, "apiVersion"); // final String kind = getValueText(topLevelMapping, "kind"); // if (apiVersion != null && kind != null) { // return new ResourceTypeKey(apiVersion, kind); // } else { // return null; // } // } // // /** // * Gets the top-level mapping in the document, if present. // * // * @param element an element within the document. // * @return the top-level mapping, or {@code null} if one is not defined (e.g. in an empty document). // */ // @Nullable // public static YAMLMapping getTopLevelMapping(final PsiElement element) { // final YAMLDocument document = PsiTreeUtil.getParentOfType(element, YAMLDocument.class); // if (document != null) { // final YAMLValue topLevelValue = document.getTopLevelValue(); // if (topLevelValue instanceof YAMLMapping) { // return (YAMLMapping) topLevelValue; // } // } // return null; // } // // /** // * Gets the text of the value held by the given key within a mapping. // * // * @param mapping the mapping to search through. // * @param key the key to search for. // * @return the trimmed text value of the key, or {@code null} if the mapping is null or the key was not found. // */ // @Nullable // public static String getValueText(@Nullable final YAMLMapping mapping, @NotNull final String key) { // return Optional.ofNullable(mapping).map(m -> m.getKeyValueByKey(key)).map(YAMLKeyValue::getValueText).map(String::trim).orElse(null); // } // // /** // * Determines whether the element is within a Kubernetes YAML file. This is done by checking for the presence of "apiVersion" or "kind" as top-level keys within the first document of the file. // * // * @param element an element within the file to check. // * @return true if the element is within A Kubernetes YAML file, otherwise, false. // */ // public static boolean isKubernetesFile(final PsiElement element) { // final PsiFile file = element.getContainingFile(); // if (file instanceof YAMLFile) { // final Collection<YAMLKeyValue> keys = YAMLUtil.getTopLevelKeys((YAMLFile) file); // return keys.stream().map(YAMLKeyValue::getKeyText).anyMatch(s -> "apiVersion".equals(s) || "kind".equals(s)); // } // return false; // } // // /** // * Find the corresponding {@link Model} object that represents the value of a given {@link YAMLKeyValue}. // * // * @param modelProvider the model provider to use for looking up schema resources. // * @param resourceKey the top-level key of the resource. // * @param keyValue the {@code YAMLKeyValue} to search back from. // * @return the corresponding model or {@code null} if one cannot be located. // */ // @Nullable // public static Model modelForKey(final ModelProvider modelProvider, final ResourceTypeKey resourceKey, final YAMLKeyValue keyValue) { // // Get the tree of keys leading up to this one // final List<String> keys = new ArrayList<>(); // YAMLKeyValue currentKey = keyValue; // do { // keys.add(currentKey.getKeyText()); // } while ((currentKey = PsiTreeUtil.getParentOfType(currentKey, YAMLKeyValue.class)) != null); // // // We have iterated from the inside out, so flip this around to get it in the correct direction for the ModelProvider // Collections.reverse(keys); // return modelProvider.findModel(resourceKey, keys); // } // // /** // * Find the corresponding {@link Property} object that relates to the given {@link YAMLKeyValue}. // * // * @param modelProvider the model provider to use for looking up schema resources. // * @param resourceKey the top-level key of the resource. // * @param keyValue the {@code YAMLKeyValue} to search back from. // * @return the corresponding property or {@code null} if one cannot be located. // */ // @Nullable // public static Property propertyForKey(@NotNull final ModelProvider modelProvider, @NotNull final ResourceTypeKey resourceKey, @NotNull final YAMLKeyValue keyValue) { // // Get the tree of keys leading up to this one // final List<String> keys = new ArrayList<>(); // YAMLKeyValue currentKey = keyValue; // while ((currentKey = PsiTreeUtil.getParentOfType(currentKey, YAMLKeyValue.class)) != null) { // keys.add(currentKey.getKeyText()); // } // // // We have iterated from the inside out, so flip this around to get it in the correct direction for the ModelProvider // Collections.reverse(keys); // return modelProvider.findProperties(resourceKey, keys).get(keyValue.getKeyText()); // } // }
import java.util.Collection; import java.util.HashSet; import java.util.Set; import org.jetbrains.annotations.NotNull; import org.jetbrains.yaml.psi.YAMLKeyValue; import org.jetbrains.yaml.psi.YAMLMapping; import com.github.tinselspoon.intellij.kubernetes.KubernetesYamlPsiUtil; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; import com.intellij.psi.PsiElement;
package com.github.tinselspoon.intellij.kubernetes.codeInsight; /** * Finds {@link YAMLMapping}s with duplicated keys. */ public class DuplicateKeyAnnotator implements Annotator { @Override public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
// Path: src/com/github/tinselspoon/intellij/kubernetes/KubernetesYamlPsiUtil.java // public final class KubernetesYamlPsiUtil { // // /** Static class private constructor. */ // private KubernetesYamlPsiUtil() { // // no construction // } // // /** // * Find the {@link ResourceTypeKey} for the current document. // * // * @param element an element within the document to check. // * @return the resource type key, or {@code null} if the "apiVersion" and "kind" fields are not present. // */ // @Nullable // public static ResourceTypeKey findResourceKey(final PsiElement element) { // // Get the top-level mapping // final YAMLMapping topLevelMapping = getTopLevelMapping(element); // final String apiVersion = getValueText(topLevelMapping, "apiVersion"); // final String kind = getValueText(topLevelMapping, "kind"); // if (apiVersion != null && kind != null) { // return new ResourceTypeKey(apiVersion, kind); // } else { // return null; // } // } // // /** // * Gets the top-level mapping in the document, if present. // * // * @param element an element within the document. // * @return the top-level mapping, or {@code null} if one is not defined (e.g. in an empty document). // */ // @Nullable // public static YAMLMapping getTopLevelMapping(final PsiElement element) { // final YAMLDocument document = PsiTreeUtil.getParentOfType(element, YAMLDocument.class); // if (document != null) { // final YAMLValue topLevelValue = document.getTopLevelValue(); // if (topLevelValue instanceof YAMLMapping) { // return (YAMLMapping) topLevelValue; // } // } // return null; // } // // /** // * Gets the text of the value held by the given key within a mapping. // * // * @param mapping the mapping to search through. // * @param key the key to search for. // * @return the trimmed text value of the key, or {@code null} if the mapping is null or the key was not found. // */ // @Nullable // public static String getValueText(@Nullable final YAMLMapping mapping, @NotNull final String key) { // return Optional.ofNullable(mapping).map(m -> m.getKeyValueByKey(key)).map(YAMLKeyValue::getValueText).map(String::trim).orElse(null); // } // // /** // * Determines whether the element is within a Kubernetes YAML file. This is done by checking for the presence of "apiVersion" or "kind" as top-level keys within the first document of the file. // * // * @param element an element within the file to check. // * @return true if the element is within A Kubernetes YAML file, otherwise, false. // */ // public static boolean isKubernetesFile(final PsiElement element) { // final PsiFile file = element.getContainingFile(); // if (file instanceof YAMLFile) { // final Collection<YAMLKeyValue> keys = YAMLUtil.getTopLevelKeys((YAMLFile) file); // return keys.stream().map(YAMLKeyValue::getKeyText).anyMatch(s -> "apiVersion".equals(s) || "kind".equals(s)); // } // return false; // } // // /** // * Find the corresponding {@link Model} object that represents the value of a given {@link YAMLKeyValue}. // * // * @param modelProvider the model provider to use for looking up schema resources. // * @param resourceKey the top-level key of the resource. // * @param keyValue the {@code YAMLKeyValue} to search back from. // * @return the corresponding model or {@code null} if one cannot be located. // */ // @Nullable // public static Model modelForKey(final ModelProvider modelProvider, final ResourceTypeKey resourceKey, final YAMLKeyValue keyValue) { // // Get the tree of keys leading up to this one // final List<String> keys = new ArrayList<>(); // YAMLKeyValue currentKey = keyValue; // do { // keys.add(currentKey.getKeyText()); // } while ((currentKey = PsiTreeUtil.getParentOfType(currentKey, YAMLKeyValue.class)) != null); // // // We have iterated from the inside out, so flip this around to get it in the correct direction for the ModelProvider // Collections.reverse(keys); // return modelProvider.findModel(resourceKey, keys); // } // // /** // * Find the corresponding {@link Property} object that relates to the given {@link YAMLKeyValue}. // * // * @param modelProvider the model provider to use for looking up schema resources. // * @param resourceKey the top-level key of the resource. // * @param keyValue the {@code YAMLKeyValue} to search back from. // * @return the corresponding property or {@code null} if one cannot be located. // */ // @Nullable // public static Property propertyForKey(@NotNull final ModelProvider modelProvider, @NotNull final ResourceTypeKey resourceKey, @NotNull final YAMLKeyValue keyValue) { // // Get the tree of keys leading up to this one // final List<String> keys = new ArrayList<>(); // YAMLKeyValue currentKey = keyValue; // while ((currentKey = PsiTreeUtil.getParentOfType(currentKey, YAMLKeyValue.class)) != null) { // keys.add(currentKey.getKeyText()); // } // // // We have iterated from the inside out, so flip this around to get it in the correct direction for the ModelProvider // Collections.reverse(keys); // return modelProvider.findProperties(resourceKey, keys).get(keyValue.getKeyText()); // } // } // Path: src/com/github/tinselspoon/intellij/kubernetes/codeInsight/DuplicateKeyAnnotator.java import java.util.Collection; import java.util.HashSet; import java.util.Set; import org.jetbrains.annotations.NotNull; import org.jetbrains.yaml.psi.YAMLKeyValue; import org.jetbrains.yaml.psi.YAMLMapping; import com.github.tinselspoon.intellij.kubernetes.KubernetesYamlPsiUtil; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; import com.intellij.psi.PsiElement; package com.github.tinselspoon.intellij.kubernetes.codeInsight; /** * Finds {@link YAMLMapping}s with duplicated keys. */ public class DuplicateKeyAnnotator implements Annotator { @Override public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) {
tinselspoon/intellij-kubernetes
src/com/github/tinselspoon/intellij/kubernetes/model/ModelProvider.java
// Path: src/com/github/tinselspoon/intellij/kubernetes/ResourceTypeKey.java // public class ResourceTypeKey { // // /** The value of the "apiVersion" field, e.g. {@code batch/v1}. */ // private final String apiVersion; // // /** The value of the "kind" field, e.g. {@code Job}. */ // private final String kind; // // /** // * Default constructor. // * // * @param apiVersion the value of the "apiVersion" field, e.g. {@code batch/v1}. // * @param kind the value of the "kind" field, e.g. {@code Job}. // */ // public ResourceTypeKey(final String apiVersion, final String kind) { // this.apiVersion = apiVersion; // this.kind = kind; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // final ResourceTypeKey that = (ResourceTypeKey) o; // return Objects.equals(apiVersion, that.apiVersion) && Objects.equals(kind, that.kind); // } // // /** // * Gets the value of the "apiVersion" field, e.g. {@code batch/v1}. // * // * @return the api version. // */ // public String getApiVersion() { // return apiVersion; // } // // /** // * Gets the value of the "kind" field, e.g. {@code Job}. // * // * @return the kind. // */ // public String getKind() { // return kind; // } // // @Override // public int hashCode() { // return Objects.hash(apiVersion, kind); // } // }
import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.github.tinselspoon.intellij.kubernetes.ResourceTypeKey;
package com.github.tinselspoon.intellij.kubernetes.model; /** * Provides information on the schema of Kubernetes resources. */ public class ModelProvider { /** Singleton instance. */ public static final ModelProvider INSTANCE = new ModelProvider(); private final ModelLoader modelLoader = new ModelLoader(); /** The specs currently loaded. */ private List<SwaggerSpec> specs; /** Singleton private constructor. */ private ModelProvider() { } /** * Find the model that governs the property described by navigating from the base model of the {@link ResourceTypeKey} through the properties given in the {@code path}. * * @param resourceTypeKey the resource at which to begin the search. * @param path a series of properties to navigate through, may be empty to return the root model of the {@code ResourceTypeKey}. * @return the model, or {@code null} if one cannot be found. */ @Nullable
// Path: src/com/github/tinselspoon/intellij/kubernetes/ResourceTypeKey.java // public class ResourceTypeKey { // // /** The value of the "apiVersion" field, e.g. {@code batch/v1}. */ // private final String apiVersion; // // /** The value of the "kind" field, e.g. {@code Job}. */ // private final String kind; // // /** // * Default constructor. // * // * @param apiVersion the value of the "apiVersion" field, e.g. {@code batch/v1}. // * @param kind the value of the "kind" field, e.g. {@code Job}. // */ // public ResourceTypeKey(final String apiVersion, final String kind) { // this.apiVersion = apiVersion; // this.kind = kind; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // final ResourceTypeKey that = (ResourceTypeKey) o; // return Objects.equals(apiVersion, that.apiVersion) && Objects.equals(kind, that.kind); // } // // /** // * Gets the value of the "apiVersion" field, e.g. {@code batch/v1}. // * // * @return the api version. // */ // public String getApiVersion() { // return apiVersion; // } // // /** // * Gets the value of the "kind" field, e.g. {@code Job}. // * // * @return the kind. // */ // public String getKind() { // return kind; // } // // @Override // public int hashCode() { // return Objects.hash(apiVersion, kind); // } // } // Path: src/com/github/tinselspoon/intellij/kubernetes/model/ModelProvider.java import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.github.tinselspoon.intellij.kubernetes.ResourceTypeKey; package com.github.tinselspoon.intellij.kubernetes.model; /** * Provides information on the schema of Kubernetes resources. */ public class ModelProvider { /** Singleton instance. */ public static final ModelProvider INSTANCE = new ModelProvider(); private final ModelLoader modelLoader = new ModelLoader(); /** The specs currently loaded. */ private List<SwaggerSpec> specs; /** Singleton private constructor. */ private ModelProvider() { } /** * Find the model that governs the property described by navigating from the base model of the {@link ResourceTypeKey} through the properties given in the {@code path}. * * @param resourceTypeKey the resource at which to begin the search. * @param path a series of properties to navigate through, may be empty to return the root model of the {@code ResourceTypeKey}. * @return the model, or {@code null} if one cannot be found. */ @Nullable
public Model findModel(final ResourceTypeKey resourceTypeKey, final List<String> path) {
tinselspoon/intellij-kubernetes
src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // }
import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property;
package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // Path: src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property; package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull
static String typeStringFor(@NotNull final Property propertySpec) {
tinselspoon/intellij-kubernetes
src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // }
import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property;
package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull static String typeStringFor(@NotNull final Property propertySpec) { final String typeText;
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // Path: src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property; package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull static String typeStringFor(@NotNull final Property propertySpec) { final String typeText;
final ArrayItems items = propertySpec.getItems();
tinselspoon/intellij-kubernetes
src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // }
import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property;
package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull static String typeStringFor(@NotNull final Property propertySpec) { final String typeText; final ArrayItems items = propertySpec.getItems();
// Path: src/com/github/tinselspoon/intellij/kubernetes/model/ArrayItems.java // public class ArrayItems { // // /** A reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. */ // @SerializedName("$ref") // private String ref; // // /** The type of the items. Either this property or {@link #getRef() ref} should be set. */ // private FieldType type; // // /** // * Gets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a reference to a model ID which the items conform to. Either this property or {@link #getType() type} should be set. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of the items. Either this property or {@link #getRef() ref} should be set. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/FieldType.java // public enum FieldType { // // /** An integer property data type. */ // @SerializedName("integer") // INTEGER, // // /** A number property data type (i.e. may have a decimal point). */ // @SerializedName("number") // NUMBER, // // /** A string property data type. */ // @SerializedName("string") // STRING, // // /** A boolean property data type. */ // @SerializedName("boolean") // BOOLEAN, // // /** An array property data type. */ // @SerializedName("array") // ARRAY, // // /** An unstructured object property data type. */ // @SerializedName("object") // OBJECT; // // @Override // public String toString() { // return name().toLowerCase(); // } // } // // Path: src/com/github/tinselspoon/intellij/kubernetes/model/Property.java // public class Property { // // /** A description of this property. */ // private String description; // // /** For properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). */ // private ArrayItems items; // // /** The model ID which describes the possible child properties of this property, or {@code null} if not applicable. */ // @SerializedName("$ref") // private String ref; // // /** The type of this property. Should not be set if {@link #getRef() ref} is populated. */ // private FieldType type; // // /** // * Gets a description of this property. // * // * @return the description. // */ // public String getDescription() { // return description; // } // // /** // * Gets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @return the items. // */ // public ArrayItems getItems() { // return items; // } // // /** // * Gets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @return the ref. // */ // public String getRef() { // return ref; // } // // /** // * Gets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @return the type. // */ // public FieldType getType() { // return type; // } // // /** // * Sets a description of this property. // * // * @param description the new description. // */ // public void setDescription(final String description) { // this.description = description; // } // // /** // * Sets for properties that are arrays, describes the items that may appear in the array ({@code null} otherwise). // * // * @param items the new items. // */ // public void setItems(final ArrayItems items) { // this.items = items; // } // // /** // * Sets the model ID which describes the possible child properties of this property, or {@code null} if not applicable. // * // * @param ref the new ref. // */ // public void setRef(final String ref) { // this.ref = ref; // } // // /** // * Sets the type of this property. Should not be set if {@link #getRef() ref} is populated. // * // * @param type the new type. // */ // public void setType(final FieldType type) { // this.type = type; // } // } // Path: src/com/github/tinselspoon/intellij/kubernetes/ModelUtil.java import java.util.Objects; import org.jetbrains.annotations.NotNull; import com.github.tinselspoon.intellij.kubernetes.model.ArrayItems; import com.github.tinselspoon.intellij.kubernetes.model.FieldType; import com.github.tinselspoon.intellij.kubernetes.model.Property; package com.github.tinselspoon.intellij.kubernetes; /** * Utilities for working with model classes. */ final class ModelUtil { /** Static class private constructor. */ private ModelUtil() { } /** * Get a string that describes the type of a particular property. * <p> * If the property is a basic type (string, integer etc) then the type name is returned. If the property type refers to a model, the model name is returned. If the property is an array, then the * process described previously is carried out for the array item type, and the string "[]" is appended to the end. * * @param propertySpec the property to obtain the type string for. * @return the type string. */ @NotNull static String typeStringFor(@NotNull final Property propertySpec) { final String typeText; final ArrayItems items = propertySpec.getItems();
if (propertySpec.getType() == FieldType.ARRAY && items != null) {
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FeedObject.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // }
import com.hardcopy.retrowatchle.utils.Logs;
mDownloadStatus = CONTENT_DOWNLOAD_STATUS_INIT; } public void setName(String name) { mName = name; } public void setDate(String date) { mDate = date; } public void setDownloadStatus(int status) { mDownloadStatus = status; } public void setRankInfo(int rankType, int rankUpDown, int commentCount) { mRankType = rankType; mRankUpAndDown = rankUpDown; mCommentCount = commentCount; } public void setFullSizeImageURL(String url) { mFullSizeImageURL = url; } public void setVersion(int ver) { mVersion = ver; } public void printLog() {
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FeedObject.java import com.hardcopy.retrowatchle.utils.Logs; mDownloadStatus = CONTENT_DOWNLOAD_STATUS_INIT; } public void setName(String name) { mName = name; } public void setDate(String date) { mDate = date; } public void setDownloadStatus(int status) { mDownloadStatus = status; } public void setRankInfo(int rankType, int rankUpDown, int commentCount) { mRankType = rankType; mRankUpAndDown = rankUpDown; mCommentCount = commentCount; } public void setFullSizeImageURL(String url) { mFullSizeImageURL = url; } public void setVersion(int ver) { mVersion = ver; } public void printLog() {
Logs.d(TAG, "[+] mType = " + mType);
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/FiltersFragment.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FilterObject.java // public class FilterObject { // // public static final int FILTER_TYPE_NONE = 0; // This means that filter is not available // public static final int FILTER_TYPE_ALL = 1; // Every item should pass this filter // public static final int FILTER_TYPE_NOTIFICATION = 2; // public static final int FILTER_TYPE_MESSAGING = 3; // public static final int FILTER_TYPE_FEED = 4; // public static final int FILTER_TYPE_EMERGENCY = 5; // public static final int FILTER_TYPE_PACKAGE_NAME = 6; // // public static final int MATCHING_TYPE_NONE = 0; // This means that matching type is not available // public static final int MATCHING_TYPE_WHOLE_WORD = 1; // public static final int MATCHING_TYPE_START_WITH = 2; // public static final int MATCHING_TYPE_END_WITH = 3; // public static final int MATCHING_TYPE_PART_OF = 4; // // public static final int REPLACE_TYPE_NONE = 0; // This means that replace type is not available // public static final int REPLACE_TYPE_ALL = 1; // replace all // public static final int REPLACE_TYPE_SAME_PART = 2; // replace only same part // // public static final int ICON_TYPE_NONE_CODE = 0xf0; // // // public int mId = -1; // ID : matching with database primary key // public int mType = FILTER_TYPE_NONE; // Filter type : defines target object // public int mIconType = 0; // public int mCompareType = MATCHING_TYPE_NONE; // Matching conditions: whole word, start with, end with, part of // public int mReplaceType = REPLACE_TYPE_NONE; // Replace methods : Replace all, Replace same part only // public String mOriginalString = null; // Original string // public String mReplaceString = null; // String to be shown on remote device // // // public void copyTo(FilterObject target) { // target.mId = this.mId; // target.mType = this.mType; // target.mIconType = this.mIconType; // target.mCompareType = this.mCompareType; // target.mReplaceType = this.mReplaceType; // target.mOriginalString = new String(this.mOriginalString); // target.mReplaceString = new String(this.mReplaceString); // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // }
import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.FilterObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Spinner; import android.widget.Toast;
/* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows user defined message filters. */ public class FiltersFragment extends Fragment implements OnClickListener, IAdapterListener { private static final String TAG = "FiltersFragment"; // Context private Context mContext = null; private IFragmentListener mFragmentListener; // View private ListView mListFilter = null; private FiltersAdapter mFiltersAdapter = null; private Spinner mSpinnerFilterType = null; private Spinner mSpinnerCompareType = null; private Spinner mSpinnerReplaceType = null; private Spinner mSpinnerIconType = null; private EditText mEditOrigin = null; private EditText mEditReplace = null; private Button mButtonDelete = null; private Button mButtonAdd = null; private Button mButtonNew = null; // Data
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/FilterObject.java // public class FilterObject { // // public static final int FILTER_TYPE_NONE = 0; // This means that filter is not available // public static final int FILTER_TYPE_ALL = 1; // Every item should pass this filter // public static final int FILTER_TYPE_NOTIFICATION = 2; // public static final int FILTER_TYPE_MESSAGING = 3; // public static final int FILTER_TYPE_FEED = 4; // public static final int FILTER_TYPE_EMERGENCY = 5; // public static final int FILTER_TYPE_PACKAGE_NAME = 6; // // public static final int MATCHING_TYPE_NONE = 0; // This means that matching type is not available // public static final int MATCHING_TYPE_WHOLE_WORD = 1; // public static final int MATCHING_TYPE_START_WITH = 2; // public static final int MATCHING_TYPE_END_WITH = 3; // public static final int MATCHING_TYPE_PART_OF = 4; // // public static final int REPLACE_TYPE_NONE = 0; // This means that replace type is not available // public static final int REPLACE_TYPE_ALL = 1; // replace all // public static final int REPLACE_TYPE_SAME_PART = 2; // replace only same part // // public static final int ICON_TYPE_NONE_CODE = 0xf0; // // // public int mId = -1; // ID : matching with database primary key // public int mType = FILTER_TYPE_NONE; // Filter type : defines target object // public int mIconType = 0; // public int mCompareType = MATCHING_TYPE_NONE; // Matching conditions: whole word, start with, end with, part of // public int mReplaceType = REPLACE_TYPE_NONE; // Replace methods : Replace all, Replace same part only // public String mOriginalString = null; // Original string // public String mReplaceString = null; // String to be shown on remote device // // // public void copyTo(FilterObject target) { // target.mId = this.mId; // target.mType = this.mType; // target.mIconType = this.mIconType; // target.mCompareType = this.mCompareType; // target.mReplaceType = this.mReplaceType; // target.mOriginalString = new String(this.mOriginalString); // target.mReplaceString = new String(this.mReplaceString); // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/FiltersFragment.java import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.FilterObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.Spinner; import android.widget.Toast; /* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows user defined message filters. */ public class FiltersFragment extends Fragment implements OnClickListener, IAdapterListener { private static final String TAG = "FiltersFragment"; // Context private Context mContext = null; private IFragmentListener mFragmentListener; // View private ListView mListFilter = null; private FiltersAdapter mFiltersAdapter = null; private Spinner mSpinnerFilterType = null; private Spinner mSpinnerCompareType = null; private Spinner mSpinnerReplaceType = null; private Spinner mSpinnerIconType = null; private EditText mEditOrigin = null; private EditText mEditReplace = null; private Button mButtonDelete = null; private Button mButtonAdd = null; private Button mButtonNew = null; // Data
private FilterObject mCurrentFilterObject = null;
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/MessageListFragment.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/ContentObject.java // public class ContentObject { // // public static final int CONTENT_TYPE_NOTIFICATION = 1; // public static final int CONTENT_TYPE_MESSAGING = 2; // public static final int CONTENT_TYPE_EMERGENCY = 3; // public static final int CONTENT_TYPE_FEED = 4; // // public static final int MESSAGING_ID_GMAIL = 1; // public static final int MESSAGING_ID_SMS = 2; // // public static final int EMERGENCY_ID_WIFI = 1; // public static final int EMERGENCY_ID_CALL_STATE = 2; // public static final int EMERGENCY_ID_BATT_STATE = 3; // public static final int EMERGENCY_ID_RF_STATE = 4; // // public static final int ICON_TYPE_NORMAL_MESSAGE = 0; // public static final int ICON_TYPE_EMAIL = 28; // public static final int ICON_TYPE_CALL = 10; // public static final int ICON_TYPE_EMERGENCY = 60; // public static final int ICON_TYPE_BATT_FULL = 4; // public static final int ICON_TYPE_BATT_MEDIUM = 5; // public static final int ICON_TYPE_BATT_LOW = 6; // public static final int ICON_TYPE_RF_STATE = 64; // public static final int ICON_TYPE_RSS = 46; // // public static final String SMS_PACKAGE_NAME = "android.telephony.sms"; // public static final String GMAIL_PACKAGE_NAME = "com.google.android.gm"; // public static final String TELEPHONY_CALL_PACKAGE_NAME = "android.telephony.call"; // public static final String TELEPHONY_RF_PACKAGE_NAME = "android.telephony.rfstatus"; // public static final String FEED_PACKAGE_NAME = "com.hardcopy.feed"; // public static final String WIFI_PACKAGE_NAME = "android.net.wifi"; // public static final String BATT_PACKAGE_NAME = "android.os.battery"; // // public int mContentType; // Content type // public int mIconType; // Icon type // public int mId; // ID // public boolean mIsEnabled = false; // Watch shows enabled items only // public String mOriginalString; // Original string // public String mFilteredString; // String to be shown on remote device // public String mExtraData = null; // Extra data defined by each content type // public String mPackageName = null; // // // public ContentObject(int type, int id, String strOrigin, String strFiltered) { // mContentType = type; // mIconType = -1; // mId = id; // mOriginalString = strOrigin; // mFilteredString = strFiltered; // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // }
import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.ContentObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView;
/* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows messages to be sent to watch. */ public class MessageListFragment extends Fragment implements IAdapterListener { private static final String TAG = "MessageListFragment"; private Context mContext = null; private IFragmentListener mFragmentListener; private ListView mListMessage = null; private MessageListAdapter mMessageListAdapter = null; public MessageListFragment(Context c, IFragmentListener l) { mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/ContentObject.java // public class ContentObject { // // public static final int CONTENT_TYPE_NOTIFICATION = 1; // public static final int CONTENT_TYPE_MESSAGING = 2; // public static final int CONTENT_TYPE_EMERGENCY = 3; // public static final int CONTENT_TYPE_FEED = 4; // // public static final int MESSAGING_ID_GMAIL = 1; // public static final int MESSAGING_ID_SMS = 2; // // public static final int EMERGENCY_ID_WIFI = 1; // public static final int EMERGENCY_ID_CALL_STATE = 2; // public static final int EMERGENCY_ID_BATT_STATE = 3; // public static final int EMERGENCY_ID_RF_STATE = 4; // // public static final int ICON_TYPE_NORMAL_MESSAGE = 0; // public static final int ICON_TYPE_EMAIL = 28; // public static final int ICON_TYPE_CALL = 10; // public static final int ICON_TYPE_EMERGENCY = 60; // public static final int ICON_TYPE_BATT_FULL = 4; // public static final int ICON_TYPE_BATT_MEDIUM = 5; // public static final int ICON_TYPE_BATT_LOW = 6; // public static final int ICON_TYPE_RF_STATE = 64; // public static final int ICON_TYPE_RSS = 46; // // public static final String SMS_PACKAGE_NAME = "android.telephony.sms"; // public static final String GMAIL_PACKAGE_NAME = "com.google.android.gm"; // public static final String TELEPHONY_CALL_PACKAGE_NAME = "android.telephony.call"; // public static final String TELEPHONY_RF_PACKAGE_NAME = "android.telephony.rfstatus"; // public static final String FEED_PACKAGE_NAME = "com.hardcopy.feed"; // public static final String WIFI_PACKAGE_NAME = "android.net.wifi"; // public static final String BATT_PACKAGE_NAME = "android.os.battery"; // // public int mContentType; // Content type // public int mIconType; // Icon type // public int mId; // ID // public boolean mIsEnabled = false; // Watch shows enabled items only // public String mOriginalString; // Original string // public String mFilteredString; // String to be shown on remote device // public String mExtraData = null; // Extra data defined by each content type // public String mPackageName = null; // // // public ContentObject(int type, int id, String strOrigin, String strFiltered) { // mContentType = type; // mIconType = -1; // mId = id; // mOriginalString = strOrigin; // mFilteredString = strFiltered; // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/MessageListFragment.java import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.ContentObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; /* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows messages to be sent to watch. */ public class MessageListFragment extends Fragment implements IAdapterListener { private static final String TAG = "MessageListFragment"; private Context mContext = null; private IFragmentListener mFragmentListener; private ListView mListMessage = null; private MessageListAdapter mMessageListAdapter = null; public MessageListFragment(Context c, IFragmentListener l) { mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Logs.d(TAG, "# MessageListFragment - onCreateView()");
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/MessageListFragment.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/ContentObject.java // public class ContentObject { // // public static final int CONTENT_TYPE_NOTIFICATION = 1; // public static final int CONTENT_TYPE_MESSAGING = 2; // public static final int CONTENT_TYPE_EMERGENCY = 3; // public static final int CONTENT_TYPE_FEED = 4; // // public static final int MESSAGING_ID_GMAIL = 1; // public static final int MESSAGING_ID_SMS = 2; // // public static final int EMERGENCY_ID_WIFI = 1; // public static final int EMERGENCY_ID_CALL_STATE = 2; // public static final int EMERGENCY_ID_BATT_STATE = 3; // public static final int EMERGENCY_ID_RF_STATE = 4; // // public static final int ICON_TYPE_NORMAL_MESSAGE = 0; // public static final int ICON_TYPE_EMAIL = 28; // public static final int ICON_TYPE_CALL = 10; // public static final int ICON_TYPE_EMERGENCY = 60; // public static final int ICON_TYPE_BATT_FULL = 4; // public static final int ICON_TYPE_BATT_MEDIUM = 5; // public static final int ICON_TYPE_BATT_LOW = 6; // public static final int ICON_TYPE_RF_STATE = 64; // public static final int ICON_TYPE_RSS = 46; // // public static final String SMS_PACKAGE_NAME = "android.telephony.sms"; // public static final String GMAIL_PACKAGE_NAME = "com.google.android.gm"; // public static final String TELEPHONY_CALL_PACKAGE_NAME = "android.telephony.call"; // public static final String TELEPHONY_RF_PACKAGE_NAME = "android.telephony.rfstatus"; // public static final String FEED_PACKAGE_NAME = "com.hardcopy.feed"; // public static final String WIFI_PACKAGE_NAME = "android.net.wifi"; // public static final String BATT_PACKAGE_NAME = "android.os.battery"; // // public int mContentType; // Content type // public int mIconType; // Icon type // public int mId; // ID // public boolean mIsEnabled = false; // Watch shows enabled items only // public String mOriginalString; // Original string // public String mFilteredString; // String to be shown on remote device // public String mExtraData = null; // Extra data defined by each content type // public String mPackageName = null; // // // public ContentObject(int type, int id, String strOrigin, String strFiltered) { // mContentType = type; // mIconType = -1; // mId = id; // mOriginalString = strOrigin; // mFilteredString = strFiltered; // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // }
import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.ContentObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView;
mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Logs.d(TAG, "# MessageListFragment - onCreateView()"); View rootView = inflater.inflate(R.layout.fragment_message_list, container, false); mListMessage = (ListView) rootView.findViewById(R.id.list_message); if(mMessageListAdapter == null) mMessageListAdapter = new MessageListAdapter(mContext, R.layout.list_message_list, null); mMessageListAdapter.setAdapterParams(this); mListMessage.setAdapter(mMessageListAdapter); return rootView; } @Override public void OnAdapterCallback(int msgType, int arg0, int arg1, String arg2, String arg3, Object arg4) { switch(msgType) { case IAdapterListener.CALLBACK_ADD_MESSAGE_FILTER: case IAdapterListener.CALLBACK_ADD_PACKAGE_FILTER: if(arg4 != null) mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_ADD_FILTER, 0, 0, null, null, arg4); break; } }
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/contents/objects/ContentObject.java // public class ContentObject { // // public static final int CONTENT_TYPE_NOTIFICATION = 1; // public static final int CONTENT_TYPE_MESSAGING = 2; // public static final int CONTENT_TYPE_EMERGENCY = 3; // public static final int CONTENT_TYPE_FEED = 4; // // public static final int MESSAGING_ID_GMAIL = 1; // public static final int MESSAGING_ID_SMS = 2; // // public static final int EMERGENCY_ID_WIFI = 1; // public static final int EMERGENCY_ID_CALL_STATE = 2; // public static final int EMERGENCY_ID_BATT_STATE = 3; // public static final int EMERGENCY_ID_RF_STATE = 4; // // public static final int ICON_TYPE_NORMAL_MESSAGE = 0; // public static final int ICON_TYPE_EMAIL = 28; // public static final int ICON_TYPE_CALL = 10; // public static final int ICON_TYPE_EMERGENCY = 60; // public static final int ICON_TYPE_BATT_FULL = 4; // public static final int ICON_TYPE_BATT_MEDIUM = 5; // public static final int ICON_TYPE_BATT_LOW = 6; // public static final int ICON_TYPE_RF_STATE = 64; // public static final int ICON_TYPE_RSS = 46; // // public static final String SMS_PACKAGE_NAME = "android.telephony.sms"; // public static final String GMAIL_PACKAGE_NAME = "com.google.android.gm"; // public static final String TELEPHONY_CALL_PACKAGE_NAME = "android.telephony.call"; // public static final String TELEPHONY_RF_PACKAGE_NAME = "android.telephony.rfstatus"; // public static final String FEED_PACKAGE_NAME = "com.hardcopy.feed"; // public static final String WIFI_PACKAGE_NAME = "android.net.wifi"; // public static final String BATT_PACKAGE_NAME = "android.os.battery"; // // public int mContentType; // Content type // public int mIconType; // Icon type // public int mId; // ID // public boolean mIsEnabled = false; // Watch shows enabled items only // public String mOriginalString; // Original string // public String mFilteredString; // String to be shown on remote device // public String mExtraData = null; // Extra data defined by each content type // public String mPackageName = null; // // // public ContentObject(int type, int id, String strOrigin, String strFiltered) { // mContentType = type; // mIconType = -1; // mId = id; // mOriginalString = strOrigin; // mFilteredString = strFiltered; // } // // } // // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/MessageListFragment.java import java.util.ArrayList; import com.hardcopy.retrowatchle.contents.objects.ContentObject; import com.hardcopy.retrowatchle.utils.Logs; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Logs.d(TAG, "# MessageListFragment - onCreateView()"); View rootView = inflater.inflate(R.layout.fragment_message_list, container, false); mListMessage = (ListView) rootView.findViewById(R.id.list_message); if(mMessageListAdapter == null) mMessageListAdapter = new MessageListAdapter(mContext, R.layout.list_message_list, null); mMessageListAdapter.setAdapterParams(this); mListMessage.setAdapter(mMessageListAdapter); return rootView; } @Override public void OnAdapterCallback(int msgType, int arg0, int arg1, String arg2, String arg3, Object arg4) { switch(msgType) { case IAdapterListener.CALLBACK_ADD_MESSAGE_FILTER: case IAdapterListener.CALLBACK_ADD_PACKAGE_FILTER: if(arg4 != null) mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_REQUEST_ADD_FILTER, 0, 0, null, null, arg4); break; } }
public void addMessage(ContentObject object) {
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/WatchControlFragment.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Settings.java // public class Settings { // // private static Settings mSettings = null; // // private Context mContext; // // // // public synchronized static Settings getInstance(Context c) { // if(mSettings == null) { // mSettings = new Settings(c); // } // return mSettings; // } // // public Settings(Context c) { // if(mContext == null) { // mContext = c; // initialize(); // } // } // // // private void initialize() { // } // // // public synchronized void finalize() { // mContext = null; // mSettings = null; // } // // public synchronized void setGmailAddress(String addr) { // if(addr != null && !addr.isEmpty()) { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // SharedPreferences.Editor editor = prefs.edit(); // editor.putString(Constants.PREFERENCE_KEY_GMAIL_ADDRESS, addr); // editor.commit(); // } // } // // public synchronized String getGmailAddress() { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // return prefs.getString(Constants.PREFERENCE_KEY_GMAIL_ADDRESS, null); // } // // public synchronized void setRunInBackground(boolean isTrue) { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // SharedPreferences.Editor editor = prefs.edit(); // editor.putBoolean(Constants.PREFERENCE_KEY_RUN_IN_BG, isTrue); // editor.commit(); // } // // public synchronized boolean getRunInBackground() { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // return prefs.getBoolean(Constants.PREFERENCE_KEY_RUN_IN_BG, false); // } // // // }
import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.CompoundButton.OnCheckedChangeListener; import com.hardcopy.retrowatchle.utils.Settings; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton;
/* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows user defined message filters. */ public class WatchControlFragment extends Fragment { private Context mContext = null; private IFragmentListener mFragmentListener = null; private EditText mEditGmailAddr = null; private Spinner mSpinnerClockStyle = null; private Spinner mSpinnerIndicator = null; private CheckBox mCheckBackground; private int mPresetClockStyle = -1; private int mPresetIndicator = -1; public WatchControlFragment(Context c, IFragmentListener l) { mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_watch_control, container, false); mEditGmailAddr = (EditText) rootView.findViewById(R.id.edit_email_addr);
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Settings.java // public class Settings { // // private static Settings mSettings = null; // // private Context mContext; // // // // public synchronized static Settings getInstance(Context c) { // if(mSettings == null) { // mSettings = new Settings(c); // } // return mSettings; // } // // public Settings(Context c) { // if(mContext == null) { // mContext = c; // initialize(); // } // } // // // private void initialize() { // } // // // public synchronized void finalize() { // mContext = null; // mSettings = null; // } // // public synchronized void setGmailAddress(String addr) { // if(addr != null && !addr.isEmpty()) { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // SharedPreferences.Editor editor = prefs.edit(); // editor.putString(Constants.PREFERENCE_KEY_GMAIL_ADDRESS, addr); // editor.commit(); // } // } // // public synchronized String getGmailAddress() { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // return prefs.getString(Constants.PREFERENCE_KEY_GMAIL_ADDRESS, null); // } // // public synchronized void setRunInBackground(boolean isTrue) { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // SharedPreferences.Editor editor = prefs.edit(); // editor.putBoolean(Constants.PREFERENCE_KEY_RUN_IN_BG, isTrue); // editor.commit(); // } // // public synchronized boolean getRunInBackground() { // SharedPreferences prefs = mContext.getSharedPreferences(Constants.PREFERENCE_NAME, Context.MODE_PRIVATE); // return prefs.getBoolean(Constants.PREFERENCE_KEY_RUN_IN_BG, false); // } // // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/WatchControlFragment.java import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.CompoundButton.OnCheckedChangeListener; import com.hardcopy.retrowatchle.utils.Settings; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton; /* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle; /** * This fragment shows user defined message filters. */ public class WatchControlFragment extends Fragment { private Context mContext = null; private IFragmentListener mFragmentListener = null; private EditText mEditGmailAddr = null; private Spinner mSpinnerClockStyle = null; private Spinner mSpinnerIndicator = null; private CheckBox mCheckBackground; private int mPresetClockStyle = -1; private int mPresetIndicator = -1; public WatchControlFragment(Context c, IFragmentListener l) { mContext = c; mFragmentListener = l; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_watch_control, container, false); mEditGmailAddr = (EditText) rootView.findViewById(R.id.edit_email_addr);
String defaultAddr = Settings.getInstance(mContext).getGmailAddress();
godstale/retrowatch
RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/connectivity/HttpAsyncTask.java
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // }
import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import com.hardcopy.retrowatchle.utils.Logs; import android.os.AsyncTask;
/* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle.connectivity; public class HttpAsyncTask extends AsyncTask<Void, Integer, String> implements HttpInterface { // Global variables public static final String tag = "HttpAsyncTask"; // private Map<String, String> mMap; // Disabled private int mType; private String mURL = null; private int mResultStatus = MSG_HTTP_RESULT_CODE_OK; private int mRequestType = REQUEST_TYPE_GET; // Context, system private HttpListener mListener; // Constructor public HttpAsyncTask(HttpListener listener, int type, String url, int requestType) { mListener = listener; mType = type; // Not used in async task. will be used in callback mURL = url; mRequestType = requestType; } protected String doInBackground(Void... unused) {
// Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/utils/Logs.java // public class Logs { // // private static final String TAG = "RetroWatch"; // public static boolean mIsEnabled = true; // // // public static void v(String msg) { // if(mIsEnabled) { // Log.v(TAG, msg); // } // } // // public static void v(String tag, String msg) { // if(mIsEnabled) { // Log.v(tag, msg); // } // } // // public static void d(String msg) { // if(mIsEnabled) { // Log.d(TAG, msg); // } // } // // public static void d(String tag, String msg) { // if(mIsEnabled) { // Log.d(tag, msg); // } // } // // public static void e(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void e(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // public static void i(String msg) { // if(mIsEnabled) { // Log.e(TAG, msg); // } // } // // public static void i(String tag, String msg) { // if(mIsEnabled) { // Log.e(tag, msg); // } // } // // } // Path: RetroWatch_Android/RetroWatchLE/src/com/hardcopy/retrowatchle/connectivity/HttpAsyncTask.java import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import com.hardcopy.retrowatchle.utils.Logs; import android.os.AsyncTask; /* * Copyright (C) 2014 The Retro Watch - Open source smart watch project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hardcopy.retrowatchle.connectivity; public class HttpAsyncTask extends AsyncTask<Void, Integer, String> implements HttpInterface { // Global variables public static final String tag = "HttpAsyncTask"; // private Map<String, String> mMap; // Disabled private int mType; private String mURL = null; private int mResultStatus = MSG_HTTP_RESULT_CODE_OK; private int mRequestType = REQUEST_TYPE_GET; // Context, system private HttpListener mListener; // Constructor public HttpAsyncTask(HttpListener listener, int type, String url, int requestType) { mListener = listener; mType = type; // Not used in async task. will be used in callback mURL = url; mRequestType = requestType; } protected String doInBackground(Void... unused) {
Logs.d(tag, "###### HttpAsyncTask :: Starting HTTP request task ");
census-instrumentation/opencensus-java
contrib/log_correlation/stackdriver/src/main/java/io/opencensus/contrib/logcorrelation/stackdriver/OpenCensusTraceLoggingEnhancer.java
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // }
import com.google.cloud.ServiceOptions; import com.google.cloud.logging.LogEntry; import com.google.cloud.logging.LoggingEnhancer; import io.opencensus.trace.Span; import io.opencensus.trace.SpanContext; import io.opencensus.trace.TraceId; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.logging.LogManager; import javax.annotation.Nullable;
@Nullable private static String lookUpProjectId() { String projectIdProperty = lookUpProperty(PROJECT_ID_PROPERTY_NAME); return projectIdProperty == null || projectIdProperty.isEmpty() ? ServiceOptions.getDefaultProjectId() : projectIdProperty; } // An OpenCensusTraceLoggingEnhancer property can be set with a logging property or a system // property. @Nullable private static String lookUpProperty(String name) { String property = LogManager.getLogManager().getProperty(name); return property == null || property.isEmpty() ? System.getProperty(name) : property; } // visible for testing @Nullable String getProjectId() { return projectId; } // This method avoids getting the current span when the feature is disabled, for efficiency. @Override public void enhanceLogEntry(LogEntry.Builder builder) { addTracingData(tracePrefix, getCurrentSpanContext(), builder); } private static SpanContext getCurrentSpanContext() {
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // } // Path: contrib/log_correlation/stackdriver/src/main/java/io/opencensus/contrib/logcorrelation/stackdriver/OpenCensusTraceLoggingEnhancer.java import com.google.cloud.ServiceOptions; import com.google.cloud.logging.LogEntry; import com.google.cloud.logging.LoggingEnhancer; import io.opencensus.trace.Span; import io.opencensus.trace.SpanContext; import io.opencensus.trace.TraceId; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.logging.LogManager; import javax.annotation.Nullable; @Nullable private static String lookUpProjectId() { String projectIdProperty = lookUpProperty(PROJECT_ID_PROPERTY_NAME); return projectIdProperty == null || projectIdProperty.isEmpty() ? ServiceOptions.getDefaultProjectId() : projectIdProperty; } // An OpenCensusTraceLoggingEnhancer property can be set with a logging property or a system // property. @Nullable private static String lookUpProperty(String name) { String property = LogManager.getLogManager().getProperty(name); return property == null || property.isEmpty() ? System.getProperty(name) : property; } // visible for testing @Nullable String getProjectId() { return projectId; } // This method avoids getting the current span when the feature is disabled, for efficiency. @Override public void enhanceLogEntry(LogEntry.Builder builder) { addTracingData(tracePrefix, getCurrentSpanContext(), builder); } private static SpanContext getCurrentSpanContext() {
Span span = ContextHandleUtils.getValue(ContextHandleUtils.currentContext());
census-instrumentation/opencensus-java
api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/ContextManager.java // public interface ContextManager { // // ContextHandle currentContext(); // // ContextHandle withValue(ContextHandle contextHandle, @javax.annotation.Nullable Span span); // // Span getValue(ContextHandle contextHandle); // }
import io.grpc.Context; import io.opencensus.internal.Provider; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.ContextManager; import io.opencensus.trace.Span; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable;
/* * Copyright 2016-17, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace.unsafe; public class ContextHandleUtils { // No instance of this class. private ContextHandleUtils() {} private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName());
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/ContextManager.java // public interface ContextManager { // // ContextHandle currentContext(); // // ContextHandle withValue(ContextHandle contextHandle, @javax.annotation.Nullable Span span); // // Span getValue(ContextHandle contextHandle); // } // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java import io.grpc.Context; import io.opencensus.internal.Provider; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.ContextManager; import io.opencensus.trace.Span; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; /* * Copyright 2016-17, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace.unsafe; public class ContextHandleUtils { // No instance of this class. private ContextHandleUtils() {} private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName());
private static final ContextManager CONTEXT_MANAGER =
census-instrumentation/opencensus-java
api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/ContextManager.java // public interface ContextManager { // // ContextHandle currentContext(); // // ContextHandle withValue(ContextHandle contextHandle, @javax.annotation.Nullable Span span); // // Span getValue(ContextHandle contextHandle); // }
import io.grpc.Context; import io.opencensus.internal.Provider; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.ContextManager; import io.opencensus.trace.Span; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable;
/* * Copyright 2016-17, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace.unsafe; public class ContextHandleUtils { // No instance of this class. private ContextHandleUtils() {} private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); private static final ContextManager CONTEXT_MANAGER = loadContextManager(ContextManager.class.getClassLoader()); private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { try { return Provider.createInstance( Class.forName( "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", /*initialize=*/ true, classLoader), ContextManager.class); } catch (ClassNotFoundException e) { LOGGER.log( Level.FINE, "Couldn't load full implementation for OpenTelemetry context manager, now loading " + "original implementation.", e); } return new ContextManagerImpl(); }
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/ContextManager.java // public interface ContextManager { // // ContextHandle currentContext(); // // ContextHandle withValue(ContextHandle contextHandle, @javax.annotation.Nullable Span span); // // Span getValue(ContextHandle contextHandle); // } // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java import io.grpc.Context; import io.opencensus.internal.Provider; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.ContextManager; import io.opencensus.trace.Span; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; /* * Copyright 2016-17, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace.unsafe; public class ContextHandleUtils { // No instance of this class. private ContextHandleUtils() {} private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); private static final ContextManager CONTEXT_MANAGER = loadContextManager(ContextManager.class.getClassLoader()); private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { try { return Provider.createInstance( Class.forName( "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", /*initialize=*/ true, classLoader), ContextManager.class); } catch (ClassNotFoundException e) { LOGGER.log( Level.FINE, "Couldn't load full implementation for OpenTelemetry context manager, now loading " + "original implementation.", e); } return new ContextManagerImpl(); }
public static ContextHandle currentContext() {
census-instrumentation/opencensus-java
contrib/log_correlation/log4j2/src/main/java/io/opencensus/contrib/logcorrelation/log4j2/ContextDataUtils.java
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // }
import io.opencensus.trace.Span; import io.opencensus.trace.SpanContext; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.Collection; import java.util.List; import javax.annotation.Nullable; import org.apache.logging.log4j.ThreadContext; import org.apache.logging.log4j.core.config.Property; import org.apache.logging.log4j.spi.ReadOnlyThreadContextMap; import org.apache.logging.log4j.util.SortedArrayStringMap; import org.apache.logging.log4j.util.StringMap;
} static StringMap getContextAndTracingData() { SpanContext spanContext = getCurrentSpanContext(); ReadOnlyThreadContextMap context = ThreadContext.getThreadContextMap(); SortedArrayStringMap stringMap; if (context == null) { stringMap = new SortedArrayStringMap(ThreadContext.getImmutableContext()); } else { StringMap contextData = context.getReadOnlyContextData(); stringMap = new SortedArrayStringMap(contextData.size() + 3); stringMap.putAll(contextData); } // TODO(sebright): Move the calls to TraceId.toLowerBase16() and SpanId.toLowerBase16() out of // the critical path by wrapping the trace and span IDs in objects that call toLowerBase16() in // their toString() methods, after there is a fix for // https://github.com/census-instrumentation/opencensus-java/issues/1436. stringMap.putValue( OpenCensusTraceContextDataInjector.TRACE_ID_CONTEXT_KEY, spanContext.getTraceId().toLowerBase16()); stringMap.putValue( OpenCensusTraceContextDataInjector.SPAN_ID_CONTEXT_KEY, spanContext.getSpanId().toLowerBase16()); stringMap.putValue( OpenCensusTraceContextDataInjector.TRACE_SAMPLED_CONTEXT_KEY, spanContext.getTraceOptions().isSampled() ? "true" : "false"); return stringMap; } private static SpanContext getCurrentSpanContext() {
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // } // Path: contrib/log_correlation/log4j2/src/main/java/io/opencensus/contrib/logcorrelation/log4j2/ContextDataUtils.java import io.opencensus.trace.Span; import io.opencensus.trace.SpanContext; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.Collection; import java.util.List; import javax.annotation.Nullable; import org.apache.logging.log4j.ThreadContext; import org.apache.logging.log4j.core.config.Property; import org.apache.logging.log4j.spi.ReadOnlyThreadContextMap; import org.apache.logging.log4j.util.SortedArrayStringMap; import org.apache.logging.log4j.util.StringMap; } static StringMap getContextAndTracingData() { SpanContext spanContext = getCurrentSpanContext(); ReadOnlyThreadContextMap context = ThreadContext.getThreadContextMap(); SortedArrayStringMap stringMap; if (context == null) { stringMap = new SortedArrayStringMap(ThreadContext.getImmutableContext()); } else { StringMap contextData = context.getReadOnlyContextData(); stringMap = new SortedArrayStringMap(contextData.size() + 3); stringMap.putAll(contextData); } // TODO(sebright): Move the calls to TraceId.toLowerBase16() and SpanId.toLowerBase16() out of // the critical path by wrapping the trace and span IDs in objects that call toLowerBase16() in // their toString() methods, after there is a fix for // https://github.com/census-instrumentation/opencensus-java/issues/1436. stringMap.putValue( OpenCensusTraceContextDataInjector.TRACE_ID_CONTEXT_KEY, spanContext.getTraceId().toLowerBase16()); stringMap.putValue( OpenCensusTraceContextDataInjector.SPAN_ID_CONTEXT_KEY, spanContext.getSpanId().toLowerBase16()); stringMap.putValue( OpenCensusTraceContextDataInjector.TRACE_SAMPLED_CONTEXT_KEY, spanContext.getTraceOptions().isSampled() ? "true" : "false"); return stringMap; } private static SpanContext getCurrentSpanContext() {
Span span = ContextHandleUtils.getValue(ContextHandleUtils.currentContext());
census-instrumentation/opencensus-java
api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // }
import io.opencensus.common.Scope; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.concurrent.Callable; import javax.annotation.Nullable;
/* * Copyright 2017, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace; /** Util methods/functionality to interact with the {@link Span} in the {@link io.grpc.Context}. */ final class CurrentSpanUtils { // No instance of this class. private CurrentSpanUtils() {} /** * Returns The {@link Span} from the current context. * * @return The {@code Span} from the current context. */ @Nullable static Span getCurrentSpan() {
// Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // } // Path: api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java import io.opencensus.common.Scope; import io.opencensus.trace.unsafe.ContextHandleUtils; import java.util.concurrent.Callable; import javax.annotation.Nullable; /* * Copyright 2017, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.trace; /** Util methods/functionality to interact with the {@link Span} in the {@link io.grpc.Context}. */ final class CurrentSpanUtils { // No instance of this class. private CurrentSpanUtils() {} /** * Returns The {@link Span} from the current context. * * @return The {@code Span} from the current context. */ @Nullable static Span getCurrentSpan() {
return ContextHandleUtils.getValue(ContextHandleUtils.currentContext());
census-instrumentation/opencensus-java
exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe;
/* * Copyright 2017, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.exporter.stats.stackdriver; /** * Exporter to Stackdriver Monitoring Client API v3. * * <p>Example of usage on Google Cloud VMs: * * <pre><code> * public static void main(String[] args) { * StackdriverStatsExporter.createAndRegister( * StackdriverStatsConfiguration * .builder() * .setProjectId("MyStackdriverProjectId") * .setExportInterval(Duration.fromMillis(100000)) * .build()); * ... // Do work. * } * </code></pre> * * @since 0.9 */ @ThreadSafe public final class StackdriverStatsExporter { @VisibleForTesting static final Object monitor = new Object(); @GuardedBy("monitor") @Nullable private static StackdriverStatsExporter instance = null; @GuardedBy("monitor") @Nullable private static MetricServiceClient metricServiceClient = null; private static final String EXPORTER_SPAN_NAME = "ExportMetricsToStackdriver"; // See io.grpc.internal.GrpcUtil.USER_AGENT_KEY private static final String USER_AGENT_KEY = "user-agent"; private static final String USER_AGENT =
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // } // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; /* * Copyright 2017, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.opencensus.exporter.stats.stackdriver; /** * Exporter to Stackdriver Monitoring Client API v3. * * <p>Example of usage on Google Cloud VMs: * * <pre><code> * public static void main(String[] args) { * StackdriverStatsExporter.createAndRegister( * StackdriverStatsConfiguration * .builder() * .setProjectId("MyStackdriverProjectId") * .setExportInterval(Duration.fromMillis(100000)) * .build()); * ... // Do work. * } * </code></pre> * * @since 0.9 */ @ThreadSafe public final class StackdriverStatsExporter { @VisibleForTesting static final Object monitor = new Object(); @GuardedBy("monitor") @Nullable private static StackdriverStatsExporter instance = null; @GuardedBy("monitor") @Nullable private static MetricServiceClient metricServiceClient = null; private static final String EXPORTER_SPAN_NAME = "ExportMetricsToStackdriver"; // See io.grpc.internal.GrpcUtil.USER_AGENT_KEY private static final String USER_AGENT_KEY = "user-agent"; private static final String USER_AGENT =
"opencensus-java/" + OpenCensusLibraryInformation.VERSION;
census-instrumentation/opencensus-java
exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe;
.setMetricProducerManager( Metrics.getExportComponent().getMetricProducerManager()) .setSpanName(EXPORTER_SPAN_NAME) .build()), intervalMetricReaderOptionsBuilder.build()); } /** * Creates a StackdriverStatsExporter for an explicit project ID and using explicit credentials, * with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter already exists. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId, Duration exportInterval) throws IOException { checkNotNull(credentials, "credentials"); checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); createInternal( credentials, projectId, exportInterval,
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // } // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; .setMetricProducerManager( Metrics.getExportComponent().getMetricProducerManager()) .setSpanName(EXPORTER_SPAN_NAME) .build()), intervalMetricReaderOptionsBuilder.build()); } /** * Creates a StackdriverStatsExporter for an explicit project ID and using explicit credentials, * with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter already exists. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId, Duration exportInterval) throws IOException { checkNotNull(credentials, "credentials"); checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); createInternal( credentials, projectId, exportInterval,
DEFAULT_RESOURCE,
census-instrumentation/opencensus-java
exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe;
intervalMetricReaderOptionsBuilder.build()); } /** * Creates a StackdriverStatsExporter for an explicit project ID and using explicit credentials, * with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter already exists. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId, Duration exportInterval) throws IOException { checkNotNull(credentials, "credentials"); checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); createInternal( credentials, projectId, exportInterval, DEFAULT_RESOURCE, null, null, DEFAULT_CONSTANT_LABELS,
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // } // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; intervalMetricReaderOptionsBuilder.build()); } /** * Creates a StackdriverStatsExporter for an explicit project ID and using explicit credentials, * with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter already exists. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId, Duration exportInterval) throws IOException { checkNotNull(credentials, "credentials"); checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); createInternal( credentials, projectId, exportInterval, DEFAULT_RESOURCE, null, null, DEFAULT_CONSTANT_LABELS,
DEFAULT_DEADLINE,
census-instrumentation/opencensus-java
exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe;
*/ public static void createAndRegister() throws IOException { createAndRegister(StackdriverStatsConfiguration.builder().build()); } /** * Creates a Stackdriver Stats exporter with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * <p>This uses the default application credentials. See {@link * GoogleCredentials#getApplicationDefault}. * * <p>This uses the default project ID configured see {@link ServiceOptions#getDefaultProjectId}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverStatsExporter.createWithProjectId(ServiceOptions.getDefaultProjectId()); * }</pre> * * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter is already created. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegister(Duration exportInterval) throws IOException { checkNotNull(exportInterval, "exportInterval"); checkArgument(
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final Duration DEFAULT_DEADLINE = Duration.create(60, 0); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final String DEFAULT_PROJECT_ID = // Strings.nullToEmpty(ServiceOptions.getDefaultProjectId()); // // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java // static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource(); // // Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java // @ExperimentalApi // public final class OpenCensusLibraryInformation { // // /** // * The current version of the OpenCensus Java library. // * // * @since 0.8 // */ // public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION // // private OpenCensusLibraryInformation() {} // } // Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID; import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE; import com.google.api.MonitoredResource; import com.google.api.gax.core.FixedCredentialsProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.rpc.FixedHeaderProvider; import com.google.api.gax.rpc.HeaderProvider; import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.ServiceOptions; import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.common.annotations.VisibleForTesting; import io.opencensus.common.Duration; import io.opencensus.common.OpenCensusLibraryInformation; import io.opencensus.exporter.metrics.util.IntervalMetricReader; import io.opencensus.exporter.metrics.util.MetricReader; import io.opencensus.metrics.LabelKey; import io.opencensus.metrics.LabelValue; import io.opencensus.metrics.Metrics; import java.io.IOException; import java.util.Map; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; */ public static void createAndRegister() throws IOException { createAndRegister(StackdriverStatsConfiguration.builder().build()); } /** * Creates a Stackdriver Stats exporter with default Monitored Resource. * * <p>Only one Stackdriver exporter can be created. * * <p>This uses the default application credentials. See {@link * GoogleCredentials#getApplicationDefault}. * * <p>This uses the default project ID configured see {@link ServiceOptions#getDefaultProjectId}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverStatsExporter.createWithProjectId(ServiceOptions.getDefaultProjectId()); * }</pre> * * @param exportInterval the interval between pushing stats to StackDriver. * @throws IllegalStateException if a Stackdriver exporter is already created. * @deprecated in favor of {@link #createAndRegister(StackdriverStatsConfiguration)}. * @since 0.9 */ @Deprecated public static void createAndRegister(Duration exportInterval) throws IOException { checkNotNull(exportInterval, "exportInterval"); checkArgument(
!DEFAULT_PROJECT_ID.isEmpty(), "Cannot find a project ID from application default.");
census-instrumentation/opencensus-java
contrib/spring_sleuth_v1x/src/main/java/io/opencensus/contrib/spring/sleuth/v1x/OpenCensusSleuthSpanContextHolder.java
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // }
import io.grpc.Context; import io.opencensus.common.ExperimentalApi; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.unsafe.ContextHandleUtils; import org.apache.commons.logging.Log; import org.springframework.cloud.sleuth.Span; import org.springframework.core.NamedThreadLocal;
interface SpanFunction { void apply(Span span); } private static final SpanFunction NO_OP_FUNCTION = new SpanFunction() { @Override public void apply(Span span) {} }; @SuppressWarnings("CheckReturnValue") private static void setSpanContextInternal(SpanContext spanContext) { CURRENT_SPAN.set(spanContext); spanContext.ocCurrentContext.attach(); } private static boolean isCurrent(Span span) { if (span == null) { return false; } SpanContext currentSpanContext = CURRENT_SPAN.get(); return currentSpanContext != null && span.equals(currentSpanContext.span); } private static class SpanContext { final Span span; final boolean autoClose; @javax.annotation.Nullable final SpanContext parent; final OpenCensusSleuthSpan ocSpan;
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // } // Path: contrib/spring_sleuth_v1x/src/main/java/io/opencensus/contrib/spring/sleuth/v1x/OpenCensusSleuthSpanContextHolder.java import io.grpc.Context; import io.opencensus.common.ExperimentalApi; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.unsafe.ContextHandleUtils; import org.apache.commons.logging.Log; import org.springframework.cloud.sleuth.Span; import org.springframework.core.NamedThreadLocal; interface SpanFunction { void apply(Span span); } private static final SpanFunction NO_OP_FUNCTION = new SpanFunction() { @Override public void apply(Span span) {} }; @SuppressWarnings("CheckReturnValue") private static void setSpanContextInternal(SpanContext spanContext) { CURRENT_SPAN.set(spanContext); spanContext.ocCurrentContext.attach(); } private static boolean isCurrent(Span span) { if (span == null) { return false; } SpanContext currentSpanContext = CURRENT_SPAN.get(); return currentSpanContext != null && span.equals(currentSpanContext.span); } private static class SpanContext { final Span span; final boolean autoClose; @javax.annotation.Nullable final SpanContext parent; final OpenCensusSleuthSpan ocSpan;
final ContextHandle ocCurrentContext;
census-instrumentation/opencensus-java
contrib/spring_sleuth_v1x/src/main/java/io/opencensus/contrib/spring/sleuth/v1x/OpenCensusSleuthSpanContextHolder.java
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // }
import io.grpc.Context; import io.opencensus.common.ExperimentalApi; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.unsafe.ContextHandleUtils; import org.apache.commons.logging.Log; import org.springframework.cloud.sleuth.Span; import org.springframework.core.NamedThreadLocal;
public void apply(Span span) {} }; @SuppressWarnings("CheckReturnValue") private static void setSpanContextInternal(SpanContext spanContext) { CURRENT_SPAN.set(spanContext); spanContext.ocCurrentContext.attach(); } private static boolean isCurrent(Span span) { if (span == null) { return false; } SpanContext currentSpanContext = CURRENT_SPAN.get(); return currentSpanContext != null && span.equals(currentSpanContext.span); } private static class SpanContext { final Span span; final boolean autoClose; @javax.annotation.Nullable final SpanContext parent; final OpenCensusSleuthSpan ocSpan; final ContextHandle ocCurrentContext; private SpanContext(Span span, boolean autoClose) { this.span = span; this.autoClose = autoClose; this.parent = CURRENT_SPAN.get(); this.ocSpan = new OpenCensusSleuthSpan(span); this.ocCurrentContext =
// Path: api/src/main/java/io/opencensus/trace/ContextHandle.java // public interface ContextHandle { // // ContextHandle attach(); // // void detach(ContextHandle contextHandle); // } // // Path: api/src/main/java/io/opencensus/trace/unsafe/ContextHandleUtils.java // public class ContextHandleUtils { // // // No instance of this class. // private ContextHandleUtils() {} // // private static final Logger LOGGER = Logger.getLogger(ContextHandleUtils.class.getName()); // private static final ContextManager CONTEXT_MANAGER = // loadContextManager(ContextManager.class.getClassLoader()); // // private static ContextManager loadContextManager(@Nullable ClassLoader classLoader) { // try { // return Provider.createInstance( // Class.forName( // "io.opentelemetry.opencensusshim.OpenTelemetryContextManager", // /*initialize=*/ true, // classLoader), // ContextManager.class); // } catch (ClassNotFoundException e) { // LOGGER.log( // Level.FINE, // "Couldn't load full implementation for OpenTelemetry context manager, now loading " // + "original implementation.", // e); // } // return new ContextManagerImpl(); // } // // public static ContextHandle currentContext() { // return CONTEXT_MANAGER.currentContext(); // } // // /** // * Creates a new {@code ContextHandle} with the given value set. // * // * @param context the parent {@code ContextHandle}. // * @param span the value to be set. // * @return a new context with the given value set. // */ // public static ContextHandle withValue( // ContextHandle context, @javax.annotation.Nullable Span span) { // return CONTEXT_MANAGER.withValue(context, span); // } // // /** // * Returns the value from the specified {@code ContextHandle}. // * // * @param context the specified {@code ContextHandle}. // * @return the value from the specified {@code ContextHandle}. // */ // public static Span getValue(ContextHandle context) { // return CONTEXT_MANAGER.getValue(context); // } // // /** // * Attempts to pull the {@link io.grpc.Context} out of an OpenCensus {@code ContextHandle}. // * // * @return The context, or null if not a GRPC backed context handle. // */ // @Nullable // public static Context tryExtractGrpcContext(ContextHandle handle) { // if (handle instanceof ContextHandleImpl) { // return ((ContextHandleImpl) handle).getContext(); // } // // TODO: see if we can do something for the OpenTelemetry shim. // return null; // } // } // Path: contrib/spring_sleuth_v1x/src/main/java/io/opencensus/contrib/spring/sleuth/v1x/OpenCensusSleuthSpanContextHolder.java import io.grpc.Context; import io.opencensus.common.ExperimentalApi; import io.opencensus.trace.ContextHandle; import io.opencensus.trace.unsafe.ContextHandleUtils; import org.apache.commons.logging.Log; import org.springframework.cloud.sleuth.Span; import org.springframework.core.NamedThreadLocal; public void apply(Span span) {} }; @SuppressWarnings("CheckReturnValue") private static void setSpanContextInternal(SpanContext spanContext) { CURRENT_SPAN.set(spanContext); spanContext.ocCurrentContext.attach(); } private static boolean isCurrent(Span span) { if (span == null) { return false; } SpanContext currentSpanContext = CURRENT_SPAN.get(); return currentSpanContext != null && span.equals(currentSpanContext.span); } private static class SpanContext { final Span span; final boolean autoClose; @javax.annotation.Nullable final SpanContext parent; final OpenCensusSleuthSpan ocSpan; final ContextHandle ocCurrentContext; private SpanContext(Span span, boolean autoClose) { this.span = span; this.autoClose = autoClose; this.parent = CURRENT_SPAN.get(); this.ocSpan = new OpenCensusSleuthSpan(span); this.ocCurrentContext =
ContextHandleUtils.withValue(ContextHandleUtils.currentContext(), this.ocSpan);
dakotasanchez/farmers-market-finder
app/src/main/java/com/sanchez/fmf/adapter/FavoriteListAdapter.java
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java // public class FavoriteClickEvent { // private final String id; // private final String name; // // public FavoriteClickEvent(String id, String name) { // this.id = id; // this.name = name; // } // // public String getId() { // return id; // } // // public String getName() { // return name; // } // } // // Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java // public class FavoriteRemoveEvent { // private final String id; // // public FavoriteRemoveEvent(String id) { // this.id = id; // } // // public String getId() { // return id; // } // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.FavoriteClickEvent; import com.sanchez.fmf.event.FavoriteRemoveEvent; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus;
package com.sanchez.fmf.adapter; /** * Created by dakota on 9/13/15. */ public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> { private LinkedHashMap<String, String> mDataset; private List<String> mKeys; public FavoriteListAdapter(LinkedHashMap<String, String> dataset) { mDataset = dataset; mKeys = new ArrayList<>(dataset.keySet()); } @Override public FavoriteListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_favorite_market, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added String name = mDataset.get(id); holder.mMarketName.setText(name); holder.mMarketName.setOnClickListener((v) -> {
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java // public class FavoriteClickEvent { // private final String id; // private final String name; // // public FavoriteClickEvent(String id, String name) { // this.id = id; // this.name = name; // } // // public String getId() { // return id; // } // // public String getName() { // return name; // } // } // // Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java // public class FavoriteRemoveEvent { // private final String id; // // public FavoriteRemoveEvent(String id) { // this.id = id; // } // // public String getId() { // return id; // } // } // Path: app/src/main/java/com/sanchez/fmf/adapter/FavoriteListAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.FavoriteClickEvent; import com.sanchez.fmf.event.FavoriteRemoveEvent; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; package com.sanchez.fmf.adapter; /** * Created by dakota on 9/13/15. */ public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> { private LinkedHashMap<String, String> mDataset; private List<String> mKeys; public FavoriteListAdapter(LinkedHashMap<String, String> dataset) { mDataset = dataset; mKeys = new ArrayList<>(dataset.keySet()); } @Override public FavoriteListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_favorite_market, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added String name = mDataset.get(id); holder.mMarketName.setText(name); holder.mMarketName.setOnClickListener((v) -> {
EventBus.getDefault().post(new FavoriteClickEvent(id, name));
dakotasanchez/farmers-market-finder
app/src/main/java/com/sanchez/fmf/adapter/FavoriteListAdapter.java
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java // public class FavoriteClickEvent { // private final String id; // private final String name; // // public FavoriteClickEvent(String id, String name) { // this.id = id; // this.name = name; // } // // public String getId() { // return id; // } // // public String getName() { // return name; // } // } // // Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java // public class FavoriteRemoveEvent { // private final String id; // // public FavoriteRemoveEvent(String id) { // this.id = id; // } // // public String getId() { // return id; // } // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.FavoriteClickEvent; import com.sanchez.fmf.event.FavoriteRemoveEvent; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus;
package com.sanchez.fmf.adapter; /** * Created by dakota on 9/13/15. */ public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> { private LinkedHashMap<String, String> mDataset; private List<String> mKeys; public FavoriteListAdapter(LinkedHashMap<String, String> dataset) { mDataset = dataset; mKeys = new ArrayList<>(dataset.keySet()); } @Override public FavoriteListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_favorite_market, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added String name = mDataset.get(id); holder.mMarketName.setText(name); holder.mMarketName.setOnClickListener((v) -> { EventBus.getDefault().post(new FavoriteClickEvent(id, name)); }); holder.mMarketRemove.setOnClickListener((v) -> {
// Path: app/src/main/java/com/sanchez/fmf/event/FavoriteClickEvent.java // public class FavoriteClickEvent { // private final String id; // private final String name; // // public FavoriteClickEvent(String id, String name) { // this.id = id; // this.name = name; // } // // public String getId() { // return id; // } // // public String getName() { // return name; // } // } // // Path: app/src/main/java/com/sanchez/fmf/event/FavoriteRemoveEvent.java // public class FavoriteRemoveEvent { // private final String id; // // public FavoriteRemoveEvent(String id) { // this.id = id; // } // // public String getId() { // return id; // } // } // Path: app/src/main/java/com/sanchez/fmf/adapter/FavoriteListAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.FavoriteClickEvent; import com.sanchez.fmf.event.FavoriteRemoveEvent; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; package com.sanchez.fmf.adapter; /** * Created by dakota on 9/13/15. */ public class FavoriteListAdapter extends RecyclerView.Adapter<FavoriteListAdapter.ViewHolder> { private LinkedHashMap<String, String> mDataset; private List<String> mKeys; public FavoriteListAdapter(LinkedHashMap<String, String> dataset) { mDataset = dataset; mKeys = new ArrayList<>(dataset.keySet()); } @Override public FavoriteListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_favorite_market, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { String id = mKeys.get(mKeys.size() - position - 1); // Sort list by most recently added String name = mDataset.get(id); holder.mMarketName.setText(name); holder.mMarketName.setOnClickListener((v) -> { EventBus.getDefault().post(new FavoriteClickEvent(id, name)); }); holder.mMarketRemove.setOnClickListener((v) -> {
EventBus.getDefault().post(new FavoriteRemoveEvent(id));
dakotasanchez/farmers-market-finder
app/src/main/java/com/sanchez/fmf/service/MarketService.java
// Path: app/src/main/java/com/sanchez/fmf/model/MarketDetailResponseModel.java // public class MarketDetailResponseModel { // // private MarketDetailModel market; // // public MarketDetailResponseModel() {} // // public MarketDetailModel getMarketdetails() { // return this.market; // } // // public void setMarketdetails(MarketDetailModel market) { // this.market = market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListResponseModel.java // public class MarketListResponseModel { // // private List<MarketListItemModel> markets; // // public MarketListResponseModel() {} // // public List<MarketListItemModel> getMarkets() { // return this.markets; // } // // public void setMarkets(List<MarketListItemModel> markets) { // this.markets = markets; // } // }
import com.sanchez.fmf.model.MarketDetailResponseModel; import com.sanchez.fmf.model.MarketListResponseModel; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Query;
package com.sanchez.fmf.service; /** * Created by dakota on 9/2/15. */ public interface MarketService { @GET("/api/v1/markets")
// Path: app/src/main/java/com/sanchez/fmf/model/MarketDetailResponseModel.java // public class MarketDetailResponseModel { // // private MarketDetailModel market; // // public MarketDetailResponseModel() {} // // public MarketDetailModel getMarketdetails() { // return this.market; // } // // public void setMarketdetails(MarketDetailModel market) { // this.market = market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListResponseModel.java // public class MarketListResponseModel { // // private List<MarketListItemModel> markets; // // public MarketListResponseModel() {} // // public List<MarketListItemModel> getMarkets() { // return this.markets; // } // // public void setMarkets(List<MarketListItemModel> markets) { // this.markets = markets; // } // } // Path: app/src/main/java/com/sanchez/fmf/service/MarketService.java import com.sanchez.fmf.model.MarketDetailResponseModel; import com.sanchez.fmf.model.MarketListResponseModel; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Query; package com.sanchez.fmf.service; /** * Created by dakota on 9/2/15. */ public interface MarketService { @GET("/api/v1/markets")
void getMarkets(@Query("x") double lng, @Query("y") double lat, @Query("dist") double distance, Callback<MarketListResponseModel> cb);
dakotasanchez/farmers-market-finder
app/src/main/java/com/sanchez/fmf/service/MarketService.java
// Path: app/src/main/java/com/sanchez/fmf/model/MarketDetailResponseModel.java // public class MarketDetailResponseModel { // // private MarketDetailModel market; // // public MarketDetailResponseModel() {} // // public MarketDetailModel getMarketdetails() { // return this.market; // } // // public void setMarketdetails(MarketDetailModel market) { // this.market = market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListResponseModel.java // public class MarketListResponseModel { // // private List<MarketListItemModel> markets; // // public MarketListResponseModel() {} // // public List<MarketListItemModel> getMarkets() { // return this.markets; // } // // public void setMarkets(List<MarketListItemModel> markets) { // this.markets = markets; // } // }
import com.sanchez.fmf.model.MarketDetailResponseModel; import com.sanchez.fmf.model.MarketListResponseModel; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Query;
package com.sanchez.fmf.service; /** * Created by dakota on 9/2/15. */ public interface MarketService { @GET("/api/v1/markets") void getMarkets(@Query("x") double lng, @Query("y") double lat, @Query("dist") double distance, Callback<MarketListResponseModel> cb); @GET("/api/v1/market")
// Path: app/src/main/java/com/sanchez/fmf/model/MarketDetailResponseModel.java // public class MarketDetailResponseModel { // // private MarketDetailModel market; // // public MarketDetailResponseModel() {} // // public MarketDetailModel getMarketdetails() { // return this.market; // } // // public void setMarketdetails(MarketDetailModel market) { // this.market = market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListResponseModel.java // public class MarketListResponseModel { // // private List<MarketListItemModel> markets; // // public MarketListResponseModel() {} // // public List<MarketListItemModel> getMarkets() { // return this.markets; // } // // public void setMarkets(List<MarketListItemModel> markets) { // this.markets = markets; // } // } // Path: app/src/main/java/com/sanchez/fmf/service/MarketService.java import com.sanchez.fmf.model.MarketDetailResponseModel; import com.sanchez.fmf.model.MarketListResponseModel; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Query; package com.sanchez.fmf.service; /** * Created by dakota on 9/2/15. */ public interface MarketService { @GET("/api/v1/markets") void getMarkets(@Query("x") double lng, @Query("y") double lat, @Query("dist") double distance, Callback<MarketListResponseModel> cb); @GET("/api/v1/market")
void getMarket(@Query("id") String id, Callback<MarketDetailResponseModel> cb);
dakotasanchez/farmers-market-finder
app/src/main/java/com/sanchez/fmf/adapter/MarketListAdapter.java
// Path: app/src/main/java/com/sanchez/fmf/event/MarketClickEvent.java // public class MarketClickEvent { // private final View market; // // public MarketClickEvent(View market) { // this.market = market; // } // // public View getMarket() { // return market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListItemModel.java // public class MarketListItemModel { // // private String fmid; // private String market_name; // private String distance; // private String uri; // private double x; // private double y; // // public MarketListItemModel() { // } // // public String getId() { // return fmid; // } // // public void setId(String id) { // this.fmid = fmid; // } // // public String getName() { // return market_name; // } // // public void setName(String market_name) { // this.market_name = market_name; // } // // // public String getDistance() { // return distance; // } // // public void setDistance(String distance) { // this.distance = distance; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // public double getX() { // return x; // } // // public void setX(double x) { // this.x = x; // } // // public double getY() { // return y; // } // // public void setY(double y) { // this.y = y; // } // } // // Path: app/src/main/java/com/sanchez/fmf/util/MarketUtils.java // public class MarketUtils { // // private static final Random RANDOM = new Random(); // // // Non-instantiatable class // private MarketUtils() { // } // // public static double haversine(double lat1, double lon1, double lat2, double lon2) { // double dLat = Math.toRadians(lat2 - lat1); // double dLon = Math.toRadians(lon2 - lon1); // lat1 = Math.toRadians(lat1); // lat2 = Math.toRadians(lat2); // // double a = Math.pow(Math.sin(dLat / 2),2) + Math.pow(Math.sin(dLon / 2),2) * Math.cos(lat1) * Math.cos(lat2); // double c = 2 * Math.asin(Math.sqrt(a)); // double radius = 3959; // miles // return radius * c; // } // // public static int getRandomMarketColor() { // // switch (RANDOM.nextInt(5)) { // default: // case 0: // return R.color.market_blue; // case 1: // return R.color.market_red; // case 2: // return R.color.market_green; // case 3: // return R.color.market_orange; // case 4: // return R.color.market_pink; // } // } // // public static int getRandomMarketDrawable() { // switch (RANDOM.nextInt(4)) { // default: // case 0: // return R.drawable.market_1; // case 1: // return R.drawable.market_2; // case 2: // return R.drawable.market_3; // case 3: // return R.drawable.market_4; // } // } // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.MarketClickEvent; import com.sanchez.fmf.model.MarketListItemModel; import com.sanchez.fmf.util.MarketUtils; import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus;
package com.sanchez.fmf.adapter; public class MarketListAdapter extends RecyclerView.Adapter<MarketListAdapter.ViewHolder> { private ArrayList<MarketListItemModel> mDataset; private boolean mDisplayDistance; public MarketListAdapter(ArrayList<MarketListItemModel> dataset, boolean displayDistance) { mDataset = dataset; mDisplayDistance = displayDistance; } // Create new views (invoked by the layout manager) @Override public MarketListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_card_market, parent, false);
// Path: app/src/main/java/com/sanchez/fmf/event/MarketClickEvent.java // public class MarketClickEvent { // private final View market; // // public MarketClickEvent(View market) { // this.market = market; // } // // public View getMarket() { // return market; // } // } // // Path: app/src/main/java/com/sanchez/fmf/model/MarketListItemModel.java // public class MarketListItemModel { // // private String fmid; // private String market_name; // private String distance; // private String uri; // private double x; // private double y; // // public MarketListItemModel() { // } // // public String getId() { // return fmid; // } // // public void setId(String id) { // this.fmid = fmid; // } // // public String getName() { // return market_name; // } // // public void setName(String market_name) { // this.market_name = market_name; // } // // // public String getDistance() { // return distance; // } // // public void setDistance(String distance) { // this.distance = distance; // } // // public String getUri() { // return uri; // } // // public void setUri(String uri) { // this.uri = uri; // } // // public double getX() { // return x; // } // // public void setX(double x) { // this.x = x; // } // // public double getY() { // return y; // } // // public void setY(double y) { // this.y = y; // } // } // // Path: app/src/main/java/com/sanchez/fmf/util/MarketUtils.java // public class MarketUtils { // // private static final Random RANDOM = new Random(); // // // Non-instantiatable class // private MarketUtils() { // } // // public static double haversine(double lat1, double lon1, double lat2, double lon2) { // double dLat = Math.toRadians(lat2 - lat1); // double dLon = Math.toRadians(lon2 - lon1); // lat1 = Math.toRadians(lat1); // lat2 = Math.toRadians(lat2); // // double a = Math.pow(Math.sin(dLat / 2),2) + Math.pow(Math.sin(dLon / 2),2) * Math.cos(lat1) * Math.cos(lat2); // double c = 2 * Math.asin(Math.sqrt(a)); // double radius = 3959; // miles // return radius * c; // } // // public static int getRandomMarketColor() { // // switch (RANDOM.nextInt(5)) { // default: // case 0: // return R.color.market_blue; // case 1: // return R.color.market_red; // case 2: // return R.color.market_green; // case 3: // return R.color.market_orange; // case 4: // return R.color.market_pink; // } // } // // public static int getRandomMarketDrawable() { // switch (RANDOM.nextInt(4)) { // default: // case 0: // return R.drawable.market_1; // case 1: // return R.drawable.market_2; // case 2: // return R.drawable.market_3; // case 3: // return R.drawable.market_4; // } // } // } // Path: app/src/main/java/com/sanchez/fmf/adapter/MarketListAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.sanchez.fmf.R; import com.sanchez.fmf.event.MarketClickEvent; import com.sanchez.fmf.model.MarketListItemModel; import com.sanchez.fmf.util.MarketUtils; import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; import de.greenrobot.event.EventBus; package com.sanchez.fmf.adapter; public class MarketListAdapter extends RecyclerView.Adapter<MarketListAdapter.ViewHolder> { private ArrayList<MarketListItemModel> mDataset; private boolean mDisplayDistance; public MarketListAdapter(ArrayList<MarketListItemModel> dataset, boolean displayDistance) { mDataset = dataset; mDisplayDistance = displayDistance; } // Create new views (invoked by the layout manager) @Override public MarketListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.row_card_market, parent, false);
view.setOnClickListener((v) -> EventBus.getDefault().post(new MarketClickEvent(v)));
karsany/obridge
obridge-main/src/test/java/org/obridge/generators/EntityObjectGeneratorTest.java
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // }
import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; import java.sql.SQLException;
package org.obridge.generators; public class EntityObjectGeneratorTest extends BaseTest { @Test public void testGenerate() throws IOException, PropertyVetoException, SQLException {
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // } // Path: obridge-main/src/test/java/org/obridge/generators/EntityObjectGeneratorTest.java import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; import java.sql.SQLException; package org.obridge.generators; public class EntityObjectGeneratorTest extends BaseTest { @Test public void testGenerate() throws IOException, PropertyVetoException, SQLException {
OBridgeConfiguration c = new OBridgeConfiguration();
karsany/obridge
obridge-main/src/test/java/org/obridge/generators/EntityObjectGeneratorTest.java
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // }
import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; import java.sql.SQLException;
package org.obridge.generators; public class EntityObjectGeneratorTest extends BaseTest { @Test public void testGenerate() throws IOException, PropertyVetoException, SQLException { OBridgeConfiguration c = new OBridgeConfiguration(); c.setJdbcUrl(connectionString); c.setSourceRoot(File.createTempFile("ObjectGenerator", Long.toString(System.nanoTime())).getParentFile().toString()); c.setRootPackageName("hu.obridge.test");
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // } // Path: obridge-main/src/test/java/org/obridge/generators/EntityObjectGeneratorTest.java import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; import java.sql.SQLException; package org.obridge.generators; public class EntityObjectGeneratorTest extends BaseTest { @Test public void testGenerate() throws IOException, PropertyVetoException, SQLException { OBridgeConfiguration c = new OBridgeConfiguration(); c.setJdbcUrl(connectionString); c.setSourceRoot(File.createTempFile("ObjectGenerator", Long.toString(System.nanoTime())).getParentFile().toString()); c.setRootPackageName("hu.obridge.test");
c.setPackages(new Packages());
karsany/obridge
obridge-main/src/test/java/org/obridge/util/XStreamFactoryTest.java
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // }
import com.thoughtworks.xstream.XStream; import org.junit.Assert; import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge.util; /** * @author fkarsany */ public class XStreamFactoryTest extends BaseTest { /** * Test of createXStream method, of class XStreamFactory. */ @Test public void testCreateXStream() throws IOException { XStream x = XStreamFactory.createXStream();
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // } // Path: obridge-main/src/test/java/org/obridge/util/XStreamFactoryTest.java import com.thoughtworks.xstream.XStream; import org.junit.Assert; import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge.util; /** * @author fkarsany */ public class XStreamFactoryTest extends BaseTest { /** * Test of createXStream method, of class XStreamFactory. */ @Test public void testCreateXStream() throws IOException { XStream x = XStreamFactory.createXStream();
OBridgeConfiguration obc = new OBridgeConfiguration();
karsany/obridge
obridge-main/src/test/java/org/obridge/util/XStreamFactoryTest.java
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // }
import com.thoughtworks.xstream.XStream; import org.junit.Assert; import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge.util; /** * @author fkarsany */ public class XStreamFactoryTest extends BaseTest { /** * Test of createXStream method, of class XStreamFactory. */ @Test public void testCreateXStream() throws IOException { XStream x = XStreamFactory.createXStream(); OBridgeConfiguration obc = new OBridgeConfiguration(); obc.setJdbcUrl(connectionString); obc.setSourceRoot(File.createTempFile("ObjectGenerator", Long.toString(System.nanoTime())).getParentFile().toString()); obc.setRootPackageName("hu.obridge.test");
// Path: obridge-main/src/test/java/org/obridge/BaseTest.java // public abstract class BaseTest { // // private static boolean flywayInitialized = false; // protected OracleDataSource ds; // protected String connectionString; // private Properties p; // // @Before // public void init() throws IOException, SQLException { // if (ds == null) { // p = new Properties(); // p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties")); // connectionString = p.getProperty("connectionString"); // ds = new OracleDataSource(); // ds.setURL(connectionString); // } // // if (!flywayInitialized) { // Flyway load = Flyway.configure().dataSource(this.ds).load(); // load.clean(); // load.migrate(); // flywayInitialized = true; // } // // } // // } // // Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // } // Path: obridge-main/src/test/java/org/obridge/util/XStreamFactoryTest.java import com.thoughtworks.xstream.XStream; import org.junit.Assert; import org.junit.Test; import org.obridge.BaseTest; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge.util; /** * @author fkarsany */ public class XStreamFactoryTest extends BaseTest { /** * Test of createXStream method, of class XStreamFactory. */ @Test public void testCreateXStream() throws IOException { XStream x = XStreamFactory.createXStream(); OBridgeConfiguration obc = new OBridgeConfiguration(); obc.setJdbcUrl(connectionString); obc.setSourceRoot(File.createTempFile("ObjectGenerator", Long.toString(System.nanoTime())).getParentFile().toString()); obc.setRootPackageName("hu.obridge.test");
obc.setPackages(new Packages());
karsany/obridge
obridge-main/src/main/java/org/obridge/model/data/Type.java
// Path: obridge-main/src/main/java/org/obridge/util/StringHelper.java // public final class StringHelper { // // private static Set<String> javaKeywords = new HashSet<>(Arrays.asList("abstract", "continue", "for", "new", // "switch", "assert", "default", "goto", "package", "synchronized", // "boolean", "do", "if", "private", "this", "break", "double", // "implements", "protected", "throw", "byte", "else", "import", // "public", "throws", "case", "enum", "instanceof", "return", // "transient", "catch", "extends", "int", "short", "try", "char", // "final", "interface", "static", "void", "class", "finally", "long", // "strictfp", "volatile", "const", "float", "native", "super", "while")); // // private StringHelper() { // } // // public static String toCamelCase(String s) { // if (s == null) { // return ""; // } // return WordUtils.capitalizeFully(s, ' ', '_').replaceAll(" ", "").replaceAll("_", ""); // } // // public static String toCamelCaseSmallBegin(String s) { // if (s == null) { // return ""; // } // String ss = toCamelCase(s); // return ss.substring(0, 1).toLowerCase() + ss.substring(1); // } // // public static String toOracleName(String s) { // StringBuilder result = new StringBuilder(); // String currChar; // if (s != null && !s.isEmpty()) { // for (int i = 0; i < s.length(); i++) { // currChar = s.substring(i, i + 1); // if (i != 0 && StringUtils.isAllUpperCase(currChar)) { // result.append("_" + currChar); // } else { // result.append(currChar); // } // } // } // return result.toString().toUpperCase().replaceAll("\\_\\_", "_"); // } // // public static boolean isJavaKeyword(String s) { // return javaKeywords.contains(s.toLowerCase()); // } // // public static String unJavaKeyword(String s) { // if (isJavaKeyword(s)) { // return "p" + s.substring(0, 1).toUpperCase() + s.substring(1); // } // return s; // } // // }
import org.obridge.util.StringHelper; import java.util.List;
/* * The MIT License (MIT) * * Copyright (c) 2016 Ferenc Karsany * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.obridge.model.data; /** * Created by fkarsany on 2015.01.11.. */ public class Type { private String typeName; private List<TypeAttribute> attributeList; private String converterPackageName; private String objectPackage; public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public List<TypeAttribute> getAttributeList() { return attributeList; } public void setAttributeList(List<TypeAttribute> attributeList) { this.attributeList = attributeList; } public String getJavaClassName() {
// Path: obridge-main/src/main/java/org/obridge/util/StringHelper.java // public final class StringHelper { // // private static Set<String> javaKeywords = new HashSet<>(Arrays.asList("abstract", "continue", "for", "new", // "switch", "assert", "default", "goto", "package", "synchronized", // "boolean", "do", "if", "private", "this", "break", "double", // "implements", "protected", "throw", "byte", "else", "import", // "public", "throws", "case", "enum", "instanceof", "return", // "transient", "catch", "extends", "int", "short", "try", "char", // "final", "interface", "static", "void", "class", "finally", "long", // "strictfp", "volatile", "const", "float", "native", "super", "while")); // // private StringHelper() { // } // // public static String toCamelCase(String s) { // if (s == null) { // return ""; // } // return WordUtils.capitalizeFully(s, ' ', '_').replaceAll(" ", "").replaceAll("_", ""); // } // // public static String toCamelCaseSmallBegin(String s) { // if (s == null) { // return ""; // } // String ss = toCamelCase(s); // return ss.substring(0, 1).toLowerCase() + ss.substring(1); // } // // public static String toOracleName(String s) { // StringBuilder result = new StringBuilder(); // String currChar; // if (s != null && !s.isEmpty()) { // for (int i = 0; i < s.length(); i++) { // currChar = s.substring(i, i + 1); // if (i != 0 && StringUtils.isAllUpperCase(currChar)) { // result.append("_" + currChar); // } else { // result.append(currChar); // } // } // } // return result.toString().toUpperCase().replaceAll("\\_\\_", "_"); // } // // public static boolean isJavaKeyword(String s) { // return javaKeywords.contains(s.toLowerCase()); // } // // public static String unJavaKeyword(String s) { // if (isJavaKeyword(s)) { // return "p" + s.substring(0, 1).toUpperCase() + s.substring(1); // } // return s; // } // // } // Path: obridge-main/src/main/java/org/obridge/model/data/Type.java import org.obridge.util.StringHelper; import java.util.List; /* * The MIT License (MIT) * * Copyright (c) 2016 Ferenc Karsany * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.obridge.model.data; /** * Created by fkarsany on 2015.01.11.. */ public class Type { private String typeName; private List<TypeAttribute> attributeList; private String converterPackageName; private String objectPackage; public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public List<TypeAttribute> getAttributeList() { return attributeList; } public void setAttributeList(List<TypeAttribute> attributeList) { this.attributeList = attributeList; } public String getJavaClassName() {
return StringHelper.toCamelCase(typeName);
karsany/obridge
obridge-main/src/main/java/org/obridge/model/data/OraclePackage.java
// Path: obridge-main/src/main/java/org/obridge/util/StringHelper.java // public final class StringHelper { // // private static Set<String> javaKeywords = new HashSet<>(Arrays.asList("abstract", "continue", "for", "new", // "switch", "assert", "default", "goto", "package", "synchronized", // "boolean", "do", "if", "private", "this", "break", "double", // "implements", "protected", "throw", "byte", "else", "import", // "public", "throws", "case", "enum", "instanceof", "return", // "transient", "catch", "extends", "int", "short", "try", "char", // "final", "interface", "static", "void", "class", "finally", "long", // "strictfp", "volatile", "const", "float", "native", "super", "while")); // // private StringHelper() { // } // // public static String toCamelCase(String s) { // if (s == null) { // return ""; // } // return WordUtils.capitalizeFully(s, ' ', '_').replaceAll(" ", "").replaceAll("_", ""); // } // // public static String toCamelCaseSmallBegin(String s) { // if (s == null) { // return ""; // } // String ss = toCamelCase(s); // return ss.substring(0, 1).toLowerCase() + ss.substring(1); // } // // public static String toOracleName(String s) { // StringBuilder result = new StringBuilder(); // String currChar; // if (s != null && !s.isEmpty()) { // for (int i = 0; i < s.length(); i++) { // currChar = s.substring(i, i + 1); // if (i != 0 && StringUtils.isAllUpperCase(currChar)) { // result.append("_" + currChar); // } else { // result.append(currChar); // } // } // } // return result.toString().toUpperCase().replaceAll("\\_\\_", "_"); // } // // public static boolean isJavaKeyword(String s) { // return javaKeywords.contains(s.toLowerCase()); // } // // public static String unJavaKeyword(String s) { // if (isJavaKeyword(s)) { // return "p" + s.substring(0, 1).toUpperCase() + s.substring(1); // } // return s; // } // // }
import org.obridge.util.StringHelper; import java.util.List;
/* * The MIT License (MIT) * * Copyright (c) 2016 Ferenc Karsany * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.obridge.model.data; /** * Created by fkarsany on 2015.01.05.. */ public class OraclePackage { private String name; private List<Procedure> procedureList; private String javaPackageName; private String contextPackage; private String converterPackage; private String objectPackage; private String loggingInitializer; private String loggingMethod; public List<Procedure> getProcedureList() { return procedureList; } public void setProcedureList(List<Procedure> procedureList) { this.procedureList = procedureList; } public void setName(String name) { this.name = name; } public String getJavaClassName() {
// Path: obridge-main/src/main/java/org/obridge/util/StringHelper.java // public final class StringHelper { // // private static Set<String> javaKeywords = new HashSet<>(Arrays.asList("abstract", "continue", "for", "new", // "switch", "assert", "default", "goto", "package", "synchronized", // "boolean", "do", "if", "private", "this", "break", "double", // "implements", "protected", "throw", "byte", "else", "import", // "public", "throws", "case", "enum", "instanceof", "return", // "transient", "catch", "extends", "int", "short", "try", "char", // "final", "interface", "static", "void", "class", "finally", "long", // "strictfp", "volatile", "const", "float", "native", "super", "while")); // // private StringHelper() { // } // // public static String toCamelCase(String s) { // if (s == null) { // return ""; // } // return WordUtils.capitalizeFully(s, ' ', '_').replaceAll(" ", "").replaceAll("_", ""); // } // // public static String toCamelCaseSmallBegin(String s) { // if (s == null) { // return ""; // } // String ss = toCamelCase(s); // return ss.substring(0, 1).toLowerCase() + ss.substring(1); // } // // public static String toOracleName(String s) { // StringBuilder result = new StringBuilder(); // String currChar; // if (s != null && !s.isEmpty()) { // for (int i = 0; i < s.length(); i++) { // currChar = s.substring(i, i + 1); // if (i != 0 && StringUtils.isAllUpperCase(currChar)) { // result.append("_" + currChar); // } else { // result.append(currChar); // } // } // } // return result.toString().toUpperCase().replaceAll("\\_\\_", "_"); // } // // public static boolean isJavaKeyword(String s) { // return javaKeywords.contains(s.toLowerCase()); // } // // public static String unJavaKeyword(String s) { // if (isJavaKeyword(s)) { // return "p" + s.substring(0, 1).toUpperCase() + s.substring(1); // } // return s; // } // // } // Path: obridge-main/src/main/java/org/obridge/model/data/OraclePackage.java import org.obridge.util.StringHelper; import java.util.List; /* * The MIT License (MIT) * * Copyright (c) 2016 Ferenc Karsany * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.obridge.model.data; /** * Created by fkarsany on 2015.01.05.. */ public class OraclePackage { private String name; private List<Procedure> procedureList; private String javaPackageName; private String contextPackage; private String converterPackage; private String objectPackage; private String loggingInitializer; private String loggingMethod; public List<Procedure> getProcedureList() { return procedureList; } public void setProcedureList(List<Procedure> procedureList) { this.procedureList = procedureList; } public void setName(String name) { this.name = name; } public String getJavaClassName() {
return StringHelper.toCamelCase(name);
karsany/obridge
obridge-main/src/test/java/org/obridge/OBridgeTest.java
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // }
import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException; import java.util.Properties;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge; /** * @author fkarsany */ public class OBridgeTest { @Rule public TemporaryFolder tempdir = new TemporaryFolder(); public OBridgeTest() { } @Test public void testMain() { OBridge.main("-h"); OBridge.main("-v"); } @Test public void fullTest() throws IOException, InterruptedException { Properties p = new Properties(); p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties"));
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java // public class OBridgeConfiguration { // // public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false; // public static final boolean ADD_ASSERT = false; // // private String jdbcUrl; // private String sourceRoot; // private String rootPackageName; // private Packages packages; // private Logging logging; // private String packagesLike; // private String sourceOwner; // private String projectName; // private String sourcesTableProc; // private String sourcesTable; // // public String getPackagesLike() { // if (packagesLike == null) { // return "%"; // } // return packagesLike; // } // // public void setPackagesLike(String packagesLike) { // this.packagesLike = packagesLike; // } // // public String getSourceOwner() { // return sourceOwner; // } // // public void setSourceOwner(String sourceOwner) { // this.sourceOwner = sourceOwner; // } // // public String getJdbcUrl() { // return jdbcUrl; // } // // public void setJdbcUrl(String jdbcUrl) { // this.jdbcUrl = jdbcUrl; // } // // public String getSourceRoot() { // return sourceRoot; // } // // public void setSourceRoot(String sourceRoot) { // this.sourceRoot = sourceRoot; // } // // public String getRootPackageName() { // return rootPackageName; // } // // public void setRootPackageName(String rootPackageName) { // this.rootPackageName = rootPackageName; // } // // public Packages getPackages() { // return packages; // } // // public void setPackages(Packages packages) { // this.packages = packages; // } // // public Logging getLogging() { // return logging; // } // // public void setLogging(Logging logging) { // this.logging = logging; // } // // public String getSourcesTable() { // return sourcesTable; // } // // public void setSourcesTable(String sourcesTable) { // this.sourcesTable = sourcesTable; // } // // public String getSourcesTableProc() { // return sourcesTableProc; // } // // public String getProjectName() { return projectName == null ? "default": projectName; } // // public void setProjectName(String projectName) { this.projectName = projectName; } // } // // Path: obridge-main/src/main/java/org/obridge/context/Packages.java // public class Packages { // // private String entityObjects = "objects"; // private String converterObjects = "converters"; // private String procedureContextObjects = "context"; // private String packageObjects = "packages"; // // public String getEntityObjects() { // return entityObjects; // } // // public void setEntityObjects(String entityObjects) { // this.entityObjects = entityObjects; // } // // public String getConverterObjects() { // return converterObjects; // } // // public void setConverterObjects(String converterObjects) { // this.converterObjects = converterObjects; // } // // public String getProcedureContextObjects() { // return procedureContextObjects; // } // // public void setProcedureContextObjects(String procedureContextObjects) { // this.procedureContextObjects = procedureContextObjects; // } // // public String getPackageObjects() { // return packageObjects; // } // // public void setPackageObjects(String packageObjects) { // this.packageObjects = packageObjects; // } // // } // Path: obridge-main/src/test/java/org/obridge/OBridgeTest.java import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.obridge.context.OBridgeConfiguration; import org.obridge.context.Packages; import java.io.File; import java.io.IOException; import java.util.Properties; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.obridge; /** * @author fkarsany */ public class OBridgeTest { @Rule public TemporaryFolder tempdir = new TemporaryFolder(); public OBridgeTest() { } @Test public void testMain() { OBridge.main("-h"); OBridge.main("-v"); } @Test public void fullTest() throws IOException, InterruptedException { Properties p = new Properties(); p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties"));
OBridgeConfiguration oBridgeConfiguration = new OBridgeConfiguration();