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
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/impl/MultiLayerNetworkSaverImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.deeplearning4j.util.ModelSerializer; import javax.inject.Inject; import java.io.File; import java.io.IOException;
package net.scaliby.ceidgcaptcha.machinelearning.common.impl; @Log4j public class MultiLayerNetworkSaverImpl implements MultiLayerNetworkSaver {
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/impl/MultiLayerNetworkSaverImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.deeplearning4j.util.ModelSerializer; import javax.inject.Inject; import java.io.File; import java.io.IOException; package net.scaliby.ceidgcaptcha.machinelearning.common.impl; @Log4j public class MultiLayerNetworkSaverImpl implements MultiLayerNetworkSaver {
private final StoreChooser storeChooser;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/impl/MultiLayerNetworkSaverImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.deeplearning4j.util.ModelSerializer; import javax.inject.Inject; import java.io.File; import java.io.IOException;
package net.scaliby.ceidgcaptcha.machinelearning.common.impl; @Log4j public class MultiLayerNetworkSaverImpl implements MultiLayerNetworkSaver { private final StoreChooser storeChooser; @Inject public MultiLayerNetworkSaverImpl(StoreChooser storeChooser) { this.storeChooser = storeChooser; } @Override public void save(MultiLayerNetwork network) { log.info("Select where you wanna save network"); storeChooser.getDirectory().ifPresent(store -> { try { ModelSerializer.writeModel(network, new File(store + File.separator + "network.zip"), false); } catch (IOException e) {
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/impl/MultiLayerNetworkSaverImpl.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.deeplearning4j.util.ModelSerializer; import javax.inject.Inject; import java.io.File; import java.io.IOException; package net.scaliby.ceidgcaptcha.machinelearning.common.impl; @Log4j public class MultiLayerNetworkSaverImpl implements MultiLayerNetworkSaver { private final StoreChooser storeChooser; @Inject public MultiLayerNetworkSaverImpl(StoreChooser storeChooser) { this.storeChooser = storeChooser; } @Override public void save(MultiLayerNetwork network) { log.info("Select where you wanna save network"); storeChooser.getDirectory().ifPresent(store -> { try { ModelSerializer.writeModel(network, new File(store + File.separator + "network.zip"), false); } catch (IOException e) {
throw new ImageStoreException(e);
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/impl/CEIDGCaptchaPredictionServiceImpl.java
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/MultiLayerNetworkLoader.java // public interface MultiLayerNetworkLoader { // // MultiLayerNetwork load(); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/OutputLabeler.java // public interface OutputLabeler { // // String getLabel(INDArray output); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // }
import net.scaliby.ceidgcaptcha.rest.common.MultiLayerNetworkLoader; import net.scaliby.ceidgcaptcha.rest.common.OutputLabeler; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage;
package net.scaliby.ceidgcaptcha.rest.service.impl; public class CEIDGCaptchaPredictionServiceImpl implements CEIDGCaptchaPredictionService { private final MultiLayerNetworkLoader multiLayerNetworkLoader;
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/MultiLayerNetworkLoader.java // public interface MultiLayerNetworkLoader { // // MultiLayerNetwork load(); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/OutputLabeler.java // public interface OutputLabeler { // // String getLabel(INDArray output); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/impl/CEIDGCaptchaPredictionServiceImpl.java import net.scaliby.ceidgcaptcha.rest.common.MultiLayerNetworkLoader; import net.scaliby.ceidgcaptcha.rest.common.OutputLabeler; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; package net.scaliby.ceidgcaptcha.rest.service.impl; public class CEIDGCaptchaPredictionServiceImpl implements CEIDGCaptchaPredictionService { private final MultiLayerNetworkLoader multiLayerNetworkLoader;
private final BufferedImageToINDArrayConverter bufferedImageToINDArrayConverter;
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/impl/CEIDGCaptchaPredictionServiceImpl.java
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/MultiLayerNetworkLoader.java // public interface MultiLayerNetworkLoader { // // MultiLayerNetwork load(); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/OutputLabeler.java // public interface OutputLabeler { // // String getLabel(INDArray output); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // }
import net.scaliby.ceidgcaptcha.rest.common.MultiLayerNetworkLoader; import net.scaliby.ceidgcaptcha.rest.common.OutputLabeler; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage;
package net.scaliby.ceidgcaptcha.rest.service.impl; public class CEIDGCaptchaPredictionServiceImpl implements CEIDGCaptchaPredictionService { private final MultiLayerNetworkLoader multiLayerNetworkLoader; private final BufferedImageToINDArrayConverter bufferedImageToINDArrayConverter;
// Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/MultiLayerNetworkLoader.java // public interface MultiLayerNetworkLoader { // // MultiLayerNetwork load(); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/common/OutputLabeler.java // public interface OutputLabeler { // // String getLabel(INDArray output); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/converter/BufferedImageToINDArrayConverter.java // public interface BufferedImageToINDArrayConverter { // // INDArray convert(BufferedImage bufferedImage); // // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/CEIDGCaptchaPredictionService.java // public interface CEIDGCaptchaPredictionService { // // String predict(BufferedImage bufferedImage); // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/service/impl/CEIDGCaptchaPredictionServiceImpl.java import net.scaliby.ceidgcaptcha.rest.common.MultiLayerNetworkLoader; import net.scaliby.ceidgcaptcha.rest.common.OutputLabeler; import net.scaliby.ceidgcaptcha.rest.converter.BufferedImageToINDArrayConverter; import net.scaliby.ceidgcaptcha.rest.service.CEIDGCaptchaPredictionService; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.api.ndarray.INDArray; import javax.inject.Inject; import java.awt.image.BufferedImage; package net.scaliby.ceidgcaptcha.rest.service.impl; public class CEIDGCaptchaPredictionServiceImpl implements CEIDGCaptchaPredictionService { private final MultiLayerNetworkLoader multiLayerNetworkLoader; private final BufferedImageToINDArrayConverter bufferedImageToINDArrayConverter;
private final OutputLabeler outputLabeler;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory;
private final InputSplitService inputSplitService;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService;
private final NetworkConfigurationResource networkConfigurationResource;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService; private final NetworkConfigurationResource networkConfigurationResource; @Inject public MachineLearningServiceImpl(DataSetIteratorFactory dataSetIteratorFactory, InputSplitService inputSplitService, NetworkConfigurationResource networkConfigurationResource) { this.dataSetIteratorFactory = dataSetIteratorFactory; this.inputSplitService = inputSplitService; this.networkConfigurationResource = networkConfigurationResource; } @Override public void train(MultiLayerNetwork multiLayerNetwork) {
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService; private final NetworkConfigurationResource networkConfigurationResource; @Inject public MachineLearningServiceImpl(DataSetIteratorFactory dataSetIteratorFactory, InputSplitService inputSplitService, NetworkConfigurationResource networkConfigurationResource) { this.dataSetIteratorFactory = dataSetIteratorFactory; this.inputSplitService = inputSplitService; this.networkConfigurationResource = networkConfigurationResource; } @Override public void train(MultiLayerNetwork multiLayerNetwork) {
InputSplitResource inputSplitResource = inputSplitService.getInputSplit();
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService; private final NetworkConfigurationResource networkConfigurationResource; @Inject public MachineLearningServiceImpl(DataSetIteratorFactory dataSetIteratorFactory, InputSplitService inputSplitService, NetworkConfigurationResource networkConfigurationResource) { this.dataSetIteratorFactory = dataSetIteratorFactory; this.inputSplitService = inputSplitService; this.networkConfigurationResource = networkConfigurationResource; } @Override public void train(MultiLayerNetwork multiLayerNetwork) { InputSplitResource inputSplitResource = inputSplitService.getInputSplit(); DataSetIterator dataSetIterator = dataSetIteratorFactory.create(inputSplitResource.getTrain()); for (int i = 0; i < networkConfigurationResource.getEpoch(); i++) { multiLayerNetwork.fit(dataSetIterator); } }
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/InputSplitResource.java // @Data // public class InputSplitResource { // // private InputSplit train; // private InputSplit test; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/InputSplitService.java // public interface InputSplitService { // // InputSplitResource getInputSplit(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/impl/MachineLearningServiceImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.InputSplitResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.InputSplitService; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.eval.Evaluation; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning.service.impl; public class MachineLearningServiceImpl implements MachineLearningService { private final DataSetIteratorFactory dataSetIteratorFactory; private final InputSplitService inputSplitService; private final NetworkConfigurationResource networkConfigurationResource; @Inject public MachineLearningServiceImpl(DataSetIteratorFactory dataSetIteratorFactory, InputSplitService inputSplitService, NetworkConfigurationResource networkConfigurationResource) { this.dataSetIteratorFactory = dataSetIteratorFactory; this.inputSplitService = inputSplitService; this.networkConfigurationResource = networkConfigurationResource; } @Override public void train(MultiLayerNetwork multiLayerNetwork) { InputSplitResource inputSplitResource = inputSplitService.getInputSplit(); DataSetIterator dataSetIterator = dataSetIteratorFactory.create(inputSplitResource.getTrain()); for (int i = 0; i < networkConfigurationResource.getEpoch(); i++) { multiLayerNetwork.fit(dataSetIterator); } }
public NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork) {
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/ImageParserImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import org.apache.http.HttpResponse; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class ImageParserImpl implements ImageParser { @Override public BufferedImage parseImage(HttpResponse httpResponse) { try { return ImageIO.read(httpResponse.getEntity().getContent()); } catch (IOException e) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageParser.java // public interface ImageParser { // // BufferedImage parseImage(HttpResponse httpResponse); // // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CEIDGHttpException.java // public class CEIDGHttpException extends RuntimeException { // public CEIDGHttpException() { // } // // public CEIDGHttpException(String message) { // super(message); // } // // public CEIDGHttpException(String message, Throwable cause) { // super(message, cause); // } // // public CEIDGHttpException(Throwable cause) { // super(cause); // } // // public CEIDGHttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/ImageParserImpl.java import net.scaliby.ceidgcaptcha.downloader.common.ImageParser; import net.scaliby.ceidgcaptcha.downloader.exception.CEIDGHttpException; import org.apache.http.HttpResponse; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class ImageParserImpl implements ImageParser { @Override public BufferedImage parseImage(HttpResponse httpResponse) { try { return ImageIO.read(httpResponse.getEntity().getContent()); } catch (IOException e) {
throw new CEIDGHttpException(e);
scaliby/ceidg-captcha
ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // }
import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl;
package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() {
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // } // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl; package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() {
bind(StoreChooser.class).to(SwingStoreChooser.class);
scaliby/ceidg-captcha
ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // }
import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl;
package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() {
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // } // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl; package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() {
bind(StoreChooser.class).to(SwingStoreChooser.class);
scaliby/ceidg-captcha
ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // }
import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl;
package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() { bind(StoreChooser.class).to(SwingStoreChooser.class);
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // } // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl; package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() { bind(StoreChooser.class).to(SwingStoreChooser.class);
bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class);
scaliby/ceidg-captcha
ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // }
import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl;
package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() { bind(StoreChooser.class).to(SwingStoreChooser.class);
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/StoreChooser.java // public interface StoreChooser { // Optional<File> getDirectory(); // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/common/impl/SwingStoreChooser.java // public class SwingStoreChooser implements StoreChooser { // // private final JFileChooserFactory jFileChooserFactory; // // @Inject // public SwingStoreChooser(JFileChooserFactory jFileChooserFactory) { // this.jFileChooserFactory = jFileChooserFactory; // } // // @Override // public Optional<File> getDirectory() { // JFileChooser fileChooser = jFileChooserFactory.create(); // fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // int result = fileChooser.showOpenDialog(null); // if (result == JFileChooser.APPROVE_OPTION) { // return Optional.of(fileChooser.getSelectedFile()); // } // return Optional.empty(); // } // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/JFileChooserFactory.java // public interface JFileChooserFactory { // // JFileChooser create(); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/factory/impl/JFileChooserFactoryImpl.java // public class JFileChooserFactoryImpl implements JFileChooserFactory { // @Override // public JFileChooser create() { // return new JFileChooser(); // } // } // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java import com.google.inject.AbstractModule; import net.scaliby.ceidgcaptcha.common.common.StoreChooser; import net.scaliby.ceidgcaptcha.common.common.impl.SwingStoreChooser; import net.scaliby.ceidgcaptcha.common.factory.JFileChooserFactory; import net.scaliby.ceidgcaptcha.common.factory.impl.JFileChooserFactoryImpl; package net.scaliby.ceidgcaptcha.common; public class CEIDGCaptchaCommonModule extends AbstractModule { @Override protected void configure() { bind(StoreChooser.class).to(SwingStoreChooser.class);
bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class);
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/SwingCaptchaLabeler.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.Arrays; import java.util.List; import java.util.Optional;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class SwingCaptchaLabeler implements CaptchaLabeler { private final Object lock = new Object(); @Override public Optional<String> getLabel(BufferedImage bufferedImage) { try { return getLabelInternal(bufferedImage); } catch (InterruptedException e) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/CaptchaLabeler.java // public interface CaptchaLabeler { // Optional<String> getLabel(BufferedImage bufferedImage); // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/exception/CaptchaLabelingException.java // public class CaptchaLabelingException extends RuntimeException { // public CaptchaLabelingException() { // } // // public CaptchaLabelingException(String message) { // super(message); // } // // public CaptchaLabelingException(String message, Throwable cause) { // super(message, cause); // } // // public CaptchaLabelingException(Throwable cause) { // super(cause); // } // // public CaptchaLabelingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/SwingCaptchaLabeler.java import net.scaliby.ceidgcaptcha.downloader.common.CaptchaLabeler; import net.scaliby.ceidgcaptcha.downloader.exception.CaptchaLabelingException; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.Arrays; import java.util.List; import java.util.Optional; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class SwingCaptchaLabeler implements CaptchaLabeler { private final Object lock = new Object(); @Override public Optional<String> getLabel(BufferedImage bufferedImage) { try { return getLabelInternal(bufferedImage); } catch (InterruptedException e) {
throw new CaptchaLabelingException(e);
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/ImageWriterImpl.java
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // }
import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import javax.imageio.ImageIO; import java.awt.image.RenderedImage; import java.io.File; import java.io.IOException;
package net.scaliby.ceidgcaptcha.downloader.common.impl; public class ImageWriterImpl implements ImageWriter { @Override public void write(RenderedImage image, String format, File path) { try { ImageIO.write(image, format, path); } catch (IOException e) {
// Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/ImageWriter.java // public interface ImageWriter { // // void write(RenderedImage image, String format, File path); // // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/common/impl/ImageWriterImpl.java import net.scaliby.ceidgcaptcha.downloader.common.ImageWriter; import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import javax.imageio.ImageIO; import java.awt.image.RenderedImage; import java.io.File; import java.io.IOException; package net.scaliby.ceidgcaptcha.downloader.common.impl; public class ImageWriterImpl implements ImageWriter { @Override public void write(RenderedImage image, String format, File path) { try { ImageIO.write(image, format, path); } catch (IOException e) {
throw new ImageStoreException(e);
scaliby/ceidg-captcha
ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/ImageStoreFactoryImpl.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // }
import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import java.io.File;
package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class ImageStoreFactoryImpl implements ImageStoreFactory { @Override public File createImageStore(File basePath, String label) { File imageStore = new File(basePath, label); if (!imageStore.mkdir()) {
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/exception/ImageStoreException.java // public class ImageStoreException extends RuntimeException { // // public ImageStoreException() { // } // // public ImageStoreException(String message) { // super(message); // } // // public ImageStoreException(String message, Throwable cause) { // super(message, cause); // } // // public ImageStoreException(Throwable cause) { // super(cause); // } // // public ImageStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { // super(message, cause, enableSuppression, writableStackTrace); // } // } // // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/ImageStoreFactory.java // public interface ImageStoreFactory { // // File createImageStore(File basePath, String label); // // } // Path: ceidg-captcha-downloader/src/main/java/net/scaliby/ceidgcaptcha/downloader/factory/impl/ImageStoreFactoryImpl.java import net.scaliby.ceidgcaptcha.common.exception.ImageStoreException; import net.scaliby.ceidgcaptcha.downloader.factory.ImageStoreFactory; import java.io.File; package net.scaliby.ceidgcaptcha.downloader.factory.impl; public class ImageStoreFactoryImpl implements ImageStoreFactory { @Override public File createImageStore(File basePath, String label) { File imageStore = new File(basePath, label); if (!imageStore.mkdir()) {
throw new ImageStoreException("Can't create labelled store");
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // }
import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer;
package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class)
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer; package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class)
.module(CEIDGCaptchaPropertiesModule.class)
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // }
import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer;
package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class) .module(CEIDGCaptchaPropertiesModule.class)
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer; package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class) .module(CEIDGCaptchaPropertiesModule.class)
.module(CEIDGCaptchaCommonModule.class)
scaliby/ceidg-captcha
ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // }
import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer;
package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class) .module(CEIDGCaptchaPropertiesModule.class) .module(CEIDGCaptchaCommonModule.class) )); server.handlers(chain -> chain
// Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaCommonModule.java // public class CEIDGCaptchaCommonModule extends AbstractModule { // @Override // protected void configure() { // bind(StoreChooser.class).to(SwingStoreChooser.class); // bind(JFileChooserFactory.class).to(JFileChooserFactoryImpl.class); // } // } // // Path: ceidg-captcha-common/src/main/java/net/scaliby/ceidgcaptcha/common/CEIDGCaptchaPropertiesModule.java // public class CEIDGCaptchaPropertiesModule extends AbstractModule { // // private static final String PROPERTIES_FILE_NAME = "application.properties"; // // @Setter // private String propertiesFileName = PROPERTIES_FILE_NAME; // // @Override // protected void configure() { // try { // Properties properties = new Properties(); // ClassLoader classLoader = this.getClass().getClassLoader(); // properties.load(classLoader.getResourceAsStream(propertiesFileName)); // Names.bindProperties(binder(), properties); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/handler/CEIDGCaptchaPredictionHandler.java // public class CEIDGCaptchaPredictionHandler implements Handler { // // private final CEIDGCaptchaPredictionService ceidgCaptchaPredictionService; // private final ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter; // // @Inject // public CEIDGCaptchaPredictionHandler(CEIDGCaptchaPredictionService ceidgCaptchaPredictionService, ByteArrayToBufferedImageConverter byteArrayToBufferedImageConverter) { // this.ceidgCaptchaPredictionService = ceidgCaptchaPredictionService; // this.byteArrayToBufferedImageConverter = byteArrayToBufferedImageConverter; // } // // @Override // public void handle(Context ctx) throws Exception { // ctx.parse(Form.class).then(form -> { // UploadedFile image = form.file("image"); // BufferedImage bufferedImage = byteArrayToBufferedImageConverter.convert(image.getBytes()); // String prediction = ceidgCaptchaPredictionService.predict(bufferedImage); // // CEIDGCaptchaResponseResource ceidgCaptchaResponseResource = new CEIDGCaptchaResponseResource(); // ceidgCaptchaResponseResource.setPrediction(prediction); // ctx.render(json(ceidgCaptchaResponseResource)); // }); // } // // } // Path: ceidg-captcha-rest/src/main/java/net/scaliby/ceidgcaptcha/rest/CEIDGCaptchaRestMain.java import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaCommonModule; import net.scaliby.ceidgcaptcha.common.CEIDGCaptchaPropertiesModule; import net.scaliby.ceidgcaptcha.rest.handler.CEIDGCaptchaPredictionHandler; import ratpack.guice.Guice; import ratpack.server.RatpackServer; package net.scaliby.ceidgcaptcha.rest; public class CEIDGCaptchaRestMain { public static void main(String[] args) throws Exception { RatpackServer.start(server -> { server.serverConfig(config -> config .props(CEIDGCaptchaRestMain.class.getClassLoader().getResource("ratpack.properties")) .sysProps() .args(args) .env() ); server.registry(Guice.registry(b -> b .module(CEIDGCaptchaRestModule.class) .module(CEIDGCaptchaPropertiesModule.class) .module(CEIDGCaptchaCommonModule.class) )); server.handlers(chain -> chain
.post("predict-captcha", CEIDGCaptchaPredictionHandler.class)
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable {
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable {
private final MultiLayerConfigurationFactory multiLayerConfigurationFactory;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory;
private final MachineLearningService machineLearningService;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService;
private final MultiLayerNetworkFactory multiLayerNetworkFactory;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService; private final MultiLayerNetworkFactory multiLayerNetworkFactory;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService; private final MultiLayerNetworkFactory multiLayerNetworkFactory;
private final MultiLayerNetworkSaver multiLayerNetworkSaver;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // }
import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject;
package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService; private final MultiLayerNetworkFactory multiLayerNetworkFactory; private final MultiLayerNetworkSaver multiLayerNetworkSaver; @Inject public CEIDGCaptchaMachineLearningRunner(MultiLayerConfigurationFactory multiLayerConfigurationFactory, MachineLearningService machineLearningService, MultiLayerNetworkFactory multiLayerNetworkFactory, MultiLayerNetworkSaver multiLayerNetworkSaver) { this.multiLayerConfigurationFactory = multiLayerConfigurationFactory; this.machineLearningService = machineLearningService; this.multiLayerNetworkFactory = multiLayerNetworkFactory; this.multiLayerNetworkSaver = multiLayerNetworkSaver; } @Override public void run() { MultiLayerConfiguration configuration = multiLayerConfigurationFactory.create(); MultiLayerNetwork multiLayerNetwork = multiLayerNetworkFactory.create(configuration); machineLearningService.train(multiLayerNetwork); multiLayerNetworkSaver.save(multiLayerNetwork);
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/common/MultiLayerNetworkSaver.java // public interface MultiLayerNetworkSaver { // // void save(MultiLayerNetwork network); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerConfigurationFactory.java // public interface MultiLayerConfigurationFactory { // // MultiLayerConfiguration create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/MultiLayerNetworkFactory.java // public interface MultiLayerNetworkFactory { // // MultiLayerNetwork create(MultiLayerConfiguration multiLayerConfiguration); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkStatisticsResource.java // @Data // public class NetworkStatisticsResource { // // private Double accuracy; // private Double precision; // private Double recall; // private Double f1; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/service/MachineLearningService.java // public interface MachineLearningService { // // void train(MultiLayerNetwork multiLayerNetwork); // // NetworkStatisticsResource test(MultiLayerNetwork multiLayerNetwork); // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/CEIDGCaptchaMachineLearningRunner.java import lombok.extern.log4j.Log4j; import net.scaliby.ceidgcaptcha.machinelearning.common.MultiLayerNetworkSaver; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerConfigurationFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.MultiLayerNetworkFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkStatisticsResource; import net.scaliby.ceidgcaptcha.machinelearning.service.MachineLearningService; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; import javax.inject.Inject; package net.scaliby.ceidgcaptcha.machinelearning; @Log4j public class CEIDGCaptchaMachineLearningRunner implements Runnable { private final MultiLayerConfigurationFactory multiLayerConfigurationFactory; private final MachineLearningService machineLearningService; private final MultiLayerNetworkFactory multiLayerNetworkFactory; private final MultiLayerNetworkSaver multiLayerNetworkSaver; @Inject public CEIDGCaptchaMachineLearningRunner(MultiLayerConfigurationFactory multiLayerConfigurationFactory, MachineLearningService machineLearningService, MultiLayerNetworkFactory multiLayerNetworkFactory, MultiLayerNetworkSaver multiLayerNetworkSaver) { this.multiLayerConfigurationFactory = multiLayerConfigurationFactory; this.machineLearningService = machineLearningService; this.multiLayerNetworkFactory = multiLayerNetworkFactory; this.multiLayerNetworkSaver = multiLayerNetworkSaver; } @Override public void run() { MultiLayerConfiguration configuration = multiLayerConfigurationFactory.create(); MultiLayerNetwork multiLayerNetwork = multiLayerNetworkFactory.create(configuration); machineLearningService.train(multiLayerNetwork); multiLayerNetworkSaver.save(multiLayerNetwork);
NetworkStatisticsResource networkStatisticsResource = machineLearningService.test(multiLayerNetwork);
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/DataSetIteratorFactoryImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.InputSplit; import org.datavec.image.recordreader.ImageRecordReader; import org.datavec.image.transform.ImageTransform; import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.preprocessor.DataNormalization; import org.nd4j.linalg.dataset.api.preprocessor.ImagePreProcessingScaler; import javax.inject.Inject; import java.io.IOException;
package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class DataSetIteratorFactoryImpl implements DataSetIteratorFactory { private final NetworkConfigurationResource networkConfigurationResource;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/DataSetIteratorFactoryImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.InputSplit; import org.datavec.image.recordreader.ImageRecordReader; import org.datavec.image.transform.ImageTransform; import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.preprocessor.DataNormalization; import org.nd4j.linalg.dataset.api.preprocessor.ImagePreProcessingScaler; import javax.inject.Inject; import java.io.IOException; package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class DataSetIteratorFactoryImpl implements DataSetIteratorFactory { private final NetworkConfigurationResource networkConfigurationResource;
private final ImageTransformConfigurationResource imageTransformConfigurationResource;
scaliby/ceidg-captcha
ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/DataSetIteratorFactoryImpl.java
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // }
import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.InputSplit; import org.datavec.image.recordreader.ImageRecordReader; import org.datavec.image.transform.ImageTransform; import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.preprocessor.DataNormalization; import org.nd4j.linalg.dataset.api.preprocessor.ImagePreProcessingScaler; import javax.inject.Inject; import java.io.IOException;
package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class DataSetIteratorFactoryImpl implements DataSetIteratorFactory { private final NetworkConfigurationResource networkConfigurationResource; private final ImageTransformConfigurationResource imageTransformConfigurationResource; private final PathLabelGenerator pathLabelGenerator;
// Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/DataSetIteratorFactory.java // public interface DataSetIteratorFactory { // // DataSetIterator create(InputSplit inputSplit); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/ImageTransformFactory.java // public interface ImageTransformFactory { // // ImageTransform create(); // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/ImageTransformConfigurationResource.java // @Data // public class ImageTransformConfigurationResource { // // @Inject // @Named("application.imageTransform.scaledHeight") // private Integer scaledHeight; // @Inject // @Named("application.imageTransform.scaledWidth") // private Integer scaledWidth; // @Inject // @Named("application.imageTransform.channels") // private Integer channels; // // } // // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/resource/NetworkConfigurationResource.java // @Data // public class NetworkConfigurationResource { // // @Inject // @Named("application.network.outputs") // private Integer outputs; // @Inject // @Named("application.network.epoch") // private Integer epoch; // @Inject // @Named("application.network.batchSize") // private Integer batchSize; // // } // Path: ceidg-captcha-machine-learning/src/main/java/net/scaliby/ceidgcaptcha/machinelearning/factory/impl/DataSetIteratorFactoryImpl.java import net.scaliby.ceidgcaptcha.machinelearning.factory.DataSetIteratorFactory; import net.scaliby.ceidgcaptcha.machinelearning.factory.ImageTransformFactory; import net.scaliby.ceidgcaptcha.machinelearning.resource.ImageTransformConfigurationResource; import net.scaliby.ceidgcaptcha.machinelearning.resource.NetworkConfigurationResource; import org.datavec.api.io.labels.PathLabelGenerator; import org.datavec.api.split.InputSplit; import org.datavec.image.recordreader.ImageRecordReader; import org.datavec.image.transform.ImageTransform; import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.preprocessor.DataNormalization; import org.nd4j.linalg.dataset.api.preprocessor.ImagePreProcessingScaler; import javax.inject.Inject; import java.io.IOException; package net.scaliby.ceidgcaptcha.machinelearning.factory.impl; public class DataSetIteratorFactoryImpl implements DataSetIteratorFactory { private final NetworkConfigurationResource networkConfigurationResource; private final ImageTransformConfigurationResource imageTransformConfigurationResource; private final PathLabelGenerator pathLabelGenerator;
private final ImageTransformFactory imageTransformFactory;
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/observers/change/ThrowOnNull.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // }
import alex.mojaki.boxes.PowerBox;
package alex.mojaki.boxes.observers.change; /** * Throws an {@code IllegalArgumentException} when the value changes to {@code null}. * <p> * Note that all boxes start with a null value, and adding this does not affect that. It will only throw an exception * when you explicitly set null as the value. * <p> * You can't create a new instance of this class. Use the public constant {@code I}, or {@code INSTANCE} if you prefer. */ public class ThrowOnNull implements ChangeObserver { public static final ThrowOnNull I = new ThrowOnNull(); public static final ThrowOnNull INSTANCE = I; private ThrowOnNull() { } @Override
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // Path: src/main/java/alex/mojaki/boxes/observers/change/ThrowOnNull.java import alex.mojaki.boxes.PowerBox; package alex.mojaki.boxes.observers.change; /** * Throws an {@code IllegalArgumentException} when the value changes to {@code null}. * <p> * Note that all boxes start with a null value, and adding this does not affect that. It will only throw an exception * when you explicitly set null as the value. * <p> * You can't create a new instance of this class. Use the public constant {@code I}, or {@code INSTANCE} if you prefer. */ public class ThrowOnNull implements ChangeObserver { public static final ThrowOnNull I = new ThrowOnNull(); public static final ThrowOnNull INSTANCE = I; private ThrowOnNull() { } @Override
public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/middleware/symmetric/EnsureBounds.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/InstanceStore.java // public abstract class InstanceStore<T> { // // private final ConcurrentMap<List<Object>, T> map = new ConcurrentHashMap<List<Object>, T>(); // // /** // * Override this method to return a new instance of the class of interest using the given arguments. This usually // * means calling a constructor. // */ // public abstract T getNew(Object... args); // // /** // * Get an instance using the given arguments. If the arguments are new then a new instance // * will be returned via {@link InstanceStore#getNew(Object...)}. Otherwise a cached instance will be returned. // */ // public T get(Object... args) { // List<Object> key = Arrays.asList(args); // T result = map.get(key); // if (result != null) { // return result; // } // synchronized (map) { // result = map.get(key); // if (result == null) { // result = getNew(args); // map.put(key, result); // } // return result; // } // } // // }
import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.InstanceStore; import static alex.mojaki.boxes.utils.Utils.lessThan;
} if (min != null && max != null && lessThan(max, min)) { throw new IllegalArgumentException("The maximum (" + max + ") was set to less than the minimum (" + min + ")"); } //noinspection unchecked return new EnsureBounds(min, max); } }; private final Comparable<T> min; private final Comparable<T> max; private EnsureBounds(Comparable<T> min, Comparable<T> max) { this.min = min; this.max = max; } public static <T> EnsureBounds maximum(Comparable<T> max) { return between(null, max); } public static <T> EnsureBounds minimum(Comparable<T> min) { return between(min, null); } public static <T> EnsureBounds between(Comparable<T> min, Comparable<T> max) { return INSTANCE_STORE.get(min, max); } @Override
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/InstanceStore.java // public abstract class InstanceStore<T> { // // private final ConcurrentMap<List<Object>, T> map = new ConcurrentHashMap<List<Object>, T>(); // // /** // * Override this method to return a new instance of the class of interest using the given arguments. This usually // * means calling a constructor. // */ // public abstract T getNew(Object... args); // // /** // * Get an instance using the given arguments. If the arguments are new then a new instance // * will be returned via {@link InstanceStore#getNew(Object...)}. Otherwise a cached instance will be returned. // */ // public T get(Object... args) { // List<Object> key = Arrays.asList(args); // T result = map.get(key); // if (result != null) { // return result; // } // synchronized (map) { // result = map.get(key); // if (result == null) { // result = getNew(args); // map.put(key, result); // } // return result; // } // } // // } // Path: src/main/java/alex/mojaki/boxes/middleware/symmetric/EnsureBounds.java import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.InstanceStore; import static alex.mojaki.boxes.utils.Utils.lessThan; } if (min != null && max != null && lessThan(max, min)) { throw new IllegalArgumentException("The maximum (" + max + ") was set to less than the minimum (" + min + ")"); } //noinspection unchecked return new EnsureBounds(min, max); } }; private final Comparable<T> min; private final Comparable<T> max; private EnsureBounds(Comparable<T> min, Comparable<T> max) { this.min = min; this.max = max; } public static <T> EnsureBounds maximum(Comparable<T> max) { return between(null, max); } public static <T> EnsureBounds minimum(Comparable<T> min) { return between(min, null); } public static <T> EnsureBounds between(Comparable<T> min, Comparable<T> max) { return INSTANCE_STORE.get(min, max); } @Override
public Comparable<T> apply(PowerBox<Comparable<T>> box, Comparable<T> firstValue, Comparable<T> currentValue) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/PowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/PowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares);
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/PowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/PowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
PowerBox<T> addGetMiddleware(GetMiddleware... middlewares);
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/PowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); /** * Add {@link ChangeObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/PowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); /** * Add {@link ChangeObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
PowerBox<T> addChangeObserver(ChangeObserver... observers);
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/PowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); /** * Add {@link ChangeObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeObserver(ChangeObserver... observers); /** * Add {@link GetObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/PowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@link Box} which can dynamically change its behaviour regarding its value changing or {@link PowerBox#get()} * being called. */ public interface PowerBox<T> extends Box<T> { /** * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. */ @Override T get(); /** * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s * added to the box's family, in the order they were added, to the given parameter, then similarly notify * the {@link ChangeObserver}s. */ @Override PowerBox<T> set(T value); /** * Add {@link ChangeMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); /** * Add {@link GetMiddleware}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); /** * Add {@link ChangeObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */ PowerBox<T> addChangeObserver(ChangeObserver... observers); /** * Add {@link GetObserver}s to this box's family. * Arguments equal to instances that have already been added will be ignored. * * @return this object for chaining */
PowerBox<T> addGetObserver(GetObserver... observers);
alexmojaki/boxes
src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail;
package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0);
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail; package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0);
unsettable.addChangeMiddleware(new ChangeMiddleware() {
alexmojaki/boxes
src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail;
package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; }
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail; package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; }
}).addChangeObserver(new ChangeObserver() {
alexmojaki/boxes
src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail;
package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; } }).addChangeObserver(new ChangeObserver() { @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { }
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail; package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; } }).addChangeObserver(new ChangeObserver() { @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { }
}).addGetObserver(new GetObserver() {
alexmojaki/boxes
src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail;
package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; } }).addChangeObserver(new ChangeObserver() { @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { } }).addGetObserver(new GetObserver() { @Override public void onGet(PowerBox box, Object originalValue, Object finalValue) { }
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/test/java/alex/mojaki/boxes/test/ForwardingBoxTest.java import alex.mojaki.boxes.*; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; import org.junit.Test; import java.util.Arrays; import java.util.List; import static alex.mojaki.boxes.Boxes.box; import static alex.mojaki.boxes.Boxes.unsettableAdapter; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.fail; package alex.mojaki.boxes.test; public class ForwardingBoxTest { @Test public void testUnsettableBox() { Box<String> box = box(); Box<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); } @Test public void testUnsettablePowerBox() { PowerBox<String> box = box(BoxFamily.getInstance(ForwardingBoxTest.class, "box")); PowerBox<String> unsettable = unsettableAdapter(box); testUnsettableSetBehaviour(box, unsettable); assertParticipantListSize(unsettable, 0); unsettable.addChangeMiddleware(new ChangeMiddleware() { @Override public Object onChange(PowerBox box, Object originalValue, Object currentValue, Object requestedValue) { return currentValue; } }).addChangeObserver(new ChangeObserver() { @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { } }).addGetObserver(new GetObserver() { @Override public void onGet(PowerBox box, Object originalValue, Object finalValue) { }
}).addGetMiddleware(new GetMiddleware() {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/middleware/symmetric/DefaultValue.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/utils/InstanceStore.java // public abstract class InstanceStore<T> { // // private final ConcurrentMap<List<Object>, T> map = new ConcurrentHashMap<List<Object>, T>(); // // /** // * Override this method to return a new instance of the class of interest using the given arguments. This usually // * means calling a constructor. // */ // public abstract T getNew(Object... args); // // /** // * Get an instance using the given arguments. If the arguments are new then a new instance // * will be returned via {@link InstanceStore#getNew(Object...)}. Otherwise a cached instance will be returned. // */ // public T get(Object... args) { // List<Object> key = Arrays.asList(args); // T result = map.get(key); // if (result != null) { // return result; // } // synchronized (map) { // result = map.get(key); // if (result == null) { // result = getNew(args); // map.put(key, result); // } // return result; // } // } // // }
import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.utils.InstanceStore;
package alex.mojaki.boxes.middleware.symmetric; // @formatter:off /** * If the current value is null, replace it with some default value. * For example: * * <pre>{@code * PowerBox<String> name = new CommonBox<String>(Example.class, "name") * .addGetMiddleware(DefaultValue.getInstance("Unknown")); * name.get(); // returns "Unknown" * }</pre> */ // @formatter:on public class DefaultValue extends SymmetricMiddleware { private static final InstanceStore<DefaultValue> INSTANCE_STORE = new InstanceStore<DefaultValue>() { @Override public DefaultValue getNew(Object... args) { return new DefaultValue(args[0]); } }; private final Object value; private DefaultValue(Object defaultValue) { this.value = defaultValue; } public static DefaultValue getInstance(Object value) { return INSTANCE_STORE.get(value); } @Override
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/utils/InstanceStore.java // public abstract class InstanceStore<T> { // // private final ConcurrentMap<List<Object>, T> map = new ConcurrentHashMap<List<Object>, T>(); // // /** // * Override this method to return a new instance of the class of interest using the given arguments. This usually // * means calling a constructor. // */ // public abstract T getNew(Object... args); // // /** // * Get an instance using the given arguments. If the arguments are new then a new instance // * will be returned via {@link InstanceStore#getNew(Object...)}. Otherwise a cached instance will be returned. // */ // public T get(Object... args) { // List<Object> key = Arrays.asList(args); // T result = map.get(key); // if (result != null) { // return result; // } // synchronized (map) { // result = map.get(key); // if (result == null) { // result = getNew(args); // map.put(key, result); // } // return result; // } // } // // } // Path: src/main/java/alex/mojaki/boxes/middleware/symmetric/DefaultValue.java import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.utils.InstanceStore; package alex.mojaki.boxes.middleware.symmetric; // @formatter:off /** * If the current value is null, replace it with some default value. * For example: * * <pre>{@code * PowerBox<String> name = new CommonBox<String>(Example.class, "name") * .addGetMiddleware(DefaultValue.getInstance("Unknown")); * name.get(); // returns "Unknown" * }</pre> */ // @formatter:on public class DefaultValue extends SymmetricMiddleware { private static final InstanceStore<DefaultValue> INSTANCE_STORE = new InstanceStore<DefaultValue>() { @Override public DefaultValue getNew(Object... args) { return new DefaultValue(args[0]); } }; private final Object value; private DefaultValue(Object defaultValue) { this.value = defaultValue; } public static DefaultValue getInstance(Object value) { return INSTANCE_STORE.get(value); } @Override
public Object apply(PowerBox box, Object firstValue, Object currentValue) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/observers/change/ChangePrinter.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/Utils.java // public enum Utils { // ; // // public static boolean lessThan(Comparable x, Comparable y) { // //noinspection unchecked // return x.compareTo(y) < 0; // } // // /** // * Return a concise human readable description of a change to a {@code PowerBox} using the arguments to // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)}. This is what is printed by // * {@link ChangePrinter}. // */ // public static String describeChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { // String beginning = box.getFamily().description() + " value changed "; // if (box instanceof WrapperBox && box == originalValue && box == finalValue && box == requestedValue) { // return beginning + "to " + ((WrapperBox) box).revealedToString(); // } // return beginning + "from " + originalValue + // " to " + finalValue + // (requestedValue.equals(finalValue) ? "" : // " (requested value was " + requestedValue + ")"); // } // // }
import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.Utils;
package alex.mojaki.boxes.observers.change; /** * Print to standard out changes made to the box this is added to. This uses * {@link Utils#describeChange(PowerBox, Object, Object, Object)}, which may help write your own method for * your specific logging needs. */ public class ChangePrinter implements ChangeObserver { public static final ChangePrinter I = new ChangePrinter(); private ChangePrinter() { } @Override
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/Utils.java // public enum Utils { // ; // // public static boolean lessThan(Comparable x, Comparable y) { // //noinspection unchecked // return x.compareTo(y) < 0; // } // // /** // * Return a concise human readable description of a change to a {@code PowerBox} using the arguments to // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)}. This is what is printed by // * {@link ChangePrinter}. // */ // public static String describeChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { // String beginning = box.getFamily().description() + " value changed "; // if (box instanceof WrapperBox && box == originalValue && box == finalValue && box == requestedValue) { // return beginning + "to " + ((WrapperBox) box).revealedToString(); // } // return beginning + "from " + originalValue + // " to " + finalValue + // (requestedValue.equals(finalValue) ? "" : // " (requested value was " + requestedValue + ")"); // } // // } // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangePrinter.java import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.Utils; package alex.mojaki.boxes.observers.change; /** * Print to standard out changes made to the box this is added to. This uses * {@link Utils#describeChange(PowerBox, Object, Object, Object)}, which may help write your own method for * your specific logging needs. */ public class ChangePrinter implements ChangeObserver { public static final ChangePrinter I = new ChangePrinter(); private ChangePrinter() { } @Override
public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/observers/change/ChangePrinter.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/Utils.java // public enum Utils { // ; // // public static boolean lessThan(Comparable x, Comparable y) { // //noinspection unchecked // return x.compareTo(y) < 0; // } // // /** // * Return a concise human readable description of a change to a {@code PowerBox} using the arguments to // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)}. This is what is printed by // * {@link ChangePrinter}. // */ // public static String describeChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { // String beginning = box.getFamily().description() + " value changed "; // if (box instanceof WrapperBox && box == originalValue && box == finalValue && box == requestedValue) { // return beginning + "to " + ((WrapperBox) box).revealedToString(); // } // return beginning + "from " + originalValue + // " to " + finalValue + // (requestedValue.equals(finalValue) ? "" : // " (requested value was " + requestedValue + ")"); // } // // }
import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.Utils;
package alex.mojaki.boxes.observers.change; /** * Print to standard out changes made to the box this is added to. This uses * {@link Utils#describeChange(PowerBox, Object, Object, Object)}, which may help write your own method for * your specific logging needs. */ public class ChangePrinter implements ChangeObserver { public static final ChangePrinter I = new ChangePrinter(); private ChangePrinter() { } @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) {
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/utils/Utils.java // public enum Utils { // ; // // public static boolean lessThan(Comparable x, Comparable y) { // //noinspection unchecked // return x.compareTo(y) < 0; // } // // /** // * Return a concise human readable description of a change to a {@code PowerBox} using the arguments to // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)}. This is what is printed by // * {@link ChangePrinter}. // */ // public static String describeChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) { // String beginning = box.getFamily().description() + " value changed "; // if (box instanceof WrapperBox && box == originalValue && box == finalValue && box == requestedValue) { // return beginning + "to " + ((WrapperBox) box).revealedToString(); // } // return beginning + "from " + originalValue + // " to " + finalValue + // (requestedValue.equals(finalValue) ? "" : // " (requested value was " + requestedValue + ")"); // } // // } // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangePrinter.java import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.utils.Utils; package alex.mojaki.boxes.observers.change; /** * Print to standard out changes made to the box this is added to. This uses * {@link Utils#describeChange(PowerBox, Object, Object, Object)}, which may help write your own method for * your specific logging needs. */ public class ChangePrinter implements ChangeObserver { public static final ChangePrinter I = new ChangePrinter(); private ChangePrinter() { } @Override public void onChange(PowerBox box, Object originalValue, Object finalValue, Object requestedValue) {
System.out.println(Utils.describeChange(box, originalValue, finalValue, requestedValue));
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/middleware/symmetric/SymmetricMiddleware.java
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // }
import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware;
package alex.mojaki.boxes.middleware.symmetric; /** * Middleware which implements both {@code GetMiddleware} and {@code ChangeMiddleware} with the same effect on values. */ public abstract class SymmetricMiddleware<T> implements ChangeMiddleware<T>, GetMiddleware<T> { /** * Call {@code apply(box, requestedValue, currentValue);}. */ @Override
// Path: src/main/java/alex/mojaki/boxes/PowerBox.java // public interface PowerBox<T> extends Box<T> { // // /** // * Return the result of applying the {@link GetMiddleware}s added to the box's family, in the order they were // * added, to the value stored by this box, then similarly notify the {@link GetObserver}s. // */ // @Override // T get(); // // /** // * Change the value stored by this box to the result of applying the {@link ChangeMiddleware}s // * added to the box's family, in the order they were added, to the given parameter, then similarly notify // * the {@link ChangeObserver}s. // */ // @Override // PowerBox<T> set(T value); // // /** // * Add {@link ChangeMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares); // // /** // * Add {@link GetMiddleware}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetMiddleware(GetMiddleware... middlewares); // // /** // * Add {@link ChangeObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addChangeObserver(ChangeObserver... observers); // // /** // * Add {@link GetObserver}s to this box's family. // * Arguments equal to instances that have already been added will be ignored. // * // * @return this object for chaining // */ // PowerBox<T> addGetObserver(GetObserver... observers); // // /** // * Return the family that this box belongs to. // */ // BoxFamily getFamily(); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // Path: src/main/java/alex/mojaki/boxes/middleware/symmetric/SymmetricMiddleware.java import alex.mojaki.boxes.PowerBox; import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; package alex.mojaki.boxes.middleware.symmetric; /** * Middleware which implements both {@code GetMiddleware} and {@code ChangeMiddleware} with the same effect on values. */ public abstract class SymmetricMiddleware<T> implements ChangeMiddleware<T>, GetMiddleware<T> { /** * Call {@code apply(box, requestedValue, currentValue);}. */ @Override
public T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override
public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override
public PowerBox<T> addGetMiddleware(GetMiddleware... middlewares) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override public PowerBox<T> addGetMiddleware(GetMiddleware... middlewares) { box.addGetMiddleware(middlewares); return this; } @Override
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override public PowerBox<T> addGetMiddleware(GetMiddleware... middlewares) { box.addGetMiddleware(middlewares); return this; } @Override
public PowerBox<T> addChangeObserver(ChangeObserver... observers) {
alexmojaki/boxes
src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // }
import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver;
package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override public PowerBox<T> addGetMiddleware(GetMiddleware... middlewares) { box.addGetMiddleware(middlewares); return this; } @Override public PowerBox<T> addChangeObserver(ChangeObserver... observers) { box.addChangeObserver(observers); return this; } @Override
// Path: src/main/java/alex/mojaki/boxes/middleware/change/ChangeMiddleware.java // public interface ChangeMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#set(Object)} for zero or more of these objects before applying the list of // * {@link ChangeObserver}s. // * // * @param box the {@code PowerBox} whose value is being {@code set}. // * @param originalValue the value the box contained before it was set. // * @param currentValue for the first middleware in the sequence, this is the same as {@code requestedValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}. // * @return the final value to be stored in the box and the parameter {@code finalValue} in the // * {@link ChangeObserver#onChange(PowerBox, Object, Object, Object)} method for any {@code ChangeObserver}s this // * box has. // */ // T onChange(PowerBox<T> box, T originalValue, T currentValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/middleware/get/GetMiddleware.java // public interface GetMiddleware<T> { // // /** // * Return the given {@code currentValue} or some transformation of it. // * Called during {@link PowerBox#get()} for zero or more of these objects before applying the list of // * {@link GetObserver}s. // * // * @param box the {@code PowerBox} whose value is being obtained by {@code get}. // * @param originalValue the value the box contained before any middleware was applied. // * @param currentValue for the first middleware in the sequence, this is the same as {@code originalValue}. // * For subsequent middleware, this is the return value of the previous middleware. // * @return the final value to be returned to the user and the parameter {@code finalValue} in the // * {@link GetObserver#onGet(PowerBox, Object, Object)} method for any {@code GetObserver}s this // * box has. // */ // T onGet(PowerBox<T> box, T originalValue, T currentValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/change/ChangeObserver.java // public interface ChangeObserver<T> { // // /** // * Take some action based on the values involved in the change. // * Called when the value of a {@code PowerBox} changes for zero or more of these objects. // * // * @param box the {@code PowerBox} whose value changed. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. In the case of {@link PowerBox#set(Object)}, // * this is the final result of applying all {@link ChangeMiddleware}. // * @param requestedValue the parameter of {@link PowerBox#set(Object)}, or just the same as {@code originalValue} // * in the case of a mutation to a {@code WrapperBox}. // */ // void onChange(PowerBox<T> box, T originalValue, T finalValue, T requestedValue); // } // // Path: src/main/java/alex/mojaki/boxes/observers/get/GetObserver.java // public interface GetObserver<T> { // // /** // * Take some action based on the values involved in the get. // * Called during {@link PowerBox#get()} for zero or more of these objects // * // * @param box the {@code PowerBox} whose value is being obtained. // * @param originalValue the value the box contained before the change. // * @param finalValue the new value the box will have. // * This is the final result of applying all {@link GetMiddleware}. // */ // void onGet(PowerBox<T> box, T originalValue, T finalValue); // } // Path: src/main/java/alex/mojaki/boxes/ForwardingPowerBox.java import alex.mojaki.boxes.middleware.change.ChangeMiddleware; import alex.mojaki.boxes.middleware.get.GetMiddleware; import alex.mojaki.boxes.observers.change.ChangeObserver; import alex.mojaki.boxes.observers.get.GetObserver; package alex.mojaki.boxes; /** * A {@code PowerBox} that wraps around another {@code PowerBox} and forwards the interface methods * and {@code toString}. * This is not useful on its own but makes it easy it to implement the decorator pattern by subclassing. */ public abstract class ForwardingPowerBox<T> implements PowerBox<T> { protected final PowerBox<T> box; public ForwardingPowerBox(PowerBox<T> box) { this.box = box; } @Override public PowerBox<T> addChangeMiddleware(ChangeMiddleware... middlewares) { box.addChangeMiddleware(middlewares); return this; } @Override public PowerBox<T> addGetMiddleware(GetMiddleware... middlewares) { box.addGetMiddleware(middlewares); return this; } @Override public PowerBox<T> addChangeObserver(ChangeObserver... observers) { box.addChangeObserver(observers); return this; } @Override
public PowerBox<T> addGetObserver(GetObserver... observers) {
Tonius/E-Mobile
src/main/java/tonius/emobile/client/ClientProxy.java
// Path: src/main/java/tonius/emobile/CommonProxy.java // public class CommonProxy { // // public void playDiallingSound(EntityPlayer player) { // } // // public void showDiallingParticles(double posX, double posY, double posZ) { // } // // public void showTeleportParticles(double posX, double posY, double posZ) { // } // // } // // Path: src/main/java/tonius/emobile/client/audio/SoundDialling.java // public class SoundDialling extends MovingSound { // // private EntityPlayer user; // // public SoundDialling(EntityPlayer user) { // super(new ResourceLocation("emobile:phonecountdown")); // this.user = user; // } // // @Override // public void update() { // this.xPosF = (float) this.user.posX; // this.yPosF = (float) this.user.posY; // this.zPosF = (float) this.user.posZ; // } // // }
import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import tonius.emobile.CommonProxy; import tonius.emobile.client.audio.SoundDialling;
package tonius.emobile.client; public class ClientProxy extends CommonProxy { private static Minecraft mc = Minecraft.getMinecraft(); private static Random rand = new Random(); @Override public void playDiallingSound(EntityPlayer player) {
// Path: src/main/java/tonius/emobile/CommonProxy.java // public class CommonProxy { // // public void playDiallingSound(EntityPlayer player) { // } // // public void showDiallingParticles(double posX, double posY, double posZ) { // } // // public void showTeleportParticles(double posX, double posY, double posZ) { // } // // } // // Path: src/main/java/tonius/emobile/client/audio/SoundDialling.java // public class SoundDialling extends MovingSound { // // private EntityPlayer user; // // public SoundDialling(EntityPlayer user) { // super(new ResourceLocation("emobile:phonecountdown")); // this.user = user; // } // // @Override // public void update() { // this.xPosF = (float) this.user.posX; // this.yPosF = (float) this.user.posY; // this.zPosF = (float) this.user.posZ; // } // // } // Path: src/main/java/tonius/emobile/client/ClientProxy.java import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import tonius.emobile.CommonProxy; import tonius.emobile.client.audio.SoundDialling; package tonius.emobile.client; public class ClientProxy extends CommonProxy { private static Minecraft mc = Minecraft.getMinecraft(); private static Random rand = new Random(); @Override public void playDiallingSound(EntityPlayer player) {
mc.getSoundHandler().playSound(new SoundDialling(player));
Tonius/E-Mobile
src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // }
import io.netty.buffer.ByteBuf; import tonius.emobile.EMobile; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
package tonius.emobile.network.message; public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { public double posX; public double posY; public double posZ; public MessageTeleportParticles() { } public MessageTeleportParticles(double posX, double posY, double posZ) { this.posX = posX; this.posY = posY; this.posZ = posZ; } @Override public void fromBytes(ByteBuf buf) { this.posX = buf.readDouble(); this.posY = buf.readDouble(); this.posZ = buf.readDouble(); } @Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.posX); buf.writeDouble(this.posY); buf.writeDouble(this.posZ); } @Override public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) {
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // } // Path: src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java import io.netty.buffer.ByteBuf; import tonius.emobile.EMobile; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; package tonius.emobile.network.message; public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { public double posX; public double posY; public double posZ; public MessageTeleportParticles() { } public MessageTeleportParticles(double posX, double posY, double posZ) { this.posX = posX; this.posY = posY; this.posZ = posZ; } @Override public void fromBytes(ByteBuf buf) { this.posX = buf.readDouble(); this.posY = buf.readDouble(); this.posZ = buf.readDouble(); } @Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.posX); buf.writeDouble(this.posY); buf.writeDouble(this.posZ); } @Override public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) {
EMobile.proxy.showTeleportParticles(msg.posX, msg.posY, msg.posZ);
Tonius/E-Mobile
src/main/java/tonius/emobile/config/EMConfig.java
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.minecraftforge.common.config.Configuration; import tonius.emobile.EMobile; import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
// tweaks default public static final int enderPearlStackSize_default = 16; // fluxCellphone default public static final boolean fluxCellphoneEnabled_default = true; public static final int fluxCellphoneMaxEnergy_default = 600000; public static final int fluxCellphoneMaxInput_default = 2000; public static final int fluxCellphoneEnergyPerUse_default = 30000; // general public static boolean allowTeleportPlayers = allowTeleportHome_default; public static boolean allowTeleportHome = allowTeleportHome_default; public static boolean allowTeleportSpawn = allowTeleportHome_default; public static int[] dimensionsBlacklist = dimensionsBlacklist_default; public static boolean dimensionsWhitelist = dimensionsWhitelist_default; public static List<String> bedBlocks = Arrays.asList(bedBlocks_default); // tweaks public static int enderPearlStackSize = enderPearlStackSize_default; // fluxCellphone public static boolean fluxCellphoneEnabled = fluxCellphoneEnabled_default; public static int fluxCellphoneMaxEnergy = fluxCellphoneMaxEnergy_default; public static int fluxCellphoneMaxInput = fluxCellphoneMaxInput_default; public static int fluxCellphoneEnergyPerUse = fluxCellphoneEnergyPerUse_default; public static void preInit(FMLPreInitializationEvent evt) { FMLCommonHandler.instance().bus().register(new EMConfig()); config = new Configuration(evt.getSuggestedConfigurationFile());
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // } // Path: src/main/java/tonius/emobile/config/EMConfig.java import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.minecraftforge.common.config.Configuration; import tonius.emobile.EMobile; import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; // tweaks default public static final int enderPearlStackSize_default = 16; // fluxCellphone default public static final boolean fluxCellphoneEnabled_default = true; public static final int fluxCellphoneMaxEnergy_default = 600000; public static final int fluxCellphoneMaxInput_default = 2000; public static final int fluxCellphoneEnergyPerUse_default = 30000; // general public static boolean allowTeleportPlayers = allowTeleportHome_default; public static boolean allowTeleportHome = allowTeleportHome_default; public static boolean allowTeleportSpawn = allowTeleportHome_default; public static int[] dimensionsBlacklist = dimensionsBlacklist_default; public static boolean dimensionsWhitelist = dimensionsWhitelist_default; public static List<String> bedBlocks = Arrays.asList(bedBlocks_default); // tweaks public static int enderPearlStackSize = enderPearlStackSize_default; // fluxCellphone public static boolean fluxCellphoneEnabled = fluxCellphoneEnabled_default; public static int fluxCellphoneMaxEnergy = fluxCellphoneMaxEnergy_default; public static int fluxCellphoneMaxInput = fluxCellphoneMaxInput_default; public static int fluxCellphoneEnergyPerUse = fluxCellphoneEnergyPerUse_default; public static void preInit(FMLPreInitializationEvent evt) { FMLCommonHandler.instance().bus().register(new EMConfig()); config = new Configuration(evt.getSuggestedConfigurationFile());
EMobile.logger.info("Loading configuration file");
Tonius/E-Mobile
src/main/java/tonius/emobile/gui/container/ContainerCellphoneRF.java
// Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; import tonius.emobile.util.StackUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package tonius.emobile.gui.container; public class ContainerCellphoneRF extends ContainerCellphoneBase { public ItemStack cellphone; private int lastEnergy; private Short energyFirstHalf = null; private Short energySecondHalf = null; public ContainerCellphoneRF(InventoryPlayer invPlayer, ItemStack cellphone) { super(invPlayer); this.cellphone = cellphone; this.bindPlayerInventory(invPlayer, 8, 121); } @Override public boolean canInteractWith(EntityPlayer player) { ItemStack invStack = player.inventory.mainInventory[this.cellphoneSlot]; if (invStack != null && invStack.isItemEqual(this.cellphone)) { this.cellphone = invStack; } return true; } @Override public void detectAndSendChanges() { super.detectAndSendChanges();
// Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // } // Path: src/main/java/tonius/emobile/gui/container/ContainerCellphoneRF.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; import tonius.emobile.util.StackUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package tonius.emobile.gui.container; public class ContainerCellphoneRF extends ContainerCellphoneBase { public ItemStack cellphone; private int lastEnergy; private Short energyFirstHalf = null; private Short energySecondHalf = null; public ContainerCellphoneRF(InventoryPlayer invPlayer, ItemStack cellphone) { super(invPlayer); this.cellphone = cellphone; this.bindPlayerInventory(invPlayer, 8, 121); } @Override public boolean canInteractWith(EntityPlayer player) { ItemStack invStack = player.inventory.mainInventory[this.cellphoneSlot]; if (invStack != null && invStack.isItemEqual(this.cellphone)) { this.cellphone = invStack; } return true; } @Override public void detectAndSendChanges() { super.detectAndSendChanges();
int energy = StackUtils.getNBT(this.cellphone).getInteger("Energy");
Tonius/E-Mobile
src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // }
import io.netty.buffer.ByteBuf; import tonius.emobile.EMobile; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
package tonius.emobile.network.message; public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { public double posX; public double posY; public double posZ; public MessageDiallingParticles() { } public MessageDiallingParticles(double posX, double posY, double posZ) { this.posX = posX; this.posY = posY; this.posZ = posZ; } @Override public void fromBytes(ByteBuf buf) { this.posX = buf.readDouble(); this.posY = buf.readDouble(); this.posZ = buf.readDouble(); } @Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.posX); buf.writeDouble(this.posY); buf.writeDouble(this.posZ); } @Override public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) {
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // } // Path: src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java import io.netty.buffer.ByteBuf; import tonius.emobile.EMobile; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; package tonius.emobile.network.message; public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { public double posX; public double posY; public double posZ; public MessageDiallingParticles() { } public MessageDiallingParticles(double posX, double posY, double posZ) { this.posX = posX; this.posY = posY; this.posZ = posZ; } @Override public void fromBytes(ByteBuf buf) { this.posX = buf.readDouble(); this.posY = buf.readDouble(); this.posZ = buf.readDouble(); } @Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.posX); buf.writeDouble(this.posY); buf.writeDouble(this.posZ); } @Override public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) {
EMobile.proxy.showDiallingParticles(msg.posX, msg.posY, msg.posZ);
Tonius/E-Mobile
src/main/java/tonius/emobile/util/ServerUtils.java
// Path: src/main/java/tonius/emobile/network/PacketHandler.java // public class PacketHandler { // // public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("EMobile"); // // public static void preInit() { // EMobile.logger.info("Registering network messages"); // instance.registerMessage(MessageCellphonePlayer.class, MessageCellphonePlayer.class, 0, Side.SERVER); // instance.registerMessage(MessageCellphoneAuthorize.class, MessageCellphoneAuthorize.class, 1, Side.SERVER); // instance.registerMessage(MessageCellphoneSpawn.class, MessageCellphoneSpawn.class, 2, Side.SERVER); // instance.registerMessage(MessageCellphoneHome.class, MessageCellphoneHome.class, 3, Side.SERVER); // instance.registerMessage(MessageCellphoneCancel.class, MessageCellphoneCancel.class, 4, Side.SERVER); // instance.registerMessage(MessageConfigSync.class, MessageConfigSync.class, 5, Side.CLIENT); // instance.registerMessage(MessageDiallingSound.class, MessageDiallingSound.class, 6, Side.CLIENT); // instance.registerMessage(MessageDiallingParticles.class, MessageDiallingParticles.class, 7, Side.CLIENT); // instance.registerMessage(MessageTeleportParticles.class, MessageTeleportParticles.class, 8, Side.CLIENT); // } // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java // public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageDiallingParticles() { // } // // public MessageDiallingParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) { // EMobile.proxy.showDiallingParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingSound.java // public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { // // public int entityID; // // public MessageDiallingSound() { // } // // public MessageDiallingSound(int entityID) { // this.entityID = entityID; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.entityID = buf.readInt(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeInt(this.entityID); // } // // @Override // public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { // Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); // if (entity instanceof EntityPlayer) { // EMobile.proxy.playDiallingSound((EntityPlayer) entity); // } // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java // public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageTeleportParticles() { // } // // public MessageTeleportParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) { // EMobile.proxy.showTeleportParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import tonius.emobile.network.PacketHandler; import tonius.emobile.network.message.MessageDiallingParticles; import tonius.emobile.network.message.MessageDiallingSound; import tonius.emobile.network.message.MessageTeleportParticles; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
package tonius.emobile.util; public class ServerUtils { public static EntityPlayerMP getPlayerOnServer(String name) { return MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); } public static boolean isPlayerConnected(EntityPlayerMP player) { return MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player); } public static boolean canPlayerTeleport(EntityPlayerMP player) { return player != null && isPlayerConnected(player) && !player.isDead; } public static void sendGlobalChat(String chat) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(chat)); } public static void sendChatToPlayer(String player, String chat, EnumChatFormatting color) { EntityPlayerMP playerEntity = getPlayerOnServer(player); if (playerEntity != null) { ChatComponentText component = new ChatComponentText(chat); component.getChatStyle().setColor(color); playerEntity.addChatMessage(component); } } public static void sendChatToPlayer(String player, String chat) { sendChatToPlayer(player, chat, EnumChatFormatting.WHITE); } public static void sendDiallingSound(EntityPlayer player) {
// Path: src/main/java/tonius/emobile/network/PacketHandler.java // public class PacketHandler { // // public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("EMobile"); // // public static void preInit() { // EMobile.logger.info("Registering network messages"); // instance.registerMessage(MessageCellphonePlayer.class, MessageCellphonePlayer.class, 0, Side.SERVER); // instance.registerMessage(MessageCellphoneAuthorize.class, MessageCellphoneAuthorize.class, 1, Side.SERVER); // instance.registerMessage(MessageCellphoneSpawn.class, MessageCellphoneSpawn.class, 2, Side.SERVER); // instance.registerMessage(MessageCellphoneHome.class, MessageCellphoneHome.class, 3, Side.SERVER); // instance.registerMessage(MessageCellphoneCancel.class, MessageCellphoneCancel.class, 4, Side.SERVER); // instance.registerMessage(MessageConfigSync.class, MessageConfigSync.class, 5, Side.CLIENT); // instance.registerMessage(MessageDiallingSound.class, MessageDiallingSound.class, 6, Side.CLIENT); // instance.registerMessage(MessageDiallingParticles.class, MessageDiallingParticles.class, 7, Side.CLIENT); // instance.registerMessage(MessageTeleportParticles.class, MessageTeleportParticles.class, 8, Side.CLIENT); // } // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java // public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageDiallingParticles() { // } // // public MessageDiallingParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) { // EMobile.proxy.showDiallingParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingSound.java // public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { // // public int entityID; // // public MessageDiallingSound() { // } // // public MessageDiallingSound(int entityID) { // this.entityID = entityID; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.entityID = buf.readInt(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeInt(this.entityID); // } // // @Override // public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { // Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); // if (entity instanceof EntityPlayer) { // EMobile.proxy.playDiallingSound((EntityPlayer) entity); // } // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java // public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageTeleportParticles() { // } // // public MessageTeleportParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) { // EMobile.proxy.showTeleportParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // Path: src/main/java/tonius/emobile/util/ServerUtils.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import tonius.emobile.network.PacketHandler; import tonius.emobile.network.message.MessageDiallingParticles; import tonius.emobile.network.message.MessageDiallingSound; import tonius.emobile.network.message.MessageTeleportParticles; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; package tonius.emobile.util; public class ServerUtils { public static EntityPlayerMP getPlayerOnServer(String name) { return MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); } public static boolean isPlayerConnected(EntityPlayerMP player) { return MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player); } public static boolean canPlayerTeleport(EntityPlayerMP player) { return player != null && isPlayerConnected(player) && !player.isDead; } public static void sendGlobalChat(String chat) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(chat)); } public static void sendChatToPlayer(String player, String chat, EnumChatFormatting color) { EntityPlayerMP playerEntity = getPlayerOnServer(player); if (playerEntity != null) { ChatComponentText component = new ChatComponentText(chat); component.getChatStyle().setColor(color); playerEntity.addChatMessage(component); } } public static void sendChatToPlayer(String player, String chat) { sendChatToPlayer(player, chat, EnumChatFormatting.WHITE); } public static void sendDiallingSound(EntityPlayer player) {
PacketHandler.instance.sendToAllAround(new MessageDiallingSound(player.getEntityId()), new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 256));
Tonius/E-Mobile
src/main/java/tonius/emobile/util/ServerUtils.java
// Path: src/main/java/tonius/emobile/network/PacketHandler.java // public class PacketHandler { // // public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("EMobile"); // // public static void preInit() { // EMobile.logger.info("Registering network messages"); // instance.registerMessage(MessageCellphonePlayer.class, MessageCellphonePlayer.class, 0, Side.SERVER); // instance.registerMessage(MessageCellphoneAuthorize.class, MessageCellphoneAuthorize.class, 1, Side.SERVER); // instance.registerMessage(MessageCellphoneSpawn.class, MessageCellphoneSpawn.class, 2, Side.SERVER); // instance.registerMessage(MessageCellphoneHome.class, MessageCellphoneHome.class, 3, Side.SERVER); // instance.registerMessage(MessageCellphoneCancel.class, MessageCellphoneCancel.class, 4, Side.SERVER); // instance.registerMessage(MessageConfigSync.class, MessageConfigSync.class, 5, Side.CLIENT); // instance.registerMessage(MessageDiallingSound.class, MessageDiallingSound.class, 6, Side.CLIENT); // instance.registerMessage(MessageDiallingParticles.class, MessageDiallingParticles.class, 7, Side.CLIENT); // instance.registerMessage(MessageTeleportParticles.class, MessageTeleportParticles.class, 8, Side.CLIENT); // } // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java // public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageDiallingParticles() { // } // // public MessageDiallingParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) { // EMobile.proxy.showDiallingParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingSound.java // public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { // // public int entityID; // // public MessageDiallingSound() { // } // // public MessageDiallingSound(int entityID) { // this.entityID = entityID; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.entityID = buf.readInt(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeInt(this.entityID); // } // // @Override // public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { // Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); // if (entity instanceof EntityPlayer) { // EMobile.proxy.playDiallingSound((EntityPlayer) entity); // } // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java // public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageTeleportParticles() { // } // // public MessageTeleportParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) { // EMobile.proxy.showTeleportParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import tonius.emobile.network.PacketHandler; import tonius.emobile.network.message.MessageDiallingParticles; import tonius.emobile.network.message.MessageDiallingSound; import tonius.emobile.network.message.MessageTeleportParticles; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
package tonius.emobile.util; public class ServerUtils { public static EntityPlayerMP getPlayerOnServer(String name) { return MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); } public static boolean isPlayerConnected(EntityPlayerMP player) { return MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player); } public static boolean canPlayerTeleport(EntityPlayerMP player) { return player != null && isPlayerConnected(player) && !player.isDead; } public static void sendGlobalChat(String chat) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(chat)); } public static void sendChatToPlayer(String player, String chat, EnumChatFormatting color) { EntityPlayerMP playerEntity = getPlayerOnServer(player); if (playerEntity != null) { ChatComponentText component = new ChatComponentText(chat); component.getChatStyle().setColor(color); playerEntity.addChatMessage(component); } } public static void sendChatToPlayer(String player, String chat) { sendChatToPlayer(player, chat, EnumChatFormatting.WHITE); } public static void sendDiallingSound(EntityPlayer player) {
// Path: src/main/java/tonius/emobile/network/PacketHandler.java // public class PacketHandler { // // public static final SimpleNetworkWrapper instance = NetworkRegistry.INSTANCE.newSimpleChannel("EMobile"); // // public static void preInit() { // EMobile.logger.info("Registering network messages"); // instance.registerMessage(MessageCellphonePlayer.class, MessageCellphonePlayer.class, 0, Side.SERVER); // instance.registerMessage(MessageCellphoneAuthorize.class, MessageCellphoneAuthorize.class, 1, Side.SERVER); // instance.registerMessage(MessageCellphoneSpawn.class, MessageCellphoneSpawn.class, 2, Side.SERVER); // instance.registerMessage(MessageCellphoneHome.class, MessageCellphoneHome.class, 3, Side.SERVER); // instance.registerMessage(MessageCellphoneCancel.class, MessageCellphoneCancel.class, 4, Side.SERVER); // instance.registerMessage(MessageConfigSync.class, MessageConfigSync.class, 5, Side.CLIENT); // instance.registerMessage(MessageDiallingSound.class, MessageDiallingSound.class, 6, Side.CLIENT); // instance.registerMessage(MessageDiallingParticles.class, MessageDiallingParticles.class, 7, Side.CLIENT); // instance.registerMessage(MessageTeleportParticles.class, MessageTeleportParticles.class, 8, Side.CLIENT); // } // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingParticles.java // public class MessageDiallingParticles implements IMessage, IMessageHandler<MessageDiallingParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageDiallingParticles() { // } // // public MessageDiallingParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageDiallingParticles msg, MessageContext ctx) { // EMobile.proxy.showDiallingParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageDiallingSound.java // public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { // // public int entityID; // // public MessageDiallingSound() { // } // // public MessageDiallingSound(int entityID) { // this.entityID = entityID; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.entityID = buf.readInt(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeInt(this.entityID); // } // // @Override // public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { // Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); // if (entity instanceof EntityPlayer) { // EMobile.proxy.playDiallingSound((EntityPlayer) entity); // } // return null; // } // // } // // Path: src/main/java/tonius/emobile/network/message/MessageTeleportParticles.java // public class MessageTeleportParticles implements IMessage, IMessageHandler<MessageTeleportParticles, IMessage> { // // public double posX; // public double posY; // public double posZ; // // public MessageTeleportParticles() { // } // // public MessageTeleportParticles(double posX, double posY, double posZ) { // this.posX = posX; // this.posY = posY; // this.posZ = posZ; // } // // @Override // public void fromBytes(ByteBuf buf) { // this.posX = buf.readDouble(); // this.posY = buf.readDouble(); // this.posZ = buf.readDouble(); // } // // @Override // public void toBytes(ByteBuf buf) { // buf.writeDouble(this.posX); // buf.writeDouble(this.posY); // buf.writeDouble(this.posZ); // } // // @Override // public IMessage onMessage(MessageTeleportParticles msg, MessageContext ctx) { // EMobile.proxy.showTeleportParticles(msg.posX, msg.posY, msg.posZ); // return null; // } // // } // Path: src/main/java/tonius/emobile/util/ServerUtils.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import tonius.emobile.network.PacketHandler; import tonius.emobile.network.message.MessageDiallingParticles; import tonius.emobile.network.message.MessageDiallingSound; import tonius.emobile.network.message.MessageTeleportParticles; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; package tonius.emobile.util; public class ServerUtils { public static EntityPlayerMP getPlayerOnServer(String name) { return MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); } public static boolean isPlayerConnected(EntityPlayerMP player) { return MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player); } public static boolean canPlayerTeleport(EntityPlayerMP player) { return player != null && isPlayerConnected(player) && !player.isDead; } public static void sendGlobalChat(String chat) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(chat)); } public static void sendChatToPlayer(String player, String chat, EnumChatFormatting color) { EntityPlayerMP playerEntity = getPlayerOnServer(player); if (playerEntity != null) { ChatComponentText component = new ChatComponentText(chat); component.getChatStyle().setColor(color); playerEntity.addChatMessage(component); } } public static void sendChatToPlayer(String player, String chat) { sendChatToPlayer(player, chat, EnumChatFormatting.WHITE); } public static void sendDiallingSound(EntityPlayer player) {
PacketHandler.instance.sendToAllAround(new MessageDiallingSound(player.getEntityId()), new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 256));
Tonius/E-Mobile
src/main/java/tonius/emobile/config/ConfigGuiEM.java
// Path: src/main/java/tonius/emobile/config/EMConfig.java // public static class ConfigSection { // // public String name; // public String id; // // public ConfigSection(String name, String id) { // this.name = name; // this.id = id; // EMConfig.configSections.add(this); // } // // public String toLowerCase() { // return this.name.toLowerCase(); // } // // } // // Path: src/main/java/tonius/emobile/util/StringUtils.java // public class StringUtils { // private static DecimalFormat formatter = new DecimalFormat("###,###"); // // public static final String BLACK = (char) 167 + "0"; // public static final String BLUE = (char) 167 + "1"; // public static final String GREEN = (char) 167 + "2"; // public static final String TEAL = (char) 167 + "3"; // public static final String RED = (char) 167 + "4"; // public static final String PURPLE = (char) 167 + "5"; // public static final String ORANGE = (char) 167 + "6"; // public static final String LIGHT_GRAY = (char) 167 + "7"; // public static final String GRAY = (char) 167 + "8"; // public static final String LIGHT_BLUE = (char) 167 + "9"; // public static final String BRIGHT_GREEN = (char) 167 + "a"; // public static final String BRIGHT_BLUE = (char) 167 + "b"; // public static final String LIGHT_RED = (char) 167 + "c"; // public static final String PINK = (char) 167 + "d"; // public static final String YELLOW = (char) 167 + "e"; // public static final String WHITE = (char) 167 + "f"; // // public static final String OBFUSCATED = (char) 167 + "k"; // public static final String BOLD = (char) 167 + "l"; // public static final String STRIKETHROUGH = (char) 167 + "m"; // public static final String UNDERLINE = (char) 167 + "n"; // public static final String ITALIC = (char) 167 + "o"; // public static final String END = (char) 167 + "r"; // // public static boolean isAltKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); // } // // public static boolean isControlKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); // } // // public static boolean isShiftKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); // } // // public static String getScaledNumber(int number) { // return getScaledNumber(number, 2); // } // // public static String getScaledNumber(int number, int minDigits) { // String numString = ""; // // int numMod = 10 * minDigits; // // if (number > 100000 * numMod) { // numString += number / 1000000 + "M"; // } else if (number > 100 * numMod) { // numString += number / 1000 + "k"; // } else { // numString += number; // } // return numString; // } // // public static String getFormattedNumber(int number) { // return formatter.format(number); // } // // public static String getShiftText() { // return LIGHT_GRAY + String.format(translate("tooltip.holdShift"), YELLOW + ITALIC + "Shift" + END + LIGHT_GRAY); // } // // public static String translate(String unlocalized) { // return translate(unlocalized, true); // } // // public static String translate(String unlocalized, boolean prefix) { // if (prefix) { // return StatCollector.translateToLocal("emobile." + unlocalized); // } // return StatCollector.translateToLocal(unlocalized); // } // // public static void addGaugeTooltip(List lines, String name, String unit, int amount, int maxAmount) { // if (name != null) { // lines.add(name); // } // if (maxAmount > 0) { // lines.add(amount + " / " + maxAmount + " " + unit); // } else { // lines.add(amount + " " + unit); // } // } // // }
import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigElement; import tonius.emobile.config.EMConfig.ConfigSection; import tonius.emobile.util.StringUtils; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement;
package tonius.emobile.config; public class ConfigGuiEM extends GuiConfig { public ConfigGuiEM(GuiScreen parentScreen) {
// Path: src/main/java/tonius/emobile/config/EMConfig.java // public static class ConfigSection { // // public String name; // public String id; // // public ConfigSection(String name, String id) { // this.name = name; // this.id = id; // EMConfig.configSections.add(this); // } // // public String toLowerCase() { // return this.name.toLowerCase(); // } // // } // // Path: src/main/java/tonius/emobile/util/StringUtils.java // public class StringUtils { // private static DecimalFormat formatter = new DecimalFormat("###,###"); // // public static final String BLACK = (char) 167 + "0"; // public static final String BLUE = (char) 167 + "1"; // public static final String GREEN = (char) 167 + "2"; // public static final String TEAL = (char) 167 + "3"; // public static final String RED = (char) 167 + "4"; // public static final String PURPLE = (char) 167 + "5"; // public static final String ORANGE = (char) 167 + "6"; // public static final String LIGHT_GRAY = (char) 167 + "7"; // public static final String GRAY = (char) 167 + "8"; // public static final String LIGHT_BLUE = (char) 167 + "9"; // public static final String BRIGHT_GREEN = (char) 167 + "a"; // public static final String BRIGHT_BLUE = (char) 167 + "b"; // public static final String LIGHT_RED = (char) 167 + "c"; // public static final String PINK = (char) 167 + "d"; // public static final String YELLOW = (char) 167 + "e"; // public static final String WHITE = (char) 167 + "f"; // // public static final String OBFUSCATED = (char) 167 + "k"; // public static final String BOLD = (char) 167 + "l"; // public static final String STRIKETHROUGH = (char) 167 + "m"; // public static final String UNDERLINE = (char) 167 + "n"; // public static final String ITALIC = (char) 167 + "o"; // public static final String END = (char) 167 + "r"; // // public static boolean isAltKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); // } // // public static boolean isControlKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); // } // // public static boolean isShiftKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); // } // // public static String getScaledNumber(int number) { // return getScaledNumber(number, 2); // } // // public static String getScaledNumber(int number, int minDigits) { // String numString = ""; // // int numMod = 10 * minDigits; // // if (number > 100000 * numMod) { // numString += number / 1000000 + "M"; // } else if (number > 100 * numMod) { // numString += number / 1000 + "k"; // } else { // numString += number; // } // return numString; // } // // public static String getFormattedNumber(int number) { // return formatter.format(number); // } // // public static String getShiftText() { // return LIGHT_GRAY + String.format(translate("tooltip.holdShift"), YELLOW + ITALIC + "Shift" + END + LIGHT_GRAY); // } // // public static String translate(String unlocalized) { // return translate(unlocalized, true); // } // // public static String translate(String unlocalized, boolean prefix) { // if (prefix) { // return StatCollector.translateToLocal("emobile." + unlocalized); // } // return StatCollector.translateToLocal(unlocalized); // } // // public static void addGaugeTooltip(List lines, String name, String unit, int amount, int maxAmount) { // if (name != null) { // lines.add(name); // } // if (maxAmount > 0) { // lines.add(amount + " / " + maxAmount + " " + unit); // } else { // lines.add(amount + " " + unit); // } // } // // } // Path: src/main/java/tonius/emobile/config/ConfigGuiEM.java import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigElement; import tonius.emobile.config.EMConfig.ConfigSection; import tonius.emobile.util.StringUtils; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement; package tonius.emobile.config; public class ConfigGuiEM extends GuiConfig { public ConfigGuiEM(GuiScreen parentScreen) {
super(parentScreen, getConfigElements(parentScreen), "emobile", false, false, StringUtils.translate("config.title"));
Tonius/E-Mobile
src/main/java/tonius/emobile/config/ConfigGuiEM.java
// Path: src/main/java/tonius/emobile/config/EMConfig.java // public static class ConfigSection { // // public String name; // public String id; // // public ConfigSection(String name, String id) { // this.name = name; // this.id = id; // EMConfig.configSections.add(this); // } // // public String toLowerCase() { // return this.name.toLowerCase(); // } // // } // // Path: src/main/java/tonius/emobile/util/StringUtils.java // public class StringUtils { // private static DecimalFormat formatter = new DecimalFormat("###,###"); // // public static final String BLACK = (char) 167 + "0"; // public static final String BLUE = (char) 167 + "1"; // public static final String GREEN = (char) 167 + "2"; // public static final String TEAL = (char) 167 + "3"; // public static final String RED = (char) 167 + "4"; // public static final String PURPLE = (char) 167 + "5"; // public static final String ORANGE = (char) 167 + "6"; // public static final String LIGHT_GRAY = (char) 167 + "7"; // public static final String GRAY = (char) 167 + "8"; // public static final String LIGHT_BLUE = (char) 167 + "9"; // public static final String BRIGHT_GREEN = (char) 167 + "a"; // public static final String BRIGHT_BLUE = (char) 167 + "b"; // public static final String LIGHT_RED = (char) 167 + "c"; // public static final String PINK = (char) 167 + "d"; // public static final String YELLOW = (char) 167 + "e"; // public static final String WHITE = (char) 167 + "f"; // // public static final String OBFUSCATED = (char) 167 + "k"; // public static final String BOLD = (char) 167 + "l"; // public static final String STRIKETHROUGH = (char) 167 + "m"; // public static final String UNDERLINE = (char) 167 + "n"; // public static final String ITALIC = (char) 167 + "o"; // public static final String END = (char) 167 + "r"; // // public static boolean isAltKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); // } // // public static boolean isControlKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); // } // // public static boolean isShiftKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); // } // // public static String getScaledNumber(int number) { // return getScaledNumber(number, 2); // } // // public static String getScaledNumber(int number, int minDigits) { // String numString = ""; // // int numMod = 10 * minDigits; // // if (number > 100000 * numMod) { // numString += number / 1000000 + "M"; // } else if (number > 100 * numMod) { // numString += number / 1000 + "k"; // } else { // numString += number; // } // return numString; // } // // public static String getFormattedNumber(int number) { // return formatter.format(number); // } // // public static String getShiftText() { // return LIGHT_GRAY + String.format(translate("tooltip.holdShift"), YELLOW + ITALIC + "Shift" + END + LIGHT_GRAY); // } // // public static String translate(String unlocalized) { // return translate(unlocalized, true); // } // // public static String translate(String unlocalized, boolean prefix) { // if (prefix) { // return StatCollector.translateToLocal("emobile." + unlocalized); // } // return StatCollector.translateToLocal(unlocalized); // } // // public static void addGaugeTooltip(List lines, String name, String unit, int amount, int maxAmount) { // if (name != null) { // lines.add(name); // } // if (maxAmount > 0) { // lines.add(amount + " / " + maxAmount + " " + unit); // } else { // lines.add(amount + " " + unit); // } // } // // }
import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigElement; import tonius.emobile.config.EMConfig.ConfigSection; import tonius.emobile.util.StringUtils; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement;
package tonius.emobile.config; public class ConfigGuiEM extends GuiConfig { public ConfigGuiEM(GuiScreen parentScreen) { super(parentScreen, getConfigElements(parentScreen), "emobile", false, false, StringUtils.translate("config.title")); } private static List<IConfigElement> getConfigElements(GuiScreen parent) { List<IConfigElement> list = new ArrayList<IConfigElement>(); String prefix = "emobile.config.";
// Path: src/main/java/tonius/emobile/config/EMConfig.java // public static class ConfigSection { // // public String name; // public String id; // // public ConfigSection(String name, String id) { // this.name = name; // this.id = id; // EMConfig.configSections.add(this); // } // // public String toLowerCase() { // return this.name.toLowerCase(); // } // // } // // Path: src/main/java/tonius/emobile/util/StringUtils.java // public class StringUtils { // private static DecimalFormat formatter = new DecimalFormat("###,###"); // // public static final String BLACK = (char) 167 + "0"; // public static final String BLUE = (char) 167 + "1"; // public static final String GREEN = (char) 167 + "2"; // public static final String TEAL = (char) 167 + "3"; // public static final String RED = (char) 167 + "4"; // public static final String PURPLE = (char) 167 + "5"; // public static final String ORANGE = (char) 167 + "6"; // public static final String LIGHT_GRAY = (char) 167 + "7"; // public static final String GRAY = (char) 167 + "8"; // public static final String LIGHT_BLUE = (char) 167 + "9"; // public static final String BRIGHT_GREEN = (char) 167 + "a"; // public static final String BRIGHT_BLUE = (char) 167 + "b"; // public static final String LIGHT_RED = (char) 167 + "c"; // public static final String PINK = (char) 167 + "d"; // public static final String YELLOW = (char) 167 + "e"; // public static final String WHITE = (char) 167 + "f"; // // public static final String OBFUSCATED = (char) 167 + "k"; // public static final String BOLD = (char) 167 + "l"; // public static final String STRIKETHROUGH = (char) 167 + "m"; // public static final String UNDERLINE = (char) 167 + "n"; // public static final String ITALIC = (char) 167 + "o"; // public static final String END = (char) 167 + "r"; // // public static boolean isAltKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); // } // // public static boolean isControlKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); // } // // public static boolean isShiftKeyDown() { // return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); // } // // public static String getScaledNumber(int number) { // return getScaledNumber(number, 2); // } // // public static String getScaledNumber(int number, int minDigits) { // String numString = ""; // // int numMod = 10 * minDigits; // // if (number > 100000 * numMod) { // numString += number / 1000000 + "M"; // } else if (number > 100 * numMod) { // numString += number / 1000 + "k"; // } else { // numString += number; // } // return numString; // } // // public static String getFormattedNumber(int number) { // return formatter.format(number); // } // // public static String getShiftText() { // return LIGHT_GRAY + String.format(translate("tooltip.holdShift"), YELLOW + ITALIC + "Shift" + END + LIGHT_GRAY); // } // // public static String translate(String unlocalized) { // return translate(unlocalized, true); // } // // public static String translate(String unlocalized, boolean prefix) { // if (prefix) { // return StatCollector.translateToLocal("emobile." + unlocalized); // } // return StatCollector.translateToLocal(unlocalized); // } // // public static void addGaugeTooltip(List lines, String name, String unit, int amount, int maxAmount) { // if (name != null) { // lines.add(name); // } // if (maxAmount > 0) { // lines.add(amount + " / " + maxAmount + " " + unit); // } else { // lines.add(amount + " " + unit); // } // } // // } // Path: src/main/java/tonius/emobile/config/ConfigGuiEM.java import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigElement; import tonius.emobile.config.EMConfig.ConfigSection; import tonius.emobile.util.StringUtils; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement; package tonius.emobile.config; public class ConfigGuiEM extends GuiConfig { public ConfigGuiEM(GuiScreen parentScreen) { super(parentScreen, getConfigElements(parentScreen), "emobile", false, false, StringUtils.translate("config.title")); } private static List<IConfigElement> getConfigElements(GuiScreen parent) { List<IConfigElement> list = new ArrayList<IConfigElement>(); String prefix = "emobile.config.";
for (ConfigSection configSection : EMConfig.configSections) {
Tonius/E-Mobile
src/main/java/tonius/emobile/inventory/InventoryCellphone.java
// Path: src/main/java/tonius/emobile/item/ItemCellphone.java // public class ItemCellphone extends Item { // // public ItemCellphone() { // this.setMaxStackSize(1); // this.setUnlocalizedName("emobile.cellphone"); // this.setTextureName("emobile:cellphone"); // this.setCreativeTab(CreativeTabs.tabTools); // } // // public boolean useFuel(ItemStack cellphone, EntityPlayer player) { // return new InventoryCellphone(cellphone).useFuel(); // } // // @Override // public ItemStack onItemRightClick(ItemStack cellphone, World world, EntityPlayer player) { // if (!world.isRemote) { // player.openGui(EMobile.instance, EMGuiHandler.CELLPHONE_PEARL, world, 0, 0, 0); // } // // return cellphone; // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean bool) { // list.add(String.format(StringUtils.translate("tooltip.cellphone.pearls"), new InventoryCellphone(itemStack).getStoredPearls())); // } // // } // // Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import tonius.emobile.item.ItemCellphone; import tonius.emobile.util.StackUtils;
package tonius.emobile.inventory; public class InventoryCellphone implements IInventory { private ItemStack cellphone; private ItemStack[] inv = new ItemStack[1]; public InventoryCellphone(ItemStack cellphone) {
// Path: src/main/java/tonius/emobile/item/ItemCellphone.java // public class ItemCellphone extends Item { // // public ItemCellphone() { // this.setMaxStackSize(1); // this.setUnlocalizedName("emobile.cellphone"); // this.setTextureName("emobile:cellphone"); // this.setCreativeTab(CreativeTabs.tabTools); // } // // public boolean useFuel(ItemStack cellphone, EntityPlayer player) { // return new InventoryCellphone(cellphone).useFuel(); // } // // @Override // public ItemStack onItemRightClick(ItemStack cellphone, World world, EntityPlayer player) { // if (!world.isRemote) { // player.openGui(EMobile.instance, EMGuiHandler.CELLPHONE_PEARL, world, 0, 0, 0); // } // // return cellphone; // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean bool) { // list.add(String.format(StringUtils.translate("tooltip.cellphone.pearls"), new InventoryCellphone(itemStack).getStoredPearls())); // } // // } // // Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // } // Path: src/main/java/tonius/emobile/inventory/InventoryCellphone.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import tonius.emobile.item.ItemCellphone; import tonius.emobile.util.StackUtils; package tonius.emobile.inventory; public class InventoryCellphone implements IInventory { private ItemStack cellphone; private ItemStack[] inv = new ItemStack[1]; public InventoryCellphone(ItemStack cellphone) {
if (cellphone == null || !(cellphone.getItem() instanceof ItemCellphone)) {
Tonius/E-Mobile
src/main/java/tonius/emobile/inventory/InventoryCellphone.java
// Path: src/main/java/tonius/emobile/item/ItemCellphone.java // public class ItemCellphone extends Item { // // public ItemCellphone() { // this.setMaxStackSize(1); // this.setUnlocalizedName("emobile.cellphone"); // this.setTextureName("emobile:cellphone"); // this.setCreativeTab(CreativeTabs.tabTools); // } // // public boolean useFuel(ItemStack cellphone, EntityPlayer player) { // return new InventoryCellphone(cellphone).useFuel(); // } // // @Override // public ItemStack onItemRightClick(ItemStack cellphone, World world, EntityPlayer player) { // if (!world.isRemote) { // player.openGui(EMobile.instance, EMGuiHandler.CELLPHONE_PEARL, world, 0, 0, 0); // } // // return cellphone; // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean bool) { // list.add(String.format(StringUtils.translate("tooltip.cellphone.pearls"), new InventoryCellphone(itemStack).getStoredPearls())); // } // // } // // Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import tonius.emobile.item.ItemCellphone; import tonius.emobile.util.StackUtils;
package tonius.emobile.inventory; public class InventoryCellphone implements IInventory { private ItemStack cellphone; private ItemStack[] inv = new ItemStack[1]; public InventoryCellphone(ItemStack cellphone) { if (cellphone == null || !(cellphone.getItem() instanceof ItemCellphone)) { throw new IllegalArgumentException("Invalid ItemStack when creating a " + this.getClass().getSimpleName() + " instance"); } this.cellphone = cellphone;
// Path: src/main/java/tonius/emobile/item/ItemCellphone.java // public class ItemCellphone extends Item { // // public ItemCellphone() { // this.setMaxStackSize(1); // this.setUnlocalizedName("emobile.cellphone"); // this.setTextureName("emobile:cellphone"); // this.setCreativeTab(CreativeTabs.tabTools); // } // // public boolean useFuel(ItemStack cellphone, EntityPlayer player) { // return new InventoryCellphone(cellphone).useFuel(); // } // // @Override // public ItemStack onItemRightClick(ItemStack cellphone, World world, EntityPlayer player) { // if (!world.isRemote) { // player.openGui(EMobile.instance, EMGuiHandler.CELLPHONE_PEARL, world, 0, 0, 0); // } // // return cellphone; // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean bool) { // list.add(String.format(StringUtils.translate("tooltip.cellphone.pearls"), new InventoryCellphone(itemStack).getStoredPearls())); // } // // } // // Path: src/main/java/tonius/emobile/util/StackUtils.java // public class StackUtils { // // public static NBTTagCompound getNBT(ItemStack itemStack) { // if (itemStack.stackTagCompound == null) { // itemStack.stackTagCompound = new NBTTagCompound(); // } // return itemStack.stackTagCompound; // } // // public static ItemStack decrementStack(ItemStack itemStack) { // if (--itemStack.stackSize <= 0) { // itemStack = null; // } // return itemStack; // } // } // Path: src/main/java/tonius/emobile/inventory/InventoryCellphone.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import tonius.emobile.item.ItemCellphone; import tonius.emobile.util.StackUtils; package tonius.emobile.inventory; public class InventoryCellphone implements IInventory { private ItemStack cellphone; private ItemStack[] inv = new ItemStack[1]; public InventoryCellphone(ItemStack cellphone) { if (cellphone == null || !(cellphone.getItem() instanceof ItemCellphone)) { throw new IllegalArgumentException("Invalid ItemStack when creating a " + this.getClass().getSimpleName() + " instance"); } this.cellphone = cellphone;
this.readFromNBT(StackUtils.getNBT(cellphone));
Tonius/E-Mobile
src/main/java/tonius/emobile/network/message/MessageDiallingSound.java
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // }
import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import tonius.emobile.EMobile; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
package tonius.emobile.network.message; public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { public int entityID; public MessageDiallingSound() { } public MessageDiallingSound(int entityID) { this.entityID = entityID; } @Override public void fromBytes(ByteBuf buf) { this.entityID = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.entityID); } @Override public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); if (entity instanceof EntityPlayer) {
// Path: src/main/java/tonius/emobile/EMobile.java // @Mod(modid = "emobile", guiFactory = "tonius.emobile.config.ConfigGuiFactoryEM", dependencies = "after:ThermalExpansion") // public class EMobile { // // @Instance("emobile") // public static EMobile instance; // @SidedProxy(serverSide = "tonius.emobile.CommonProxy", clientSide = "tonius.emobile.client.ClientProxy") // public static CommonProxy proxy; // public static Logger logger; // // public static ItemCellphone cellphone = null; // public static ItemCellphoneRF cellphoneRF = null; // // @EventHandler // public void preInit(FMLPreInitializationEvent evt) { // logger = evt.getModLog(); // logger.info("Starting E-Mobile"); // // EMConfig.preInit(evt); // // if (EMConfig.enderPearlStackSize != Items.ender_pearl.getItemStackLimit()) { // logger.info("Setting new Ender Pearl stack size"); // Items.ender_pearl.setMaxStackSize(EMConfig.enderPearlStackSize); // } // // logger.info("Registering items"); // cellphone = new ItemCellphone(); // GameRegistry.registerItem(cellphone, "cellphone"); // if (EMConfig.fluxCellphoneEnabled) { // cellphoneRF = new ItemCellphoneRF(EMConfig.fluxCellphoneMaxEnergy, EMConfig.fluxCellphoneMaxInput, EMConfig.fluxCellphoneEnergyPerUse); // GameRegistry.registerItem(cellphoneRF, "cellphoneRF"); // } // // logger.info("Registering handlers"); // PacketHandler.preInit(); // NetworkRegistry.INSTANCE.registerGuiHandler(this, new EMGuiHandler()); // FMLCommonHandler.instance().bus().register(instance); // FMLCommonHandler.instance().bus().register(new CellphoneSessionsHandler()); // if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { // FMLCommonHandler.instance().bus().register(new ClientConfigTickHandler()); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent evt) { // logger.info("Registering recipes"); // if (Loader.isModLoaded("ThermalExpansion")) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "nuggetCopper", 'I', "ingotInvar", 'P', GameRegistry.findItemStack("ThermalFoundation", "bucketEnder", 1) })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "III", 'S', GameRegistry.findItemStack("ThermalExpansion", "powerCoilGold", 1), 'I', "ingotSignalum", 'P', cellphone })); // } // } else { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphone, new Object[] { " IS", "IPI", "III", 'S', "stickWood", 'I', "ingotIron", 'P', Items.ender_pearl })); // if (cellphoneRF != null) { // GameRegistry.addRecipe(new ShapedOreRecipe(cellphoneRF, new Object[] { " IS", "IPI", "RIR", 'S', "gemDiamond", 'I', "ingotGold", 'P', cellphone, 'R', "dustRedstone" })); // } // } // } // // @SubscribeEvent // public void onPlayerLoggedIn(PlayerLoggedInEvent evt) { // PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player); // } // // } // Path: src/main/java/tonius/emobile/network/message/MessageDiallingSound.java import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import tonius.emobile.EMobile; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; package tonius.emobile.network.message; public class MessageDiallingSound implements IMessage, IMessageHandler<MessageDiallingSound, IMessage> { public int entityID; public MessageDiallingSound() { } public MessageDiallingSound(int entityID) { this.entityID = entityID; } @Override public void fromBytes(ByteBuf buf) { this.entityID = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.entityID); } @Override public IMessage onMessage(MessageDiallingSound msg, MessageContext ctx) { Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityID); if (entity instanceof EntityPlayer) {
EMobile.proxy.playDiallingSound((EntityPlayer) entity);
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/util/AppInfo.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/App.java // public class App extends Application { // // public static Application app; // public static Stage stage; // protected static Scene scene; // protected static FXMLLoader fxmlLoader; // // @Override // public void start(Stage stage) throws IOException { // App.stage = stage; // App.app = this; // scene = new Scene(loadFXML("primary")); // stage.setScene(scene); // Image icon = new Image(getClass().getResourceAsStream("icons/Icon.png")); // stage.getIcons().add(icon); // stage.show(); // // stage.setMinWidth(scene.getRoot().minWidth(-1)); // // stage.setMinHeight(scene.getRoot().minHeight(-1)+10); // stage.setMinWidth(832); // stage.setMinHeight(582); // } // // static void setRoot(String fxml) throws IOException { // scene.setRoot(loadFXML(fxml)); // } // // private static Parent loadFXML(String fxml) throws IOException { // fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); // return fxmlLoader.load(); // } // // public static void main(String[] args) { // launch(); // } // // }
import com.botthoughts.wheelencodergenerator.App; import java.io.IOException; import java.io.InputStream; import java.util.Properties;
/* * Copyright 2021 mes. * * 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.botthoughts.util; /** * Container for application info, read from /app.properties file which needs the following * properties defined. * * name: name of the application * abbr: abbreviated name of the application * description: description of application * version: the version of the application * platform: the os family the build targets * build.date: date of the build * author: author of the application * * @author mes */ public class AppInfo { private static AppInfo me; private static String version; private static String author; private static String name; private static String abbr; private static String platform; private static String buildDate; private static String description; /** * Private constructor for Singleton. * Create a new AppInfo object, loading info from properties file and populating fields. * @throws IOException */ private AppInfo() throws IOException { Properties properties = new Properties();
// Path: src/main/java/com/botthoughts/wheelencodergenerator/App.java // public class App extends Application { // // public static Application app; // public static Stage stage; // protected static Scene scene; // protected static FXMLLoader fxmlLoader; // // @Override // public void start(Stage stage) throws IOException { // App.stage = stage; // App.app = this; // scene = new Scene(loadFXML("primary")); // stage.setScene(scene); // Image icon = new Image(getClass().getResourceAsStream("icons/Icon.png")); // stage.getIcons().add(icon); // stage.show(); // // stage.setMinWidth(scene.getRoot().minWidth(-1)); // // stage.setMinHeight(scene.getRoot().minHeight(-1)+10); // stage.setMinWidth(832); // stage.setMinHeight(582); // } // // static void setRoot(String fxml) throws IOException { // scene.setRoot(loadFXML(fxml)); // } // // private static Parent loadFXML(String fxml) throws IOException { // fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); // return fxmlLoader.load(); // } // // public static void main(String[] args) { // launch(); // } // // } // Path: src/main/java/com/botthoughts/util/AppInfo.java import com.botthoughts.wheelencodergenerator.App; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /* * Copyright 2021 mes. * * 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.botthoughts.util; /** * Container for application info, read from /app.properties file which needs the following * properties defined. * * name: name of the application * abbr: abbreviated name of the application * description: description of application * version: the version of the application * platform: the os family the build targets * build.date: date of the build * author: author of the application * * @author mes */ public class AppInfo { private static AppInfo me; private static String version; private static String author; private static String name; private static String abbr; private static String platform; private static String buildDate; private static String description; /** * Private constructor for Singleton. * Create a new AppInfo object, loading info from properties file and populating fields. * @throws IOException */ private AppInfo() throws IOException { Properties properties = new Properties();
InputStream stream = App.class.getResourceAsStream("/app.properties");
shimniok/WheelEncoderGenerator
src/test/java/com/botthoughts/wheelencodergenerator/model/GrayEncoderTest.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java // public class GrayEncoder extends BinaryEncoder { // // /** // * Return list of ordered Track objects for this encoder. Track information is computed on-demand // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution // * @param index ignored because it doesn't make sense for this type of encoder // * @return list of tracks // */ // @Override // public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise) { // double tw = (od - id) / resolution; // track width // double angle = 0; // double start; // int res = 0; // // tracks = new ArrayList<>(); // // id = od - tw; // for (int b = resolution - 1; b >= 0; b--) { // if (b == 0) { // /** // * for the final, innermost track, we still have 2 stripes, black and white, covering // * the same angle of 180°, but rotated ±90 degrees from the previous track (-90 for // * clockwise, +90 for counter-clockwise) // */ // if (clockwise) { // start = 180; // } else { // start = 0; // } // } else { // /** // * for all the other tracks, the number of black and white stripes is 2^b with the first // * stripe centered on 0 degrees // */ // res = 1 << b; // angle = 360.0 / res; // start = angle / 2; // } // // tracks.add(new EncoderTrack(od, id, start, angle, res)); // od -= tw; // id -= tw; // } // // return tracks; // } // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import com.botthoughts.wheelencodergenerator.model.GrayEncoder; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class GrayEncoderTest { private static final double TOL = 0.00001; public GrayEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class GrayEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 44.0; int resolution = 3; boolean index = false; boolean clockwise = false;
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java // public class GrayEncoder extends BinaryEncoder { // // /** // * Return list of ordered Track objects for this encoder. Track information is computed on-demand // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution // * @param index ignored because it doesn't make sense for this type of encoder // * @return list of tracks // */ // @Override // public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise) { // double tw = (od - id) / resolution; // track width // double angle = 0; // double start; // int res = 0; // // tracks = new ArrayList<>(); // // id = od - tw; // for (int b = resolution - 1; b >= 0; b--) { // if (b == 0) { // /** // * for the final, innermost track, we still have 2 stripes, black and white, covering // * the same angle of 180°, but rotated ±90 degrees from the previous track (-90 for // * clockwise, +90 for counter-clockwise) // */ // if (clockwise) { // start = 180; // } else { // start = 0; // } // } else { // /** // * for all the other tracks, the number of black and white stripes is 2^b with the first // * stripe centered on 0 degrees // */ // res = 1 << b; // angle = 360.0 / res; // start = angle / 2; // } // // tracks.add(new EncoderTrack(od, id, start, angle, res)); // od -= tw; // id -= tw; // } // // return tracks; // } // } // Path: src/test/java/com/botthoughts/wheelencodergenerator/model/GrayEncoderTest.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import com.botthoughts.wheelencodergenerator.model.GrayEncoder; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class GrayEncoderTest { private static final double TOL = 0.00001; public GrayEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class GrayEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 44.0; int resolution = 3; boolean index = false; boolean clockwise = false;
GrayEncoder instance = new GrayEncoder();
shimniok/WheelEncoderGenerator
src/test/java/com/botthoughts/wheelencodergenerator/model/GrayEncoderTest.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java // public class GrayEncoder extends BinaryEncoder { // // /** // * Return list of ordered Track objects for this encoder. Track information is computed on-demand // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution // * @param index ignored because it doesn't make sense for this type of encoder // * @return list of tracks // */ // @Override // public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise) { // double tw = (od - id) / resolution; // track width // double angle = 0; // double start; // int res = 0; // // tracks = new ArrayList<>(); // // id = od - tw; // for (int b = resolution - 1; b >= 0; b--) { // if (b == 0) { // /** // * for the final, innermost track, we still have 2 stripes, black and white, covering // * the same angle of 180°, but rotated ±90 degrees from the previous track (-90 for // * clockwise, +90 for counter-clockwise) // */ // if (clockwise) { // start = 180; // } else { // start = 0; // } // } else { // /** // * for all the other tracks, the number of black and white stripes is 2^b with the first // * stripe centered on 0 degrees // */ // res = 1 << b; // angle = 360.0 / res; // start = angle / 2; // } // // tracks.add(new EncoderTrack(od, id, start, angle, res)); // od -= tw; // id -= tw; // } // // return tracks; // } // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import com.botthoughts.wheelencodergenerator.model.GrayEncoder; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class GrayEncoderTest { private static final double TOL = 0.00001; public GrayEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class GrayEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 44.0; int resolution = 3; boolean index = false; boolean clockwise = false; GrayEncoder instance = new GrayEncoder();
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java // public class GrayEncoder extends BinaryEncoder { // // /** // * Return list of ordered Track objects for this encoder. Track information is computed on-demand // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution // * @param index ignored because it doesn't make sense for this type of encoder // * @return list of tracks // */ // @Override // public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise) { // double tw = (od - id) / resolution; // track width // double angle = 0; // double start; // int res = 0; // // tracks = new ArrayList<>(); // // id = od - tw; // for (int b = resolution - 1; b >= 0; b--) { // if (b == 0) { // /** // * for the final, innermost track, we still have 2 stripes, black and white, covering // * the same angle of 180°, but rotated ±90 degrees from the previous track (-90 for // * clockwise, +90 for counter-clockwise) // */ // if (clockwise) { // start = 180; // } else { // start = 0; // } // } else { // /** // * for all the other tracks, the number of black and white stripes is 2^b with the first // * stripe centered on 0 degrees // */ // res = 1 << b; // angle = 360.0 / res; // start = angle / 2; // } // // tracks.add(new EncoderTrack(od, id, start, angle, res)); // od -= tw; // id -= tw; // } // // return tracks; // } // } // Path: src/test/java/com/botthoughts/wheelencodergenerator/model/GrayEncoderTest.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import com.botthoughts.wheelencodergenerator.model.GrayEncoder; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class GrayEncoderTest { private static final double TOL = 0.00001; public GrayEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class GrayEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 44.0; int resolution = 3; boolean index = false; boolean clockwise = false; GrayEncoder instance = new GrayEncoder();
List<EncoderTrack> result = instance.getTracks(id, od, resolution, index, clockwise);
shimniok/WheelEncoderGenerator
src/test/java/com/botthoughts/wheelencodergenerator/model/BasicEncoderTest.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import java.util.function.UnaryOperator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class BasicEncoderTest { private static final double TOL = 0.00001; public BasicEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class BasicEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 11.0; double od = 66.0; int resolution = 64; boolean index = true; boolean clockwise = false; BasicEncoder instance = new BasicEncoder();
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/test/java/com/botthoughts/wheelencodergenerator/model/BasicEncoderTest.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import java.util.function.UnaryOperator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class BasicEncoderTest { private static final double TOL = 0.00001; public BasicEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class BasicEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 11.0; double od = 66.0; int resolution = 64; boolean index = true; boolean clockwise = false; BasicEncoder instance = new BasicEncoder();
List<EncoderTrack> tracks = instance.getTracks(id, od, resolution, index, clockwise);
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Gray-code encoder model is a type of binary encoder (See BinaryEncoder) encoder identical in * every respect except the bit pattern between any two positions differs only by a single bit * (e.g, 00, 01, 11, 10). * @author mes */ public class GrayEncoder extends BinaryEncoder { /** * Return list of ordered Track objects for this encoder. Track information is computed on-demand * * @param id Inside diameter * @param od Outside diameter * @param resolution * @param index ignored because it doesn't make sense for this type of encoder * @return list of tracks */ @Override
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/GrayEncoder.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Gray-code encoder model is a type of binary encoder (See BinaryEncoder) encoder identical in * every respect except the bit pattern between any two positions differs only by a single bit * (e.g, 00, 01, 11, 10). * @author mes */ public class GrayEncoder extends BinaryEncoder { /** * Return list of ordered Track objects for this encoder. Track information is computed on-demand * * @param id Inside diameter * @param od Outside diameter * @param resolution * @param index ignored because it doesn't make sense for this type of encoder * @return list of tracks */ @Override
public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index,
shimniok/WheelEncoderGenerator
src/test/java/com/botthoughts/wheelencodergenerator/model/BinaryEncoderTest.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MIN-1); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MIN-2); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MAX+1); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MAX+1); assertEquals(false, result); for (int i=instance.RESOLUTION_MIN; i <= instance.RESOLUTION_MAX; i++) { result = instance.validResolution(i); assertEquals(true, result); } } /** * Test of getTracks method, of class BinaryEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 45.0; int resolution = 5; boolean index = false; boolean clockwise = false; BinaryEncoder instance = new BinaryEncoder();
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/test/java/com/botthoughts/wheelencodergenerator/model/BinaryEncoderTest.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MIN-1); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MIN-2); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MAX+1); assertEquals(false, result); result = instance.validResolution(instance.RESOLUTION_MAX+1); assertEquals(false, result); for (int i=instance.RESOLUTION_MIN; i <= instance.RESOLUTION_MAX; i++) { result = instance.validResolution(i); assertEquals(true, result); } } /** * Test of getTracks method, of class BinaryEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 22.0; double od = 45.0; int resolution = 5; boolean index = false; boolean clockwise = false; BinaryEncoder instance = new BinaryEncoder();
List<EncoderTrack> result = instance.getTracks(id, od, resolution, index, clockwise);
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/wheelencodergenerator/EncoderView.java
// Path: src/main/java/com/botthoughts/util/ResizeableCanvas.java // abstract public class ResizeableCanvas extends Canvas { // // public ResizeableCanvas() { // super(); // // Redraw canvas when size changes. // widthProperty().addListener(evt -> draw()); // heightProperty().addListener(evt -> draw()); // } // // public ResizeableCanvas(double width, double height) { // this(); // this.setWidth(width); // this.setHeight(height); // } // // abstract protected void draw(); // // @Override // public boolean isResizable() { // return true; // } // // @Override // public double prefWidth(double height) { // return getWidth(); // } // // @Override // public double prefHeight(double width) { // return getHeight(); // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/EncoderModel.java // public interface EncoderModel { // // /** // * Return minimum resolution for the encoder. // * // * @return min resolution // */ // abstract public int getMinResolution(); // // /** // * Return maximum resolution for the encoder. // * // * @return max resolution // */ // abstract public int getMaxResolution(); // // /** // * Return the UnaryOperator for incrementing resolution // * // * @return resolution increment value // */ // abstract public UnaryOperator<Integer> getResolutionIncrement(); // // /** // * Return the UnaryOperator for decrementing resolution // * // * @return resolution increment value // */ // abstract public UnaryOperator<Integer> getResolutionDecrement(); // // /** // * Return list of ordered Track objects for this encoder.Track information is computed on-demand. // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution Resolution of encoder // * @param index include index track // * @param clockwise true if encoder is designed to rotate clockwise // * @return list of tracks // */ // abstract public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise); // // /** // * Determine if provided resolution is valid for encoder type // * // * @param resolution // * @return true if resolution is valid, false otherwise // */ // abstract public boolean validResolution(int resolution); // // /** // * If resolution is not valid, set it to the nearest valid value. // * @param resolution is the encoder resolution // * @return resolution, if valid, or the nearest valid value // */ // abstract public int fixResolution(int resolution); // // /** // * Indicates whether the encoder is indexable or not. // * @return true only if the encoder supports an index track // */ // abstract public boolean isIndexable(); // // /** // * Returns the directionality of the encoder // * @return true if the encoder is directional, false if non-directional. // */ // abstract public boolean isDirectional(); // // }
import com.botthoughts.util.ResizeableCanvas; import com.botthoughts.wheelencodergenerator.model.EncoderModel; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.scene.shape.ArcType;
double od = t.outerDiameter * scale; double id = t.innerDiameter * scale; gc.setFill(backgroundColor); gc.fillOval(x1, y1, od, od); // Draw the stripes for the track gc.setFill(foregroundColor); for (int s = 0; s < t.stripeCount; s += 2) { gc.fillArc(x1, y1, od, od, t.startAngle + s * t.stripeAngle, t.stripeAngle, ArcType.ROUND); } // Draw outside stroke gc.setStroke(foregroundColor); gc.strokeOval(x1, y1, od, od); // Draw inner circle double trackWidth = (t.outerDiameter - t.innerDiameter) * scale / 2; gc.setFill(backgroundColor); gc.fillOval(x1 + trackWidth, y1 + trackWidth, id, id); gc.strokeOval(x1 + trackWidth, y1 + trackWidth, id, id); } /** * Render the encoder on our canvas */ @Override public void draw() {
// Path: src/main/java/com/botthoughts/util/ResizeableCanvas.java // abstract public class ResizeableCanvas extends Canvas { // // public ResizeableCanvas() { // super(); // // Redraw canvas when size changes. // widthProperty().addListener(evt -> draw()); // heightProperty().addListener(evt -> draw()); // } // // public ResizeableCanvas(double width, double height) { // this(); // this.setWidth(width); // this.setHeight(height); // } // // abstract protected void draw(); // // @Override // public boolean isResizable() { // return true; // } // // @Override // public double prefWidth(double height) { // return getWidth(); // } // // @Override // public double prefHeight(double width) { // return getHeight(); // } // // } // // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/EncoderModel.java // public interface EncoderModel { // // /** // * Return minimum resolution for the encoder. // * // * @return min resolution // */ // abstract public int getMinResolution(); // // /** // * Return maximum resolution for the encoder. // * // * @return max resolution // */ // abstract public int getMaxResolution(); // // /** // * Return the UnaryOperator for incrementing resolution // * // * @return resolution increment value // */ // abstract public UnaryOperator<Integer> getResolutionIncrement(); // // /** // * Return the UnaryOperator for decrementing resolution // * // * @return resolution increment value // */ // abstract public UnaryOperator<Integer> getResolutionDecrement(); // // /** // * Return list of ordered Track objects for this encoder.Track information is computed on-demand. // * // * @param id Inside diameter // * @param od Outside diameter // * @param resolution Resolution of encoder // * @param index include index track // * @param clockwise true if encoder is designed to rotate clockwise // * @return list of tracks // */ // abstract public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index, // boolean clockwise); // // /** // * Determine if provided resolution is valid for encoder type // * // * @param resolution // * @return true if resolution is valid, false otherwise // */ // abstract public boolean validResolution(int resolution); // // /** // * If resolution is not valid, set it to the nearest valid value. // * @param resolution is the encoder resolution // * @return resolution, if valid, or the nearest valid value // */ // abstract public int fixResolution(int resolution); // // /** // * Indicates whether the encoder is indexable or not. // * @return true only if the encoder supports an index track // */ // abstract public boolean isIndexable(); // // /** // * Returns the directionality of the encoder // * @return true if the encoder is directional, false if non-directional. // */ // abstract public boolean isDirectional(); // // } // Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderView.java import com.botthoughts.util.ResizeableCanvas; import com.botthoughts.wheelencodergenerator.model.EncoderModel; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.scene.shape.ArcType; double od = t.outerDiameter * scale; double id = t.innerDiameter * scale; gc.setFill(backgroundColor); gc.fillOval(x1, y1, od, od); // Draw the stripes for the track gc.setFill(foregroundColor); for (int s = 0; s < t.stripeCount; s += 2) { gc.fillArc(x1, y1, od, od, t.startAngle + s * t.stripeAngle, t.stripeAngle, ArcType.ROUND); } // Draw outside stroke gc.setStroke(foregroundColor); gc.strokeOval(x1, y1, od, od); // Draw inner circle double trackWidth = (t.outerDiameter - t.innerDiameter) * scale / 2; gc.setFill(backgroundColor); gc.fillOval(x1 + trackWidth, y1 + trackWidth, id, id); gc.strokeOval(x1 + trackWidth, y1 + trackWidth, id, id); } /** * Render the encoder on our canvas */ @Override public void draw() {
EncoderModel enc = ep.getEncoder();
shimniok/WheelEncoderGenerator
src/test/java/com/botthoughts/wheelencodergenerator/model/QuadratureEncoderTest.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class QuadratureEncoderTest { public QuadratureEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class QuadratureEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 11.0; double od = 77.0; int resolution = 20; boolean index = true; boolean clockwise = false; QuadratureEncoder instance = new QuadratureEncoder();
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/test/java/com/botthoughts/wheelencodergenerator/model/QuadratureEncoderTest.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * * @author mes */ public class QuadratureEncoderTest { public QuadratureEncoderTest() { } @BeforeAll public static void setUpClass() { } @AfterAll public static void tearDownClass() { } @BeforeEach public void setUp() { } @AfterEach public void tearDown() { } /** * Test of getTracks method, of class QuadratureEncoder. */ @Test public void testGetTracks() { System.out.println("getTracks"); double id = 11.0; double od = 77.0; int resolution = 20; boolean index = true; boolean clockwise = false; QuadratureEncoder instance = new QuadratureEncoder();
List<EncoderTrack> tracks = instance.getTracks(id, od, resolution, index, clockwise);
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/wheelencodergenerator/model/QuadratureEncoder.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Quadrature encoder model consisting of two tracks of stripes, offset to detect direction of * rotation, and an optional index track. * @author mes */ public class QuadratureEncoder extends BasicEncoder { /** * Create a new quadrature encoder model */ public QuadratureEncoder() { super(); this.DIRECTIONAL = true; } /** * Return list of ordered Track objects for this encoder.Track information is computed on-demand * * @param id inside diameter of track * @param od outside diameter of track * @param resolution number of black stripes on track * @param index include index track? * @return list of tracks */ @Override
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/QuadratureEncoder.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Quadrature encoder model consisting of two tracks of stripes, offset to detect direction of * rotation, and an optional index track. * @author mes */ public class QuadratureEncoder extends BasicEncoder { /** * Create a new quadrature encoder model */ public QuadratureEncoder() { super(); this.DIRECTIONAL = true; } /** * Return list of ordered Track objects for this encoder.Track information is computed on-demand * * @param id inside diameter of track * @param od outside diameter of track * @param resolution number of black stripes on track * @param index include index track? * @return list of tracks */ @Override
public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index,
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/wheelencodergenerator/model/BinaryEncoder.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Binary encoder model is a type of absolute position encoder consisting of n tracks to achieve * 2^n unique positions represented by sequential binary numbers (e.g, 00, 01, 11, 10). This * encoder is directional, and doesn't have a separate index track because it is superfluous for * an absolute encoder. * @author mes */ public class BinaryEncoder extends BasicEncoder { /** * Create a new binary encoder with a minimum resolution of 1 bit (2 positions) and maximum * resolution of 11 bits (2048 positions) */ public BinaryEncoder() { this.RESOLUTION_MIN = 1; this.RESOLUTION_MAX = 11; this.INCREMENT = 1; this.INDEXABLE = false; this.DIRECTIONAL = true; } /** * Return list of ordered Track objects for this encoder. Tracks are computed on-demand based on * current properties * * @param id Inside diameter * @param od Outside diameter * @param resolution is the number of "bits" or separate tracks * @param index is ignored for binary * @param clockwise is true if encoder designed for clockwise rotation * @return list of tracks */ @Override
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/BinaryEncoder.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.ArrayList; import java.util.List; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Binary encoder model is a type of absolute position encoder consisting of n tracks to achieve * 2^n unique positions represented by sequential binary numbers (e.g, 00, 01, 11, 10). This * encoder is directional, and doesn't have a separate index track because it is superfluous for * an absolute encoder. * @author mes */ public class BinaryEncoder extends BasicEncoder { /** * Create a new binary encoder with a minimum resolution of 1 bit (2 positions) and maximum * resolution of 11 bits (2048 positions) */ public BinaryEncoder() { this.RESOLUTION_MIN = 1; this.RESOLUTION_MAX = 11; this.INCREMENT = 1; this.INDEXABLE = false; this.DIRECTIONAL = true; } /** * Return list of ordered Track objects for this encoder. Tracks are computed on-demand based on * current properties * * @param id Inside diameter * @param od Outside diameter * @param resolution is the number of "bits" or separate tracks * @param index is ignored for binary * @param clockwise is true if encoder designed for clockwise rotation * @return list of tracks */ @Override
public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index,
shimniok/WheelEncoderGenerator
src/main/java/com/botthoughts/wheelencodergenerator/model/EncoderModel.java
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // }
import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import java.util.function.UnaryOperator;
/* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Functionality required of--and unique to--each encoder type. * @author mes */ public interface EncoderModel { /** * Return minimum resolution for the encoder. * * @return min resolution */ abstract public int getMinResolution(); /** * Return maximum resolution for the encoder. * * @return max resolution */ abstract public int getMaxResolution(); /** * Return the UnaryOperator for incrementing resolution * * @return resolution increment value */ abstract public UnaryOperator<Integer> getResolutionIncrement(); /** * Return the UnaryOperator for decrementing resolution * * @return resolution increment value */ abstract public UnaryOperator<Integer> getResolutionDecrement(); /** * Return list of ordered Track objects for this encoder.Track information is computed on-demand. * * @param id Inside diameter * @param od Outside diameter * @param resolution Resolution of encoder * @param index include index track * @param clockwise true if encoder is designed to rotate clockwise * @return list of tracks */
// Path: src/main/java/com/botthoughts/wheelencodergenerator/EncoderTrack.java // public class EncoderTrack { // public double outerDiameter; // public double innerDiameter; // public double startAngle; // public double stripeAngle; // public int stripeCount; // // /** // * // * @param outerDiameter outer diameter (all units managed externally) // * @param innerDiameter inner diameter // * @param startAngle starting angle for first stripe in degrees // * @param stripeSweepAngle angle of each white and black stripe // * @param stripeCount number of black stripes // */ // public EncoderTrack(double outerDiameter, double innerDiameter, double startAngle, // double stripeSweepAngle, int stripeCount) { // this.outerDiameter = outerDiameter; // this.innerDiameter = innerDiameter; // this.startAngle = startAngle; // this.stripeAngle = stripeSweepAngle; // this.stripeCount = stripeCount; // } // // } // Path: src/main/java/com/botthoughts/wheelencodergenerator/model/EncoderModel.java import com.botthoughts.wheelencodergenerator.EncoderTrack; import java.util.List; import java.util.function.UnaryOperator; /* * Copyright 2021 mes. * * 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.botthoughts.wheelencodergenerator.model; /** * Functionality required of--and unique to--each encoder type. * @author mes */ public interface EncoderModel { /** * Return minimum resolution for the encoder. * * @return min resolution */ abstract public int getMinResolution(); /** * Return maximum resolution for the encoder. * * @return max resolution */ abstract public int getMaxResolution(); /** * Return the UnaryOperator for incrementing resolution * * @return resolution increment value */ abstract public UnaryOperator<Integer> getResolutionIncrement(); /** * Return the UnaryOperator for decrementing resolution * * @return resolution increment value */ abstract public UnaryOperator<Integer> getResolutionDecrement(); /** * Return list of ordered Track objects for this encoder.Track information is computed on-demand. * * @param id Inside diameter * @param od Outside diameter * @param resolution Resolution of encoder * @param index include index track * @param clockwise true if encoder is designed to rotate clockwise * @return list of tracks */
abstract public List<EncoderTrack> getTracks(double id, double od, int resolution, boolean index,
r2bapps/TaskManager
TaskManagerTest/src/r2b/apps/test/taskmanager/custom/CustomAsyncTask.java
// Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/BaseAsyncTask.java // public abstract class BaseAsyncTask extends Task<Void> { // // /** // * Builder. // * @param id The task identifier. // * @param priority The task priority. // */ // public BaseAsyncTask(long id, PRIORITY priority) { // super(id); // init(this, priority); // } // // /** // * Builder, with the task default priority and identifier value zero. // */ // public BaseAsyncTask() { // super(0); // init(this, PRIORITY.DEFAULT); // } // // /* (non-Javadoc) // * @see r2b.apps.lib.taskmanager.Task#call() // */ // @Override // public final Void call() throws Exception { // return super.call(); // } // // } // // Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/PRIORITY.java // public enum PRIORITY { // // CRITICAL(0), VERY_HIGH(20), HIGH(40), DEFAULT(60), LOW(80), VERY_LOW(100); // // private int priority; // // PRIORITY(int priority) { // this.priority = priority; // } // // public int getValue() { // return priority; // } // // }
import r2b.apps.lib.taskmanager.BaseAsyncTask; import r2b.apps.lib.taskmanager.PRIORITY; import android.util.Log;
package r2b.apps.test.taskmanager.custom; public class CustomAsyncTask extends BaseAsyncTask { private static long DEFAULT_ID = 0; private static long DEFAULT_THREAD_ID = 0; private long sleep; private String name; private long threadId; public CustomAsyncTask(long sleep, String name) {
// Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/BaseAsyncTask.java // public abstract class BaseAsyncTask extends Task<Void> { // // /** // * Builder. // * @param id The task identifier. // * @param priority The task priority. // */ // public BaseAsyncTask(long id, PRIORITY priority) { // super(id); // init(this, priority); // } // // /** // * Builder, with the task default priority and identifier value zero. // */ // public BaseAsyncTask() { // super(0); // init(this, PRIORITY.DEFAULT); // } // // /* (non-Javadoc) // * @see r2b.apps.lib.taskmanager.Task#call() // */ // @Override // public final Void call() throws Exception { // return super.call(); // } // // } // // Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/PRIORITY.java // public enum PRIORITY { // // CRITICAL(0), VERY_HIGH(20), HIGH(40), DEFAULT(60), LOW(80), VERY_LOW(100); // // private int priority; // // PRIORITY(int priority) { // this.priority = priority; // } // // public int getValue() { // return priority; // } // // } // Path: TaskManagerTest/src/r2b/apps/test/taskmanager/custom/CustomAsyncTask.java import r2b.apps.lib.taskmanager.BaseAsyncTask; import r2b.apps.lib.taskmanager.PRIORITY; import android.util.Log; package r2b.apps.test.taskmanager.custom; public class CustomAsyncTask extends BaseAsyncTask { private static long DEFAULT_ID = 0; private static long DEFAULT_THREAD_ID = 0; private long sleep; private String name; private long threadId; public CustomAsyncTask(long sleep, String name) {
super(DEFAULT_ID, PRIORITY.DEFAULT);
r2bapps/TaskManager
TaskManagerTest/src/r2b/apps/test/taskmanager/custom/PriorityAsyncTask.java
// Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/BaseAsyncTask.java // public abstract class BaseAsyncTask extends Task<Void> { // // /** // * Builder. // * @param id The task identifier. // * @param priority The task priority. // */ // public BaseAsyncTask(long id, PRIORITY priority) { // super(id); // init(this, priority); // } // // /** // * Builder, with the task default priority and identifier value zero. // */ // public BaseAsyncTask() { // super(0); // init(this, PRIORITY.DEFAULT); // } // // /* (non-Javadoc) // * @see r2b.apps.lib.taskmanager.Task#call() // */ // @Override // public final Void call() throws Exception { // return super.call(); // } // // } // // Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/PRIORITY.java // public enum PRIORITY { // // CRITICAL(0), VERY_HIGH(20), HIGH(40), DEFAULT(60), LOW(80), VERY_LOW(100); // // private int priority; // // PRIORITY(int priority) { // this.priority = priority; // } // // public int getValue() { // return priority; // } // // }
import r2b.apps.lib.taskmanager.BaseAsyncTask; import r2b.apps.lib.taskmanager.PRIORITY; import android.util.Log;
package r2b.apps.test.taskmanager.custom; public class PriorityAsyncTask extends BaseAsyncTask { private static long DEFAULT_THREAD_ID = 0; private long sleep; private String name; private long threadId; private long beginExecution = -1;
// Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/BaseAsyncTask.java // public abstract class BaseAsyncTask extends Task<Void> { // // /** // * Builder. // * @param id The task identifier. // * @param priority The task priority. // */ // public BaseAsyncTask(long id, PRIORITY priority) { // super(id); // init(this, priority); // } // // /** // * Builder, with the task default priority and identifier value zero. // */ // public BaseAsyncTask() { // super(0); // init(this, PRIORITY.DEFAULT); // } // // /* (non-Javadoc) // * @see r2b.apps.lib.taskmanager.Task#call() // */ // @Override // public final Void call() throws Exception { // return super.call(); // } // // } // // Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/PRIORITY.java // public enum PRIORITY { // // CRITICAL(0), VERY_HIGH(20), HIGH(40), DEFAULT(60), LOW(80), VERY_LOW(100); // // private int priority; // // PRIORITY(int priority) { // this.priority = priority; // } // // public int getValue() { // return priority; // } // // } // Path: TaskManagerTest/src/r2b/apps/test/taskmanager/custom/PriorityAsyncTask.java import r2b.apps.lib.taskmanager.BaseAsyncTask; import r2b.apps.lib.taskmanager.PRIORITY; import android.util.Log; package r2b.apps.test.taskmanager.custom; public class PriorityAsyncTask extends BaseAsyncTask { private static long DEFAULT_THREAD_ID = 0; private long sleep; private String name; private long threadId; private long beginExecution = -1;
public PriorityAsyncTask(long sleep, String name, PRIORITY priority) {
r2bapps/TaskManager
TaskManagerLib/src/r2b/apps/lib/taskmanager/Task.java
// Path: TaskManagerLib/src/r2b/apps/utils/Logger.java // public final class Logger { // // /** // * Send a INFO log message. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // */ // public static final void i(String tag, String msg) { // if (Cons.SHOW_LOGS) { // Log.i(tag, msg); // } // } // // /** // * Send a INFO log message. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // */ // public static final void e(String tag, String msg) { // if (Cons.SHOW_LOGS) { // Log.e(tag, msg); // } // } // // /** // * Send a ERROR log message and log the exception. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // * @param tr // * An exception to log. // */ // public static final void e(String tag, String msg, Throwable tr) { // if (Cons.SHOW_LOGS) { // Log.e(tag, msg, tr); // } // } // // /** // * Send a INFO log message for performance notice. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param method // * Used to identify the method of a log performance message. // * @param time // * The performance time in milliseconds you would like logged. // */ // public static final void performance(String tag, String method, long time) { // if (Cons.SHOW_LOGS) { // Log.i("Performance:" + tag, method + ": " + String.valueOf(time) + " ms"); // } // } // // }
import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; import r2b.apps.utils.Logger;
} return ((PriorityFutureTask<V>) priorityFutureTask).getPriority(); } /** * Get task identifier. * @return The identifier, should be unique. */ public long getId() { return id; } /* (non-Javadoc) * @see java.util.concurrent.Callable#call() */ @Override public V call() throws Exception { if (priorityFutureTask == null) { throw new IllegalStateException("priorityFutureTask is null."); } // Useful to identify the task on debug Thread.currentThread().setName(this.getClass().getSimpleName() + "<" + String.valueOf(id) + ">"); long begin = System.currentTimeMillis(); V result = doInBackground();
// Path: TaskManagerLib/src/r2b/apps/utils/Logger.java // public final class Logger { // // /** // * Send a INFO log message. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // */ // public static final void i(String tag, String msg) { // if (Cons.SHOW_LOGS) { // Log.i(tag, msg); // } // } // // /** // * Send a INFO log message. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // */ // public static final void e(String tag, String msg) { // if (Cons.SHOW_LOGS) { // Log.e(tag, msg); // } // } // // /** // * Send a ERROR log message and log the exception. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param msg // * The message you would like logged. // * @param tr // * An exception to log. // */ // public static final void e(String tag, String msg, Throwable tr) { // if (Cons.SHOW_LOGS) { // Log.e(tag, msg, tr); // } // } // // /** // * Send a INFO log message for performance notice. // * // * @param tag // * Used to identify the source of a log message. It usually // * identifies the class or activity where the log call occurs. // * @param method // * Used to identify the method of a log performance message. // * @param time // * The performance time in milliseconds you would like logged. // */ // public static final void performance(String tag, String method, long time) { // if (Cons.SHOW_LOGS) { // Log.i("Performance:" + tag, method + ": " + String.valueOf(time) + " ms"); // } // } // // } // Path: TaskManagerLib/src/r2b/apps/lib/taskmanager/Task.java import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; import r2b.apps.utils.Logger; } return ((PriorityFutureTask<V>) priorityFutureTask).getPriority(); } /** * Get task identifier. * @return The identifier, should be unique. */ public long getId() { return id; } /* (non-Javadoc) * @see java.util.concurrent.Callable#call() */ @Override public V call() throws Exception { if (priorityFutureTask == null) { throw new IllegalStateException("priorityFutureTask is null."); } // Useful to identify the task on debug Thread.currentThread().setName(this.getClass().getSimpleName() + "<" + String.valueOf(id) + ">"); long begin = System.currentTimeMillis(); V result = doInBackground();
Logger.performance(
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/MovieCategoryJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.MainCategoryEvent;
package us.nineworlds.serenity.jobs; public class MovieCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public MovieCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/MovieCategoryJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.MainCategoryEvent; package us.nineworlds.serenity.jobs; public class MovieCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public MovieCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
IMediaContainer mediaContainer = client.retrieveItemByIdCategory(key);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/SeasonsRetrievalJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.SeasonsRetrievalEvent;
package us.nineworlds.serenity.jobs; public class SeasonsRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; public SeasonsRetrievalJob(@NonNull String key) { this.key = key; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/SeasonsRetrievalJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.SeasonsRetrievalEvent; package us.nineworlds.serenity.jobs; public class SeasonsRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; public SeasonsRetrievalJob(@NonNull String key) { this.key = key; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
IMediaContainer mediaContainer = client.retrieveSeasons(key);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/video/player/EventLogger.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // }
import android.os.SystemClock; import android.util.Log; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.audio.AudioRendererEventListener; import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.MetadataOutput; import com.google.android.exoplayer2.metadata.emsg.EventMessage; import com.google.android.exoplayer2.metadata.id3.ApicFrame; import com.google.android.exoplayer2.metadata.id3.CommentFrame; import com.google.android.exoplayer2.metadata.id3.GeobFrame; import com.google.android.exoplayer2.metadata.id3.Id3Frame; import com.google.android.exoplayer2.metadata.id3.PrivFrame; import com.google.android.exoplayer2.metadata.id3.TextInformationFrame; import com.google.android.exoplayer2.metadata.id3.UrlLinkFrame; import com.google.android.exoplayer2.source.MediaSourceEventListener; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.video.VideoRendererEventListener; import java.text.NumberFormat; import java.util.Locale; import javax.inject.Inject; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.logger.Logger;
/* * Copyright (C) 2016 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 us.nineworlds.serenity.ui.video.player; /** * Logs player events using {@link Log}. */ public final class EventLogger implements Player.EventListener, AudioRendererEventListener, VideoRendererEventListener, MediaSourceEventListener, MetadataOutput { private static final int MAX_TIMELINE_ITEM_LINES = 3; private static final NumberFormat TIME_FORMAT; static { TIME_FORMAT = NumberFormat.getInstance(Locale.US); TIME_FORMAT.setMinimumFractionDigits(2); TIME_FORMAT.setMaximumFractionDigits(2); TIME_FORMAT.setGroupingUsed(false); } private final MappingTrackSelector trackSelector; private final long startTimeMs; @Inject Logger logger; public EventLogger(MappingTrackSelector trackSelector) { this.trackSelector = trackSelector; startTimeMs = SystemClock.elapsedRealtime();
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/video/player/EventLogger.java import android.os.SystemClock; import android.util.Log; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.audio.AudioRendererEventListener; import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.MetadataOutput; import com.google.android.exoplayer2.metadata.emsg.EventMessage; import com.google.android.exoplayer2.metadata.id3.ApicFrame; import com.google.android.exoplayer2.metadata.id3.CommentFrame; import com.google.android.exoplayer2.metadata.id3.GeobFrame; import com.google.android.exoplayer2.metadata.id3.Id3Frame; import com.google.android.exoplayer2.metadata.id3.PrivFrame; import com.google.android.exoplayer2.metadata.id3.TextInformationFrame; import com.google.android.exoplayer2.metadata.id3.UrlLinkFrame; import com.google.android.exoplayer2.source.MediaSourceEventListener; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.video.VideoRendererEventListener; import java.text.NumberFormat; import java.util.Locale; import javax.inject.Inject; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.logger.Logger; /* * Copyright (C) 2016 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 us.nineworlds.serenity.ui.video.player; /** * Logs player events using {@link Log}. */ public final class EventLogger implements Player.EventListener, AudioRendererEventListener, VideoRendererEventListener, MediaSourceEventListener, MetadataOutput { private static final int MAX_TIMELINE_ITEM_LINES = 3; private static final NumberFormat TIME_FORMAT; static { TIME_FORMAT = NumberFormat.getInstance(Locale.US); TIME_FORMAT.setMinimumFractionDigits(2); TIME_FORMAT.setMaximumFractionDigits(2); TIME_FORMAT.setGroupingUsed(false); } private final MappingTrackSelector trackSelector; private final long startTimeMs; @Inject Logger logger; public EventLogger(MappingTrackSelector trackSelector) { this.trackSelector = trackSelector; startTimeMs = SystemClock.elapsedRealtime();
Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE));
NineWorlds/serenity-android
plexapp-rest-library/src/test/java/us/nineworlds/plex/rest/tests/TestPlexFactory.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/ITrack.java // public interface ITrack { // String getKey(); // // void setKey(String key); // // String getTitle(); // // void setTitle(String title); // // String getSummary(); // // void setSummary(String summary); // // String getType(); // // void setType(String type); // // String getParentKey(); // // void setParentKey(String parentKey); // // int getIndex(); // // void setIndex(int index); // // long getDuration(); // // void setDuration(long duration); // // long getTimeAdded(); // // void setTimeAdded(long timeAdded); // // long getTimeUpdated(); // // void setTimeUpdated(long timeUpdated); // // List<IMedia> getMedias(); // // void setMedias(List<IMedia> medias); // }
import us.nineworlds.plex.rest.tests.utils.NanoHTTPD; import us.nineworlds.serenity.common.media.model.IDirectory; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.media.model.ITrack; import us.nineworlds.serenity.common.rest.SerenityClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; import us.nineworlds.plex.rest.PlexappFactory; import us.nineworlds.plex.rest.config.IConfiguration;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.plex.rest.tests; /** * @author dcarver */ public class TestPlexFactory { NanoHTTPD server = null; IConfiguration config = null; @Before public void setUp() throws Exception { config = new MockConfig(); //URL url = this.getClass().getResource("/"); File rootfile = new File("src/test/resources"); server = new NanoHTTPD(Integer.parseInt(config.getPort()), rootfile); } @After public void tearDown() throws Exception { server.stop(); } @Test public void testRetrieveLibrary() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config);
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/ITrack.java // public interface ITrack { // String getKey(); // // void setKey(String key); // // String getTitle(); // // void setTitle(String title); // // String getSummary(); // // void setSummary(String summary); // // String getType(); // // void setType(String type); // // String getParentKey(); // // void setParentKey(String parentKey); // // int getIndex(); // // void setIndex(int index); // // long getDuration(); // // void setDuration(long duration); // // long getTimeAdded(); // // void setTimeAdded(long timeAdded); // // long getTimeUpdated(); // // void setTimeUpdated(long timeUpdated); // // List<IMedia> getMedias(); // // void setMedias(List<IMedia> medias); // } // Path: plexapp-rest-library/src/test/java/us/nineworlds/plex/rest/tests/TestPlexFactory.java import us.nineworlds.plex.rest.tests.utils.NanoHTTPD; import us.nineworlds.serenity.common.media.model.IDirectory; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.media.model.ITrack; import us.nineworlds.serenity.common.rest.SerenityClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; import us.nineworlds.plex.rest.PlexappFactory; import us.nineworlds.plex.rest.config.IConfiguration; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.plex.rest.tests; /** * @author dcarver */ public class TestPlexFactory { NanoHTTPD server = null; IConfiguration config = null; @Before public void setUp() throws Exception { config = new MockConfig(); //URL url = this.getClass().getResource("/"); File rootfile = new File("src/test/resources"); server = new NanoHTTPD(Integer.parseInt(config.getPort()), rootfile); } @After public void tearDown() throws Exception { server.stop(); } @Test public void testRetrieveLibrary() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config);
IMediaContainer mediaContainer = factory.retrieveLibrary();
NineWorlds/serenity-android
plexapp-rest-library/src/test/java/us/nineworlds/plex/rest/tests/TestPlexFactory.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/ITrack.java // public interface ITrack { // String getKey(); // // void setKey(String key); // // String getTitle(); // // void setTitle(String title); // // String getSummary(); // // void setSummary(String summary); // // String getType(); // // void setType(String type); // // String getParentKey(); // // void setParentKey(String parentKey); // // int getIndex(); // // void setIndex(int index); // // long getDuration(); // // void setDuration(long duration); // // long getTimeAdded(); // // void setTimeAdded(long timeAdded); // // long getTimeUpdated(); // // void setTimeUpdated(long timeUpdated); // // List<IMedia> getMedias(); // // void setMedias(List<IMedia> medias); // }
import us.nineworlds.plex.rest.tests.utils.NanoHTTPD; import us.nineworlds.serenity.common.media.model.IDirectory; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.media.model.ITrack; import us.nineworlds.serenity.common.rest.SerenityClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; import us.nineworlds.plex.rest.PlexappFactory; import us.nineworlds.plex.rest.config.IConfiguration;
SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveItemByIdCategory("6", "all"); List<IDirectory> directories = mediaContainer.getDirectories(); assertEquals(6, directories.size()); } @Test public void testRetrieveAllMusic() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveItemByIdCategory("3", "all"); List<IDirectory> directories = mediaContainer.getDirectories(); assertEquals(4, directories.size()); } @Test public void testRetrieveSeasonsForTVShow() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/209/children/"); assertEquals(5, mediaContainer.getSize()); } @Test public void testRetrieveMusicMetaData() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/101/children/"); assertEquals(1, mediaContainer.getSize()); } @Test public void testRetrieveMusicTrackMetaData() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/102/children/"); assertEquals(21, mediaContainer.getSize()); assertNotNull(mediaContainer.getTracks());
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/ITrack.java // public interface ITrack { // String getKey(); // // void setKey(String key); // // String getTitle(); // // void setTitle(String title); // // String getSummary(); // // void setSummary(String summary); // // String getType(); // // void setType(String type); // // String getParentKey(); // // void setParentKey(String parentKey); // // int getIndex(); // // void setIndex(int index); // // long getDuration(); // // void setDuration(long duration); // // long getTimeAdded(); // // void setTimeAdded(long timeAdded); // // long getTimeUpdated(); // // void setTimeUpdated(long timeUpdated); // // List<IMedia> getMedias(); // // void setMedias(List<IMedia> medias); // } // Path: plexapp-rest-library/src/test/java/us/nineworlds/plex/rest/tests/TestPlexFactory.java import us.nineworlds.plex.rest.tests.utils.NanoHTTPD; import us.nineworlds.serenity.common.media.model.IDirectory; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.media.model.ITrack; import us.nineworlds.serenity.common.rest.SerenityClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; import us.nineworlds.plex.rest.PlexappFactory; import us.nineworlds.plex.rest.config.IConfiguration; SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveItemByIdCategory("6", "all"); List<IDirectory> directories = mediaContainer.getDirectories(); assertEquals(6, directories.size()); } @Test public void testRetrieveAllMusic() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveItemByIdCategory("3", "all"); List<IDirectory> directories = mediaContainer.getDirectories(); assertEquals(4, directories.size()); } @Test public void testRetrieveSeasonsForTVShow() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/209/children/"); assertEquals(5, mediaContainer.getSize()); } @Test public void testRetrieveMusicMetaData() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/101/children/"); assertEquals(1, mediaContainer.getSize()); } @Test public void testRetrieveMusicTrackMetaData() throws Exception { SerenityClient factory = PlexappFactory.getInstance(config); IMediaContainer mediaContainer = factory.retrieveSeasons("/library/metadata/102/children/"); assertEquals(21, mediaContainer.getSize()); assertNotNull(mediaContainer.getTracks());
ITrack track = mediaContainer.getTracks().get(0);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/StartupBroadcastReceiver.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // }
import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.util.AndroidHelper; import us.nineworlds.serenity.injection.InjectingBroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import javax.inject.Inject;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity; /** * Used to automatically launch Serenity for Android after boot is completed on * a device. This is only enabled if the startup preference option has been set * to true. * <p> * Recommendations are always run if on an Android TV device or a device that * supports the leanback feature. */ public class StartupBroadcastReceiver extends InjectingBroadcastReceiver { @Inject AndroidHelper androidHelper; @Inject SharedPreferences preferences; private static final int INITIAL_DELAY = 5000; private Context context; @Override public void onReceive(Context context, Intent intent) {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/StartupBroadcastReceiver.java import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.util.AndroidHelper; import us.nineworlds.serenity.injection.InjectingBroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import javax.inject.Inject; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity; /** * Used to automatically launch Serenity for Android after boot is completed on * a device. This is only enabled if the startup preference option has been set * to true. * <p> * Recommendations are always run if on an Android TV device or a device that * supports the leanback feature. */ public class StartupBroadcastReceiver extends InjectingBroadcastReceiver { @Inject AndroidHelper androidHelper; @Inject SharedPreferences preferences; private static final int INITIAL_DELAY = 5000; private Context context; @Override public void onReceive(Context context, Intent intent) {
Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE));
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob;
package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) {
Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE));
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob;
package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) {
jobManager.addJobInBackground(new TVCategoryJob(key));
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob;
package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) {
TVShowRetrievalJob tvShowRetrievalJob = new TVShowRetrievalJob(key, category);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob;
package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) { TVShowRetrievalJob tvShowRetrievalJob = new TVShowRetrievalJob(key, category); jobManager.addJobInBackground(tvShowRetrievalJob); }
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) { TVShowRetrievalJob tvShowRetrievalJob = new TVShowRetrievalJob(key, category); jobManager.addJobInBackground(tvShowRetrievalJob); }
@Subscribe(threadMode = ThreadMode.MAIN) public void onTVCategoryResponse(TVCategoryEvent event) {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob;
package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) { TVShowRetrievalJob tvShowRetrievalJob = new TVShowRetrievalJob(key, category); jobManager.addJobInBackground(tvShowRetrievalJob); } @Subscribe(threadMode = ThreadMode.MAIN) public void onTVCategoryResponse(TVCategoryEvent event) { TVCategoryMediaContainer categoryMediaContainer = new TVCategoryMediaContainer(event.getMediaContainer()); List<CategoryInfo> categories = categoryMediaContainer.createCategories(); getViewState().updateCategories(categories); }
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenter.java import androidx.annotation.NonNull; import moxy.InjectViewState; import moxy.MvpPresenter; import moxy.viewstate.strategy.SkipStrategy; import moxy.viewstate.strategy.StateStrategyType; import com.birbit.android.jobqueue.JobManager; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Toothpick; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.SeriesContentInfo; import us.nineworlds.serenity.core.model.impl.SecondaryCategoryMediaContainer; import us.nineworlds.serenity.core.model.impl.SeriesMediaContainer; import us.nineworlds.serenity.core.model.impl.TVCategoryMediaContainer; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; package us.nineworlds.serenity.ui.browser.tv; @InjectViewState @StateStrategyType(SkipStrategy.class) public class TVShowBrowserPresenter extends MvpPresenter<TVShowBrowserView> { EventBus eventBus = EventBus.getDefault(); @Inject JobManager jobManager; public TVShowBrowserPresenter() { } @Override public void attachView(TVShowBrowserView view) { Toothpick.inject(this, Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE)); super.attachView(view); eventBus.register(this); } @Override public void detachView(TVShowBrowserView view) { super.detachView(view); eventBus.unregister(this); } public void fetchTVCategories(@NonNull String key) { jobManager.addJobInBackground(new TVCategoryJob(key)); } public void fetchTVShows(@NonNull String key, @NonNull String category) { TVShowRetrievalJob tvShowRetrievalJob = new TVShowRetrievalJob(key, category); jobManager.addJobInBackground(tvShowRetrievalJob); } @Subscribe(threadMode = ThreadMode.MAIN) public void onTVCategoryResponse(TVCategoryEvent event) { TVCategoryMediaContainer categoryMediaContainer = new TVCategoryMediaContainer(event.getMediaContainer()); List<CategoryInfo> categories = categoryMediaContainer.createCategories(); getViewState().updateCategories(categories); }
@Subscribe(threadMode = ThreadMode.MAIN) public void onTVShowResponse(TVShowRetrievalEvent event) {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/movie/MovieBrowserContract.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/MovieRetrievalEvent.java // public class MovieRetrievalEvent extends SerenityEvent { // // public MovieRetrievalEvent(IMediaContainer mediaContainer) { // super(mediaContainer); // } // }
import moxy.MvpView; import java.util.List; import moxy.viewstate.strategy.AddToEndSingleStrategy; import moxy.viewstate.strategy.StateStrategyType; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.events.MainCategoryEvent; import us.nineworlds.serenity.events.MovieRetrievalEvent; import us.nineworlds.serenity.events.MovieSecondaryCategoryEvent;
package us.nineworlds.serenity.ui.browser.movie; /** * Created by dcarver on 10/10/17. */ public interface MovieBrowserContract { interface MovieBrowserView extends MvpView { @StateStrategyType(AddToEndSingleStrategy.class) void populateCategory(List<CategoryInfo> categories, String key); @StateStrategyType(AddToEndSingleStrategy.class) void populateSecondaryCategory(List<SecondaryCategoryInfo> categories, String key, String category); @StateStrategyType(AddToEndSingleStrategy.class) void displayPosters(List<VideoContentInfo> videos); } interface MoviewBrowserPresenter { void onMainCategoryResponse(MainCategoryEvent event); void onSecondaryCategoryEvent(MovieSecondaryCategoryEvent event);
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/MovieRetrievalEvent.java // public class MovieRetrievalEvent extends SerenityEvent { // // public MovieRetrievalEvent(IMediaContainer mediaContainer) { // super(mediaContainer); // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/movie/MovieBrowserContract.java import moxy.MvpView; import java.util.List; import moxy.viewstate.strategy.AddToEndSingleStrategy; import moxy.viewstate.strategy.StateStrategyType; import us.nineworlds.serenity.core.model.CategoryInfo; import us.nineworlds.serenity.core.model.SecondaryCategoryInfo; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.events.MainCategoryEvent; import us.nineworlds.serenity.events.MovieRetrievalEvent; import us.nineworlds.serenity.events.MovieSecondaryCategoryEvent; package us.nineworlds.serenity.ui.browser.movie; /** * Created by dcarver on 10/10/17. */ public interface MovieBrowserContract { interface MovieBrowserView extends MvpView { @StateStrategyType(AddToEndSingleStrategy.class) void populateCategory(List<CategoryInfo> categories, String key); @StateStrategyType(AddToEndSingleStrategy.class) void populateSecondaryCategory(List<SecondaryCategoryInfo> categories, String key, String category); @StateStrategyType(AddToEndSingleStrategy.class) void displayPosters(List<VideoContentInfo> videos); } interface MoviewBrowserPresenter { void onMainCategoryResponse(MainCategoryEvent event); void onSecondaryCategoryEvent(MovieSecondaryCategoryEvent event);
void onMoviePosterResponse(MovieRetrievalEvent event);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/fragments/MainMenuFragment.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/ErrorMainMenuEvent.java // public class ErrorMainMenuEvent extends SerenityEvent { // // public ErrorMainMenuEvent() { // super(null); // } // }
import android.app.Activity; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.leanback.widget.HorizontalGridView; import androidx.leanback.widget.OnChildSelectedListener; import androidx.leanback.widget.OnChildViewHolderSelectedListener; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.Toast; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import com.birbit.android.jobqueue.JobManager; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import timber.log.Timber; import us.nineworlds.serenity.MainMenuTextViewAdapter; import us.nineworlds.serenity.R; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.core.menus.MenuItem; import us.nineworlds.serenity.core.model.impl.MenuMediaContainer; import us.nineworlds.serenity.events.ErrorMainMenuEvent; import us.nineworlds.serenity.events.MainMenuEvent; import us.nineworlds.serenity.injection.InjectingFragment; import us.nineworlds.serenity.jobs.MainMenuRetrievalJob;
} private void setupGallery() { mainGallery.setWindowAlignment(HorizontalGridView.WINDOW_ALIGN_BOTH_EDGE); MainMenuTextViewAdapter adapter = new MainMenuTextViewAdapter(); mainGallery.setAdapter(adapter); mainGallery.setVisibility(View.VISIBLE); adapter.updateMenuItems(menuItems); Activity activity = getActivity(); if (activity != null) { FrameLayout dataLoadingContainer = activity.findViewById(R.id.data_loading_container); if (dataLoadingContainer != null) { dataLoadingContainer.setVisibility(View.GONE); } } } @Override public void onDestroyView() { super.onDestroyView(); unbinder.unbind(); } @Subscribe(threadMode = ThreadMode.MAIN) public void onMainMenuRetrievalResponse(MainMenuEvent event) { menuItems = new MenuMediaContainer(event.getMediaContainer()).createMenuItems(); setupGallery(); mainGallery.setVisibility(View.VISIBLE); mainGallery.requestFocusFromTouch(); }
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/ErrorMainMenuEvent.java // public class ErrorMainMenuEvent extends SerenityEvent { // // public ErrorMainMenuEvent() { // super(null); // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/fragments/MainMenuFragment.java import android.app.Activity; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.leanback.widget.HorizontalGridView; import androidx.leanback.widget.OnChildSelectedListener; import androidx.leanback.widget.OnChildViewHolderSelectedListener; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.Toast; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; import com.birbit.android.jobqueue.JobManager; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import timber.log.Timber; import us.nineworlds.serenity.MainMenuTextViewAdapter; import us.nineworlds.serenity.R; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.core.menus.MenuItem; import us.nineworlds.serenity.core.model.impl.MenuMediaContainer; import us.nineworlds.serenity.events.ErrorMainMenuEvent; import us.nineworlds.serenity.events.MainMenuEvent; import us.nineworlds.serenity.injection.InjectingFragment; import us.nineworlds.serenity.jobs.MainMenuRetrievalJob; } private void setupGallery() { mainGallery.setWindowAlignment(HorizontalGridView.WINDOW_ALIGN_BOTH_EDGE); MainMenuTextViewAdapter adapter = new MainMenuTextViewAdapter(); mainGallery.setAdapter(adapter); mainGallery.setVisibility(View.VISIBLE); adapter.updateMenuItems(menuItems); Activity activity = getActivity(); if (activity != null) { FrameLayout dataLoadingContainer = activity.findViewById(R.id.data_loading_container); if (dataLoadingContainer != null) { dataLoadingContainer.setVisibility(View.GONE); } } } @Override public void onDestroyView() { super.onDestroyView(); unbinder.unbind(); } @Subscribe(threadMode = ThreadMode.MAIN) public void onMainMenuRetrievalResponse(MainMenuEvent event) { menuItems = new MenuMediaContainer(event.getMediaContainer()).createMenuItems(); setupGallery(); mainGallery.setVisibility(View.VISIBLE); mainGallery.requestFocusFromTouch(); }
@Subscribe(threadMode = ThreadMode.MAIN) public void onMainMenuErrorResponse(ErrorMainMenuEvent event) {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/episodes/EpisodePosterOnItemSelectedListener.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/adapters/AbstractPosterImageGalleryAdapter.java // public abstract class AbstractPosterImageGalleryAdapter extends InjectingRecyclerViewAdapter implements // View.OnKeyListener { // // protected static List<VideoContentInfo> posterList = null; // protected Handler handler; // protected AbstractVideoOnItemClickListener onItemClickListener; // protected AbstractVideoOnItemSelectedListener onItemSelectedListener; // protected boolean triggerFocusSelection = true; // // private Animation scaleSmallAnimation; // private Animation scaleBigAnimation; // // public AbstractPosterImageGalleryAdapter() { // posterList = new ArrayList<>(); // } // // @Override public int getItemCount() { // return posterList.size(); // } // // public Object getItem(int position) { // if (position < posterList.size()) { // return posterList.get(position); // } // // return posterList.get(0); // } // // @Override public long getItemId(int position) { // return position; // } // // // public List<VideoContentInfo> getItems() { // return posterList; // } // // public AbstractVideoOnItemClickListener getOnItemClickListener() { // return onItemClickListener; // } // // public void setOnItemClickListener(AbstractVideoOnItemClickListener onItemClickListener) { // this.onItemClickListener = onItemClickListener; // } // // public AbstractVideoOnItemSelectedListener getOnItemSelectedListener() { // return onItemSelectedListener; // } // // public void setOnItemSelectedListener(AbstractVideoOnItemSelectedListener onItemSelectedListener) { // this.onItemSelectedListener = onItemSelectedListener; // } // // protected void zoomIn(View view) { // view.clearAnimation(); // if (scaleSmallAnimation == null) { // scaleSmallAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_small); // } // view.startAnimation(scaleSmallAnimation); // } // // protected void zoomOut(View view) { // if (scaleBigAnimation == null) { // scaleBigAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_big); // } // view.startAnimation(scaleBigAnimation); // } // // public boolean onKey(View v, int keyCode, KeyEvent event) { // triggerFocusSelection = true; // // if (event.getAction() == KeyEvent.ACTION_UP && isDirectionalPadKeyCode(keyCode)) { // v.setBackground(ContextCompat.getDrawable(v.getContext(), R.drawable.rounded_transparent_border)); // return true; // } // // if (event.getRepeatCount() > 1 && isDirectionalPadKeyCode(keyCode)) { // triggerFocusSelection = false; // } // // return false; // } // // protected boolean isDirectionalPadKeyCode(int keyCode) { // return keyCode == KeyEvent.KEYCODE_DPAD_LEFT || // keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || // keyCode == KeyEvent.KEYCODE_DPAD_UP || // keyCode == KeyEvent.KEYCODE_DPAD_DOWN; // } // }
import android.app.Activity; import android.graphics.Bitmap; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.Spinner; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import us.nineworlds.serenity.GlideApp; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.imageloader.BackgroundBitmapDisplayer; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.ui.adapters.AbstractPosterImageGalleryAdapter; import us.nineworlds.serenity.ui.listeners.AbstractVideoOnItemSelectedListener; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale;
@BindView(R.id.movieActionBarPosterTitle) TextView seriesTitle; @BindView(R.id.movieSummary) TextView episodeSummary; @BindView(R.id.movieBrowserPosterTitle) TextView title; @BindView(R.id.videoTextExtra) TextView videoTextExtra; @BindView(R.id.fanArt) View fanArt; @BindView(R.id.categoryFilter) View categoryFilter; @BindView(R.id.categoryFilter2) View categoryFilter2; @BindView(R.id.movieCategoryName) View categoryName; @BindView(R.id.subtitleFilter) TextView subtFilter; @BindView(R.id.videoSubtitle) Spinner subtitleSpinner; ImageView posterImageView; private static final String DISPLAY_DATE_FORMAT = "MMMM d, yyyy"; private static final String DATE_FORMAT = "yyyy-MM-dd"; private String prevTitle; private boolean fadeIn = true; private int fadeInCount = 0;
// Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/adapters/AbstractPosterImageGalleryAdapter.java // public abstract class AbstractPosterImageGalleryAdapter extends InjectingRecyclerViewAdapter implements // View.OnKeyListener { // // protected static List<VideoContentInfo> posterList = null; // protected Handler handler; // protected AbstractVideoOnItemClickListener onItemClickListener; // protected AbstractVideoOnItemSelectedListener onItemSelectedListener; // protected boolean triggerFocusSelection = true; // // private Animation scaleSmallAnimation; // private Animation scaleBigAnimation; // // public AbstractPosterImageGalleryAdapter() { // posterList = new ArrayList<>(); // } // // @Override public int getItemCount() { // return posterList.size(); // } // // public Object getItem(int position) { // if (position < posterList.size()) { // return posterList.get(position); // } // // return posterList.get(0); // } // // @Override public long getItemId(int position) { // return position; // } // // // public List<VideoContentInfo> getItems() { // return posterList; // } // // public AbstractVideoOnItemClickListener getOnItemClickListener() { // return onItemClickListener; // } // // public void setOnItemClickListener(AbstractVideoOnItemClickListener onItemClickListener) { // this.onItemClickListener = onItemClickListener; // } // // public AbstractVideoOnItemSelectedListener getOnItemSelectedListener() { // return onItemSelectedListener; // } // // public void setOnItemSelectedListener(AbstractVideoOnItemSelectedListener onItemSelectedListener) { // this.onItemSelectedListener = onItemSelectedListener; // } // // protected void zoomIn(View view) { // view.clearAnimation(); // if (scaleSmallAnimation == null) { // scaleSmallAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_small); // } // view.startAnimation(scaleSmallAnimation); // } // // protected void zoomOut(View view) { // if (scaleBigAnimation == null) { // scaleBigAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_big); // } // view.startAnimation(scaleBigAnimation); // } // // public boolean onKey(View v, int keyCode, KeyEvent event) { // triggerFocusSelection = true; // // if (event.getAction() == KeyEvent.ACTION_UP && isDirectionalPadKeyCode(keyCode)) { // v.setBackground(ContextCompat.getDrawable(v.getContext(), R.drawable.rounded_transparent_border)); // return true; // } // // if (event.getRepeatCount() > 1 && isDirectionalPadKeyCode(keyCode)) { // triggerFocusSelection = false; // } // // return false; // } // // protected boolean isDirectionalPadKeyCode(int keyCode) { // return keyCode == KeyEvent.KEYCODE_DPAD_LEFT || // keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || // keyCode == KeyEvent.KEYCODE_DPAD_UP || // keyCode == KeyEvent.KEYCODE_DPAD_DOWN; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/episodes/EpisodePosterOnItemSelectedListener.java import android.app.Activity; import android.graphics.Bitmap; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.Spinner; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import us.nineworlds.serenity.GlideApp; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.imageloader.BackgroundBitmapDisplayer; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.ui.adapters.AbstractPosterImageGalleryAdapter; import us.nineworlds.serenity.ui.listeners.AbstractVideoOnItemSelectedListener; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; @BindView(R.id.movieActionBarPosterTitle) TextView seriesTitle; @BindView(R.id.movieSummary) TextView episodeSummary; @BindView(R.id.movieBrowserPosterTitle) TextView title; @BindView(R.id.videoTextExtra) TextView videoTextExtra; @BindView(R.id.fanArt) View fanArt; @BindView(R.id.categoryFilter) View categoryFilter; @BindView(R.id.categoryFilter2) View categoryFilter2; @BindView(R.id.movieCategoryName) View categoryName; @BindView(R.id.subtitleFilter) TextView subtFilter; @BindView(R.id.videoSubtitle) Spinner subtitleSpinner; ImageView posterImageView; private static final String DISPLAY_DATE_FORMAT = "MMMM d, yyyy"; private static final String DATE_FORMAT = "yyyy-MM-dd"; private String prevTitle; private boolean fadeIn = true; private int fadeInCount = 0;
AbstractPosterImageGalleryAdapter adapter;
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/SerenityApplication.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // }
import android.app.Application; import android.content.BroadcastReceiver; import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.birbit.android.jobqueue.JobManager; import com.google.firebase.analytics.FirebaseAnalytics; import java.util.Map; import javax.inject.Inject; import net.danlew.android.joda.JodaTimeAndroid; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Scope; import toothpick.Toothpick; import us.nineworlds.serenity.common.Server; import us.nineworlds.serenity.common.android.mediacodec.MediaCodecInfoUtil; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.logger.Logger; import us.nineworlds.serenity.core.util.AndroidHelper; import us.nineworlds.serenity.emby.server.EmbyServer; import us.nineworlds.serenity.emby.server.EmbyServerJob; import us.nineworlds.serenity.injection.ForMediaServers; import us.nineworlds.serenity.injection.modules.AndroidModule; import us.nineworlds.serenity.injection.modules.LoginModule; import us.nineworlds.serenity.injection.modules.SerenityModule; import us.nineworlds.serenity.jobs.GDMServerJob; import us.nineworlds.serenity.server.GDMReceiver;
/** * The MIT License (MIT) * Copyright (c) 2012-2014 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity; /** * Global manager for the Serenity application * * @author dcarver */ public class SerenityApplication extends Application { @Inject @ForMediaServers Map<String, Server> servers; @Inject AndroidHelper androidHelper; @Inject SharedPreferences preferences; @Inject JobManager jobManager; @Inject Logger logger; @Inject LocalBroadcastManager localBroadcastManager; private BroadcastReceiver gdmReceiver; EventBus eventBus; private static boolean enableTracking = true; public static void disableTracking() { enableTracking = false; } private void init() { inject(); JodaTimeAndroid.init(this); sendStartedApplicationEvent(); eventBus = EventBus.getDefault(); eventBus.register(this); jobManager.start(); logger.initialize(); } protected void inject() {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/SerenityApplication.java import android.app.Application; import android.content.BroadcastReceiver; import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.birbit.android.jobqueue.JobManager; import com.google.firebase.analytics.FirebaseAnalytics; import java.util.Map; import javax.inject.Inject; import net.danlew.android.joda.JodaTimeAndroid; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import toothpick.Scope; import toothpick.Toothpick; import us.nineworlds.serenity.common.Server; import us.nineworlds.serenity.common.android.mediacodec.MediaCodecInfoUtil; import us.nineworlds.serenity.common.annotations.InjectionConstants; import us.nineworlds.serenity.core.logger.Logger; import us.nineworlds.serenity.core.util.AndroidHelper; import us.nineworlds.serenity.emby.server.EmbyServer; import us.nineworlds.serenity.emby.server.EmbyServerJob; import us.nineworlds.serenity.injection.ForMediaServers; import us.nineworlds.serenity.injection.modules.AndroidModule; import us.nineworlds.serenity.injection.modules.LoginModule; import us.nineworlds.serenity.injection.modules.SerenityModule; import us.nineworlds.serenity.jobs.GDMServerJob; import us.nineworlds.serenity.server.GDMReceiver; /** * The MIT License (MIT) * Copyright (c) 2012-2014 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity; /** * Global manager for the Serenity application * * @author dcarver */ public class SerenityApplication extends Application { @Inject @ForMediaServers Map<String, Server> servers; @Inject AndroidHelper androidHelper; @Inject SharedPreferences preferences; @Inject JobManager jobManager; @Inject Logger logger; @Inject LocalBroadcastManager localBroadcastManager; private BroadcastReceiver gdmReceiver; EventBus eventBus; private static boolean enableTracking = true; public static void disableTracking() { enableTracking = false; } private void init() { inject(); JodaTimeAndroid.init(this); sendStartedApplicationEvent(); eventBus = EventBus.getDefault(); eventBus.register(this); jobManager.start(); logger.initialize(); } protected void inject() {
Scope scope = Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent;
package us.nineworlds.serenity.jobs; public class TVCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public TVCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @VisibleForTesting public String getKey() { return key; } @Override public void onRun() throws Throwable {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent; package us.nineworlds.serenity.jobs; public class TVCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public TVCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @VisibleForTesting public String getKey() { return key; } @Override public void onRun() throws Throwable {
IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent;
package us.nineworlds.serenity.jobs; public class TVCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public TVCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @VisibleForTesting public String getKey() { return key; } @Override public void onRun() throws Throwable { IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key);
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent; package us.nineworlds.serenity.jobs; public class TVCategoryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; public TVCategoryJob(String key) { this.key = key; } @Override public void onAdded() { } @VisibleForTesting public String getKey() { return key; } @Override public void onRun() throws Throwable { IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key);
eventBus.post(new TVCategoryEvent(mediaContainer, key));
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVShowRetrievalEvent;
package us.nineworlds.serenity.jobs; public class TVShowRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; String category; public TVShowRetrievalJob(@NonNull String key, String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVShowRetrievalEvent; package us.nineworlds.serenity.jobs; public class TVShowRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; String category; public TVShowRetrievalJob(@NonNull String key, String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
IMediaContainer mediaContainer = client.retrieveSeriesById(key, category);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVShowRetrievalEvent;
package us.nineworlds.serenity.jobs; public class TVShowRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; String category; public TVShowRetrievalJob(@NonNull String key, String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable { IMediaContainer mediaContainer = client.retrieveSeriesById(key, category);
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVShowRetrievalEvent; package us.nineworlds.serenity.jobs; public class TVShowRetrievalJob extends InjectingJob { @Inject SerenityClient client; EventBus eventBus = EventBus.getDefault(); String key; String category; public TVShowRetrievalJob(@NonNull String key, String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable { IMediaContainer mediaContainer = client.retrieveSeriesById(key, category);
TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategorySecondaryJob.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategorySecondaryEvent;
package us.nineworlds.serenity.jobs; public class TVCategorySecondaryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; String category; public TVCategorySecondaryJob(@NonNull String key, @NonNull String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategorySecondaryJob.java import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.birbit.android.jobqueue.RetryConstraint; import javax.inject.Inject; import org.greenrobot.eventbus.EventBus; import us.nineworlds.serenity.common.android.injection.InjectingJob; import us.nineworlds.serenity.common.media.model.IMediaContainer; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; package us.nineworlds.serenity.jobs; public class TVCategorySecondaryJob extends InjectingJob { EventBus eventBus = EventBus.getDefault(); @Inject SerenityClient client; String key; String category; public TVCategorySecondaryJob(@NonNull String key, @NonNull String category) { this.key = key; this.category = category; } @Override public void onAdded() { } @Override public void onRun() throws Throwable {
IMediaContainer mediaContainer = client.retrieveItemByIdCategory(key, category);
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/episodes/EpisodeBrowserActivity.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/adapters/AbstractPosterImageGalleryAdapter.java // public abstract class AbstractPosterImageGalleryAdapter extends InjectingRecyclerViewAdapter implements // View.OnKeyListener { // // protected static List<VideoContentInfo> posterList = null; // protected Handler handler; // protected AbstractVideoOnItemClickListener onItemClickListener; // protected AbstractVideoOnItemSelectedListener onItemSelectedListener; // protected boolean triggerFocusSelection = true; // // private Animation scaleSmallAnimation; // private Animation scaleBigAnimation; // // public AbstractPosterImageGalleryAdapter() { // posterList = new ArrayList<>(); // } // // @Override public int getItemCount() { // return posterList.size(); // } // // public Object getItem(int position) { // if (position < posterList.size()) { // return posterList.get(position); // } // // return posterList.get(0); // } // // @Override public long getItemId(int position) { // return position; // } // // // public List<VideoContentInfo> getItems() { // return posterList; // } // // public AbstractVideoOnItemClickListener getOnItemClickListener() { // return onItemClickListener; // } // // public void setOnItemClickListener(AbstractVideoOnItemClickListener onItemClickListener) { // this.onItemClickListener = onItemClickListener; // } // // public AbstractVideoOnItemSelectedListener getOnItemSelectedListener() { // return onItemSelectedListener; // } // // public void setOnItemSelectedListener(AbstractVideoOnItemSelectedListener onItemSelectedListener) { // this.onItemSelectedListener = onItemSelectedListener; // } // // protected void zoomIn(View view) { // view.clearAnimation(); // if (scaleSmallAnimation == null) { // scaleSmallAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_small); // } // view.startAnimation(scaleSmallAnimation); // } // // protected void zoomOut(View view) { // if (scaleBigAnimation == null) { // scaleBigAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_big); // } // view.startAnimation(scaleBigAnimation); // } // // public boolean onKey(View v, int keyCode, KeyEvent event) { // triggerFocusSelection = true; // // if (event.getAction() == KeyEvent.ACTION_UP && isDirectionalPadKeyCode(keyCode)) { // v.setBackground(ContextCompat.getDrawable(v.getContext(), R.drawable.rounded_transparent_border)); // return true; // } // // if (event.getRepeatCount() > 1 && isDirectionalPadKeyCode(keyCode)) { // triggerFocusSelection = false; // } // // return false; // } // // protected boolean isDirectionalPadKeyCode(int keyCode) { // return keyCode == KeyEvent.KEYCODE_DPAD_LEFT || // keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || // keyCode == KeyEvent.KEYCODE_DPAD_UP || // keyCode == KeyEvent.KEYCODE_DPAD_DOWN; // } // }
import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import androidx.legacy.app.ActionBarDrawerToggle; import androidx.recyclerview.widget.RecyclerView; import android.view.KeyEvent; import android.view.View; import android.widget.FrameLayout; import butterknife.ButterKnife; import moxy.presenter.InjectPresenter; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.menus.MenuDrawerItem; import us.nineworlds.serenity.core.menus.MenuDrawerItemImpl; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.ui.activity.SerenityVideoActivity; import us.nineworlds.serenity.ui.adapters.AbstractPosterImageGalleryAdapter; import us.nineworlds.serenity.ui.adapters.MenuDrawerAdapter; import us.nineworlds.serenity.ui.util.DisplayUtils; import static android.view.View.*;
/** * The MIT License (MIT) * Copyright (c) 2013 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.ui.browser.tv.episodes; public class EpisodeBrowserActivity extends SerenityVideoActivity implements EpisodeBrowserView { @Inject protected SharedPreferences prefs; @InjectPresenter EpisodeBrowserPresenter presenter;
// Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/adapters/AbstractPosterImageGalleryAdapter.java // public abstract class AbstractPosterImageGalleryAdapter extends InjectingRecyclerViewAdapter implements // View.OnKeyListener { // // protected static List<VideoContentInfo> posterList = null; // protected Handler handler; // protected AbstractVideoOnItemClickListener onItemClickListener; // protected AbstractVideoOnItemSelectedListener onItemSelectedListener; // protected boolean triggerFocusSelection = true; // // private Animation scaleSmallAnimation; // private Animation scaleBigAnimation; // // public AbstractPosterImageGalleryAdapter() { // posterList = new ArrayList<>(); // } // // @Override public int getItemCount() { // return posterList.size(); // } // // public Object getItem(int position) { // if (position < posterList.size()) { // return posterList.get(position); // } // // return posterList.get(0); // } // // @Override public long getItemId(int position) { // return position; // } // // // public List<VideoContentInfo> getItems() { // return posterList; // } // // public AbstractVideoOnItemClickListener getOnItemClickListener() { // return onItemClickListener; // } // // public void setOnItemClickListener(AbstractVideoOnItemClickListener onItemClickListener) { // this.onItemClickListener = onItemClickListener; // } // // public AbstractVideoOnItemSelectedListener getOnItemSelectedListener() { // return onItemSelectedListener; // } // // public void setOnItemSelectedListener(AbstractVideoOnItemSelectedListener onItemSelectedListener) { // this.onItemSelectedListener = onItemSelectedListener; // } // // protected void zoomIn(View view) { // view.clearAnimation(); // if (scaleSmallAnimation == null) { // scaleSmallAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_small); // } // view.startAnimation(scaleSmallAnimation); // } // // protected void zoomOut(View view) { // if (scaleBigAnimation == null) { // scaleBigAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.anim_scale_big); // } // view.startAnimation(scaleBigAnimation); // } // // public boolean onKey(View v, int keyCode, KeyEvent event) { // triggerFocusSelection = true; // // if (event.getAction() == KeyEvent.ACTION_UP && isDirectionalPadKeyCode(keyCode)) { // v.setBackground(ContextCompat.getDrawable(v.getContext(), R.drawable.rounded_transparent_border)); // return true; // } // // if (event.getRepeatCount() > 1 && isDirectionalPadKeyCode(keyCode)) { // triggerFocusSelection = false; // } // // return false; // } // // protected boolean isDirectionalPadKeyCode(int keyCode) { // return keyCode == KeyEvent.KEYCODE_DPAD_LEFT || // keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || // keyCode == KeyEvent.KEYCODE_DPAD_UP || // keyCode == KeyEvent.KEYCODE_DPAD_DOWN; // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/browser/tv/episodes/EpisodeBrowserActivity.java import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import androidx.legacy.app.ActionBarDrawerToggle; import androidx.recyclerview.widget.RecyclerView; import android.view.KeyEvent; import android.view.View; import android.widget.FrameLayout; import butterknife.ButterKnife; import moxy.presenter.InjectPresenter; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.menus.MenuDrawerItem; import us.nineworlds.serenity.core.menus.MenuDrawerItemImpl; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.ui.activity.SerenityVideoActivity; import us.nineworlds.serenity.ui.adapters.AbstractPosterImageGalleryAdapter; import us.nineworlds.serenity.ui.adapters.MenuDrawerAdapter; import us.nineworlds.serenity.ui.util.DisplayUtils; import static android.view.View.*; /** * The MIT License (MIT) * Copyright (c) 2013 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.ui.browser.tv.episodes; public class EpisodeBrowserActivity extends SerenityVideoActivity implements EpisodeBrowserView { @Inject protected SharedPreferences prefs; @InjectPresenter EpisodeBrowserPresenter presenter;
public AbstractPosterImageGalleryAdapter seasonEpisodeAdapter;
NineWorlds/serenity-android
serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // }
import org.junit.After; import org.junit.Before; import toothpick.Scope; import toothpick.Toothpick; import toothpick.config.Module; import us.nineworlds.serenity.common.annotations.InjectionConstants;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.serenity.test; public abstract class InjectingTest { protected Scope scope; @Before public void setUp() throws Exception { scope = openScope(); installTestModules(); Toothpick.inject(this, scope); } protected Scope openScope() {
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/annotations/InjectionConstants.java // public class InjectionConstants { // // public static final String APPLICATION_SCOPE = "Application Scope"; // // } // Path: serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java import org.junit.After; import org.junit.Before; import toothpick.Scope; import toothpick.Toothpick; import toothpick.config.Module; import us.nineworlds.serenity.common.annotations.InjectionConstants; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.serenity.test; public abstract class InjectingTest { protected Scope scope; @Before public void setUp() throws Exception { scope = openScope(); installTestModules(); Toothpick.inject(this, scope); } protected Scope openScope() {
return Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE);
NineWorlds/serenity-android
plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/PlexappClient.java
// Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/services/PlexTextService.java // public interface PlexTextService { // // @GET(":/scrobble?identifier=com.plexapp.plugins.library") // Call<String> watched(@Query("key") String key); // // @GET(":/unscrobble?identifier=com.plexapp.plugins.library") // Call<String> unwatched(@Query("key") String key); // // @GET(":/progress?identifier=com.plexapp.plugins.library") // Call<String> progress(@Query("key") String key, // @Query("time") String offset); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import retrofit2.Retrofit; import retrofit2.converter.scalars.ScalarsConverterFactory; import retrofit2.converter.simplexml.SimpleXmlConverterFactory; import us.nineworlds.plex.rest.config.IConfiguration; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.plex.rest.services.PlexMediaContainerService; import us.nineworlds.plex.rest.services.PlexTextService; import us.nineworlds.serenity.common.media.model.IMediaContainer; import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.simpleframework.xml.Serializer; import org.simpleframework.xml.core.Persister; import retrofit2.Call; import retrofit2.Response;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.plex.rest; /** * This class acts as a factory for retrieving items from Plex. * * This is a singleton so only one of these will ever exist currently. * * @author dcarver */ public class PlexappClient { private static PlexappClient instance = null; private ResourcePaths resourcePath = null; private PlexMediaContainerService mediaContainerclient;
// Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/services/PlexTextService.java // public interface PlexTextService { // // @GET(":/scrobble?identifier=com.plexapp.plugins.library") // Call<String> watched(@Query("key") String key); // // @GET(":/unscrobble?identifier=com.plexapp.plugins.library") // Call<String> unwatched(@Query("key") String key); // // @GET(":/progress?identifier=com.plexapp.plugins.library") // Call<String> progress(@Query("key") String key, // @Query("time") String offset); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/PlexappClient.java import retrofit2.Retrofit; import retrofit2.converter.scalars.ScalarsConverterFactory; import retrofit2.converter.simplexml.SimpleXmlConverterFactory; import us.nineworlds.plex.rest.config.IConfiguration; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.plex.rest.services.PlexMediaContainerService; import us.nineworlds.plex.rest.services.PlexTextService; import us.nineworlds.serenity.common.media.model.IMediaContainer; import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.simpleframework.xml.Serializer; import org.simpleframework.xml.core.Persister; import retrofit2.Call; import retrofit2.Response; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.plex.rest; /** * This class acts as a factory for retrieving items from Plex. * * This is a singleton so only one of these will ever exist currently. * * @author dcarver */ public class PlexappClient { private static PlexappClient instance = null; private ResourcePaths resourcePath = null; private PlexMediaContainerService mediaContainerclient;
private PlexTextService textClient;
NineWorlds/serenity-android
plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/PlexappClient.java
// Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/services/PlexTextService.java // public interface PlexTextService { // // @GET(":/scrobble?identifier=com.plexapp.plugins.library") // Call<String> watched(@Query("key") String key); // // @GET(":/unscrobble?identifier=com.plexapp.plugins.library") // Call<String> unwatched(@Query("key") String key); // // @GET(":/progress?identifier=com.plexapp.plugins.library") // Call<String> progress(@Query("key") String key, // @Query("time") String offset); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import retrofit2.Retrofit; import retrofit2.converter.scalars.ScalarsConverterFactory; import retrofit2.converter.simplexml.SimpleXmlConverterFactory; import us.nineworlds.plex.rest.config.IConfiguration; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.plex.rest.services.PlexMediaContainerService; import us.nineworlds.plex.rest.services.PlexTextService; import us.nineworlds.serenity.common.media.model.IMediaContainer; import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.simpleframework.xml.Serializer; import org.simpleframework.xml.core.Persister; import retrofit2.Call; import retrofit2.Response;
okClient.cache(null); Retrofit.Builder builder = new Retrofit.Builder(); Retrofit mediaContainerAdapter = builder.baseUrl(resourcePath.getRoot()) .addConverterFactory(SimpleXmlConverterFactory.createNonStrict(serializer)) .client(okClient.build()) .build(); mediaContainerclient = mediaContainerAdapter.create(PlexMediaContainerService.class); Retrofit stringAdapter = new Retrofit.Builder().baseUrl(resourcePath.getRoot()) .addConverterFactory(ScalarsConverterFactory.create()) .client(okClient.build()) .build(); textClient = stringAdapter.create(PlexTextService.class); } private void reinitIfNecessary() { if (mediaContainerclient != null && textClient != null) { return; } init(); } /** * Retrieve the root metadata from the Plex Media Server. * * @throws Exception */
// Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/services/PlexTextService.java // public interface PlexTextService { // // @GET(":/scrobble?identifier=com.plexapp.plugins.library") // Call<String> watched(@Query("key") String key); // // @GET(":/unscrobble?identifier=com.plexapp.plugins.library") // Call<String> unwatched(@Query("key") String key); // // @GET(":/progress?identifier=com.plexapp.plugins.library") // Call<String> progress(@Query("key") String key, // @Query("time") String offset); // } // // Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: plexapp-rest-library/src/main/java/us/nineworlds/plex/rest/PlexappClient.java import retrofit2.Retrofit; import retrofit2.converter.scalars.ScalarsConverterFactory; import retrofit2.converter.simplexml.SimpleXmlConverterFactory; import us.nineworlds.plex.rest.config.IConfiguration; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.plex.rest.services.PlexMediaContainerService; import us.nineworlds.plex.rest.services.PlexTextService; import us.nineworlds.serenity.common.media.model.IMediaContainer; import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import org.simpleframework.xml.Serializer; import org.simpleframework.xml.core.Persister; import retrofit2.Call; import retrofit2.Response; okClient.cache(null); Retrofit.Builder builder = new Retrofit.Builder(); Retrofit mediaContainerAdapter = builder.baseUrl(resourcePath.getRoot()) .addConverterFactory(SimpleXmlConverterFactory.createNonStrict(serializer)) .client(okClient.build()) .build(); mediaContainerclient = mediaContainerAdapter.create(PlexMediaContainerService.class); Retrofit stringAdapter = new Retrofit.Builder().baseUrl(resourcePath.getRoot()) .addConverterFactory(ScalarsConverterFactory.create()) .client(okClient.build()) .build(); textClient = stringAdapter.create(PlexTextService.class); } private void reinitIfNecessary() { if (mediaContainerclient != null && textClient != null) { return; } init(); } /** * Retrieve the root metadata from the Plex Media Server. * * @throws Exception */
public IMediaContainer retrieveRootData() throws Exception {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import us.nineworlds.serenity.common.media.model.IMediaContainer;
package us.nineworlds.serenity.events; public class TVShowRetrievalEvent extends SerenityEvent { private String key; private String category;
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java import us.nineworlds.serenity.common.media.model.IMediaContainer; package us.nineworlds.serenity.events; public class TVShowRetrievalEvent extends SerenityEvent { private String key; private String category;
public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/core/services/MovieSearchIntentService.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // }
import android.content.Intent; import android.os.Bundle; import android.util.Log; import us.nineworlds.serenity.common.media.model.IMediaContainer;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.core.services; /** * @deprecated Need to migrate this to Volley for searching for movies. */ @Deprecated public class MovieSearchIntentService extends MoviesRetrievalIntentService { protected String query; @Override protected void onHandleIntent(Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null) { Log.e(getClass().getName(), "Missing intent extras"); return; } key = intent.getExtras().getString("key", ""); query = intent.getExtras().getString("query"); createPosters(); sendMessageResults(intent); }
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IMediaContainer.java // public interface IMediaContainer { // String getTitle2(); // // void setTitle2(String title2); // // List<IDirectory> getDirectories(); // // void setDirectories(List<IDirectory> directory); // // int getSize(); // // void setSize(int size); // // int getAllowSync(); // // void setAllowSync(int allowSync); // // String getIdentifier(); // // void setIdentifier(String identifier); // // String getMediaTagPrefix(); // // void setMediaTagPrefix(String mediaTagPrefix); // // long getMediaTagVersion(); // // String getArt(); // // void setArt(String art); // // int getSortAsc(); // // void setSortAsc(int sortAsc); // // String getContent(); // // void setContent(String content); // // String getViewGroup(); // // void setViewGroup(String viewGroup); // // int getViewMode(); // // void setViewMode(int viewMode); // // void setMediaTagVersion(long mediaTagVersion); // // void setMediaTagVersion(int mediaTagVersion); // // String getTitle1(); // // void setTitle1(String title1); // // List<IVideo> getVideos(); // // void setVideos(List<IVideo> videos); // // String getParentPosterURL(); // // void setParentPosterURL(String parentPosterURL); // // List<ITrack> getTracks(); // // void setTracks(List<ITrack> tracks); // // String getParentIndex(); // // void setParentIndex(String parentIndex); // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/core/services/MovieSearchIntentService.java import android.content.Intent; import android.os.Bundle; import android.util.Log; import us.nineworlds.serenity.common.media.model.IMediaContainer; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.core.services; /** * @deprecated Need to migrate this to Volley for searching for movies. */ @Deprecated public class MovieSearchIntentService extends MoviesRetrievalIntentService { protected String query; @Override protected void onHandleIntent(Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null) { Log.e(getClass().getName(), "Missing intent extras"); return; } key = intent.getExtras().getString("key", ""); query = intent.getExtras().getString("query"); createPosters(); sendMessageResults(intent); }
@Override protected IMediaContainer retrieveVideos() throws Exception {
NineWorlds/serenity-android
emby-lib/src/main/java/us/nineworlds/serenity/emby/model/Media.java
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IPart.java // public interface IPart { // List<IStream> getStreams(); // // void setStreams(List<IStream> streams); // // String getContainer(); // // void setContainer(String container); // // String getKey(); // // void setKey(String key); // // String getFilename(); // // void setFilename(String filename); // }
import java.util.List; import us.nineworlds.serenity.common.media.model.IMedia; import us.nineworlds.serenity.common.media.model.IPart;
package us.nineworlds.serenity.emby.model; public class Media implements IMedia { private String aspectRatio; private String audioCodec; private String videoCodec; private String videoResolution; private String container; private String audioChannels;
// Path: serenity-common/src/main/java/us/nineworlds/serenity/common/media/model/IPart.java // public interface IPart { // List<IStream> getStreams(); // // void setStreams(List<IStream> streams); // // String getContainer(); // // void setContainer(String container); // // String getKey(); // // void setKey(String key); // // String getFilename(); // // void setFilename(String filename); // } // Path: emby-lib/src/main/java/us/nineworlds/serenity/emby/model/Media.java import java.util.List; import us.nineworlds.serenity.common.media.model.IMedia; import us.nineworlds.serenity.common.media.model.IPart; package us.nineworlds.serenity.emby.model; public class Media implements IMedia { private String aspectRatio; private String audioCodec; private String videoCodec; private String videoResolution; private String container; private String audioChannels;
private List<IPart> videoParts;
NineWorlds/serenity-android
serenity-app/src/test/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenterTest.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // // Path: serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java // public abstract class InjectingTest { // // protected Scope scope; // // @Before public void setUp() throws Exception { // scope = openScope(); // installTestModules(); // Toothpick.inject(this, scope); // } // // protected Scope openScope() { // return Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE); // } // // @After // public void closeScope() { // Toothpick.reset(); // } // // public abstract void installTestModules(); // }
import com.birbit.android.jobqueue.JobManager; import java.util.List; import org.apache.commons.lang3.RandomStringUtils; import org.greenrobot.eventbus.EventBus; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.robolectric.RobolectricTestRunner; import toothpick.config.Module; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.serenity.TestingModule; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; import us.nineworlds.serenity.test.InjectingTest; import us.nineworlds.serenity.testrunner.PlainAndroidRunner; import static org.assertj.core.api.Java6Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks;
package us.nineworlds.serenity.ui.browser.tv; public class TVShowBrowserPresenterTest extends InjectingTest { @Mock JobManager mockJobManager; @Mock EventBus mockEventBus; @Mock SerenityClient mockSerenityClient; @Mock TVShowBrowserView mockView; TVShowBrowserPresenter presenter; @Before public void setUp() throws Exception { initMocks(this); super.setUp(); presenter = new TVShowBrowserPresenter(); presenter.attachView(mockView); } @After public void tearDown() throws Exception { presenter.detachView(mockView); } @Test public void fetchTVCategoriesAddsTVCategoryJobWithExpectedKey() { String key = RandomStringUtils.randomAlphanumeric(12);
// Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVCategoryEvent.java // public class TVCategoryEvent extends MainCategoryEvent { // // public TVCategoryEvent(IMediaContainer mediaContainer, String key) { // super(mediaContainer, key); // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/events/TVShowRetrievalEvent.java // public class TVShowRetrievalEvent extends SerenityEvent { // // private String key; // private String category; // // public TVShowRetrievalEvent(IMediaContainer mediaContainer, String key, String category) { // super(mediaContainer); // this.key = key; // this.category = category; // } // // public String getKey() { // return key; // } // // public String getCategory() { // return category; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVCategoryJob.java // public class TVCategoryJob extends InjectingJob { // // EventBus eventBus = EventBus.getDefault(); // // @Inject SerenityClient client; // // String key; // // public TVCategoryJob(String key) { // this.key = key; // } // // @Override public void onAdded() { // // } // // @VisibleForTesting public String getKey() { // return key; // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesCategoryById(key); // eventBus.post(new TVCategoryEvent(mediaContainer, key)); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // } // // Path: serenity-app/src/main/java/us/nineworlds/serenity/jobs/TVShowRetrievalJob.java // public class TVShowRetrievalJob extends InjectingJob { // // @Inject SerenityClient client; // // EventBus eventBus = EventBus.getDefault(); // // String key; // String category; // // public TVShowRetrievalJob(@NonNull String key, String category) { // this.key = key; // this.category = category; // } // // @Override public void onAdded() { // // } // // @Override public void onRun() throws Throwable { // IMediaContainer mediaContainer = client.retrieveSeriesById(key, category); // TVShowRetrievalEvent event = new TVShowRetrievalEvent(mediaContainer, key, category); // eventBus.post(event); // } // // @Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) { // // } // // @Override // protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) { // return null; // } // // @VisibleForTesting public String getKey() { // return key; // } // // @VisibleForTesting public String getCategory() { // return category; // } // } // // Path: serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java // public abstract class InjectingTest { // // protected Scope scope; // // @Before public void setUp() throws Exception { // scope = openScope(); // installTestModules(); // Toothpick.inject(this, scope); // } // // protected Scope openScope() { // return Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE); // } // // @After // public void closeScope() { // Toothpick.reset(); // } // // public abstract void installTestModules(); // } // Path: serenity-app/src/test/java/us/nineworlds/serenity/ui/browser/tv/TVShowBrowserPresenterTest.java import com.birbit.android.jobqueue.JobManager; import java.util.List; import org.apache.commons.lang3.RandomStringUtils; import org.greenrobot.eventbus.EventBus; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.robolectric.RobolectricTestRunner; import toothpick.config.Module; import us.nineworlds.plex.rest.model.impl.MediaContainer; import us.nineworlds.serenity.TestingModule; import us.nineworlds.serenity.common.rest.SerenityClient; import us.nineworlds.serenity.events.TVCategoryEvent; import us.nineworlds.serenity.events.TVCategorySecondaryEvent; import us.nineworlds.serenity.events.TVShowRetrievalEvent; import us.nineworlds.serenity.jobs.TVCategoryJob; import us.nineworlds.serenity.jobs.TVShowRetrievalJob; import us.nineworlds.serenity.test.InjectingTest; import us.nineworlds.serenity.testrunner.PlainAndroidRunner; import static org.assertj.core.api.Java6Assertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; package us.nineworlds.serenity.ui.browser.tv; public class TVShowBrowserPresenterTest extends InjectingTest { @Mock JobManager mockJobManager; @Mock EventBus mockEventBus; @Mock SerenityClient mockSerenityClient; @Mock TVShowBrowserView mockView; TVShowBrowserPresenter presenter; @Before public void setUp() throws Exception { initMocks(this); super.setUp(); presenter = new TVShowBrowserPresenter(); presenter.attachView(mockView); } @After public void tearDown() throws Exception { presenter.detachView(mockView); } @Test public void fetchTVCategoriesAddsTVCategoryJobWithExpectedKey() { String key = RandomStringUtils.randomAlphanumeric(12);
doNothing().when(mockJobManager).addJobInBackground(any(TVCategoryJob.class));
NineWorlds/serenity-android
serenity-app/src/test/java/us/nineworlds/serenity/handlers/AutoConfigureHandlerRunnableTest.java
// Path: serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java // public abstract class InjectingTest { // // protected Scope scope; // // @Before public void setUp() throws Exception { // scope = openScope(); // installTestModules(); // Toothpick.inject(this, scope); // } // // protected Scope openScope() { // return Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE); // } // // @After // public void closeScope() { // Toothpick.reset(); // } // // public abstract void installTestModules(); // }
import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.shadows.ShadowToast; import toothpick.config.Module; import us.nineworlds.plex.server.GDMServer; import us.nineworlds.serenity.common.Server; import us.nineworlds.serenity.injection.ForMediaServers; import us.nineworlds.serenity.test.InjectingTest; import static org.assertj.core.api.Java6Assertions.assertThat; import android.app.Activity; import java.util.Map; import javax.inject.Inject; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.serenity.handlers; @RunWith(RobolectricTestRunner.class) @Ignore
// Path: serenity-app/src/test/java/us/nineworlds/serenity/test/InjectingTest.java // public abstract class InjectingTest { // // protected Scope scope; // // @Before public void setUp() throws Exception { // scope = openScope(); // installTestModules(); // Toothpick.inject(this, scope); // } // // protected Scope openScope() { // return Toothpick.openScope(InjectionConstants.APPLICATION_SCOPE); // } // // @After // public void closeScope() { // Toothpick.reset(); // } // // public abstract void installTestModules(); // } // Path: serenity-app/src/test/java/us/nineworlds/serenity/handlers/AutoConfigureHandlerRunnableTest.java import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.shadows.ShadowToast; import toothpick.config.Module; import us.nineworlds.plex.server.GDMServer; import us.nineworlds.serenity.common.Server; import us.nineworlds.serenity.injection.ForMediaServers; import us.nineworlds.serenity.test.InjectingTest; import static org.assertj.core.api.Java6Assertions.assertThat; import android.app.Activity; import java.util.Map; import javax.inject.Inject; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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 us.nineworlds.serenity.handlers; @RunWith(RobolectricTestRunner.class) @Ignore
public class AutoConfigureHandlerRunnableTest extends InjectingTest {
NineWorlds/serenity-android
serenity-app/src/main/java/us/nineworlds/serenity/ui/util/VideoPlayerIntentUtils.java
// Path: serenity-app/src/main/java/us/nineworlds/serenity/core/externalplayer/ExternalPlayerFactory.java // public class ExternalPlayerFactory { // // private final VideoContentInfo videoContent; // private final Context activity; // // /** // * // */ // public ExternalPlayerFactory(VideoContentInfo vc, Context ac) { // videoContent = vc; // activity = ac; // } // // public ExternalPlayer createExternalPlayer(String identifier) { // if ("mxplayer".equals(identifier)) { // return new MXPlayer(videoContent, activity); // } // // if ("mxplayerpro".equals(identifier)) { // return new MXPlayerPro(videoContent, activity); // } // // if ("vimu".equals(identifier)) { // return new ViMuPlayer(videoContent, activity); // } // // return new SystemDefaultPlayer(videoContent, activity); // } // }
import java.util.LinkedList; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.SerenityConstants; import us.nineworlds.serenity.core.externalplayer.ExternalPlayer; import us.nineworlds.serenity.core.externalplayer.ExternalPlayerFactory; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.core.util.TimeUtil; import us.nineworlds.serenity.ui.video.player.ExoplayerVideoActivity; import android.app.Activity; import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.widget.Toast;
/** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.ui.util; public class VideoPlayerIntentUtils { protected LinkedList<VideoContentInfo> videoQueue; protected SharedPreferences prefs; protected TimeUtil timeUtil; public VideoPlayerIntentUtils(LinkedList<VideoContentInfo> videoQueue, SharedPreferences prefs, TimeUtil timeUtil) { this.videoQueue = videoQueue; this.prefs = prefs; this.timeUtil = timeUtil; } /** * This must run on a UI thread. * * Launches an external player based on the information provided. */ public void launchExternalPlayer(VideoContentInfo videoContent, Activity activity, boolean autoResume) { String externalPlayerValue = prefs.getString("serenity_external_player_filter", "default"); if ("default".equals(externalPlayerValue)) { videoContent.setResumeOffset(0); launchPlayer(videoContent, activity); return; } if (videoContent.isPartiallyWatched() && !autoResume) { showResumeDialogQueue(activity, videoContent); return; } launchPlayer(videoContent, activity); } protected void launchPlayer(VideoContentInfo videoContent, Activity activity) { String externalPlayerValue = prefs.getString("serenity_external_player_filter", "default");
// Path: serenity-app/src/main/java/us/nineworlds/serenity/core/externalplayer/ExternalPlayerFactory.java // public class ExternalPlayerFactory { // // private final VideoContentInfo videoContent; // private final Context activity; // // /** // * // */ // public ExternalPlayerFactory(VideoContentInfo vc, Context ac) { // videoContent = vc; // activity = ac; // } // // public ExternalPlayer createExternalPlayer(String identifier) { // if ("mxplayer".equals(identifier)) { // return new MXPlayer(videoContent, activity); // } // // if ("mxplayerpro".equals(identifier)) { // return new MXPlayerPro(videoContent, activity); // } // // if ("vimu".equals(identifier)) { // return new ViMuPlayer(videoContent, activity); // } // // return new SystemDefaultPlayer(videoContent, activity); // } // } // Path: serenity-app/src/main/java/us/nineworlds/serenity/ui/util/VideoPlayerIntentUtils.java import java.util.LinkedList; import us.nineworlds.serenity.R; import us.nineworlds.serenity.core.SerenityConstants; import us.nineworlds.serenity.core.externalplayer.ExternalPlayer; import us.nineworlds.serenity.core.externalplayer.ExternalPlayerFactory; import us.nineworlds.serenity.core.model.VideoContentInfo; import us.nineworlds.serenity.core.util.TimeUtil; import us.nineworlds.serenity.ui.video.player.ExoplayerVideoActivity; import android.app.Activity; import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.widget.Toast; /** * The MIT License (MIT) * Copyright (c) 2012 David Carver * 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: * <p> * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * <p> * 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 us.nineworlds.serenity.ui.util; public class VideoPlayerIntentUtils { protected LinkedList<VideoContentInfo> videoQueue; protected SharedPreferences prefs; protected TimeUtil timeUtil; public VideoPlayerIntentUtils(LinkedList<VideoContentInfo> videoQueue, SharedPreferences prefs, TimeUtil timeUtil) { this.videoQueue = videoQueue; this.prefs = prefs; this.timeUtil = timeUtil; } /** * This must run on a UI thread. * * Launches an external player based on the information provided. */ public void launchExternalPlayer(VideoContentInfo videoContent, Activity activity, boolean autoResume) { String externalPlayerValue = prefs.getString("serenity_external_player_filter", "default"); if ("default".equals(externalPlayerValue)) { videoContent.setResumeOffset(0); launchPlayer(videoContent, activity); return; } if (videoContent.isPartiallyWatched() && !autoResume) { showResumeDialogQueue(activity, videoContent); return; } launchPlayer(videoContent, activity); } protected void launchPlayer(VideoContentInfo videoContent, Activity activity) { String externalPlayerValue = prefs.getString("serenity_external_player_filter", "default");
ExternalPlayerFactory factory = new ExternalPlayerFactory(videoContent, activity);