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
digitalpetri/ethernet-ip
cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterRequest.java
// Path: cip-core/src/main/java/com/digitalpetri/enip/cip/epath/EPath.java // public abstract class EPath { // // private final EPathSegment[] segments; // // protected EPath(EPathSegment[] segments) { // this.segments = segments; // } // // public EPathSegment[] getSegments() { // return segments; // } // // public abstract boolean isPadded(); // // public static ByteBuf encode(EPath path, ByteBuf buffer) { // // length placeholder... // int lengthStartIndex = buffer.writerIndex(); // buffer.writeByte(0); // // // encode the path segments... // int dataStartIndex = buffer.writerIndex(); // // for (EPathSegment segment : path.getSegments()) { // if (segment instanceof LogicalSegment) { // LogicalSegment.encode((LogicalSegment) segment, path.isPadded(), buffer); // } else if (segment instanceof PortSegment) { // PortSegment.encode((PortSegment) segment, path.isPadded(), buffer); // } else if (segment instanceof DataSegment) { // DataSegment.encode((DataSegment) segment, path.isPadded(), buffer); // } else { // throw new RuntimeException("no encoder for " + segment.getClass().getSimpleName()); // } // } // // // go back and update the length // int bytesWritten = buffer.writerIndex() - dataStartIndex; // int wordsWritten = bytesWritten / 2; // buffer.markWriterIndex(); // buffer.writerIndex(lengthStartIndex); // buffer.writeByte(wordsWritten); // buffer.resetWriterIndex(); // // return buffer; // } // // public static final class PaddedEPath extends EPath { // // public PaddedEPath(List<EPathSegment> segments) { // this(segments.toArray(new EPathSegment[segments.size()])); // } // // public PaddedEPath(EPathSegment... segments) { // super(segments); // } // // @Override // public boolean isPadded() { // return true; // } // // public PaddedEPath append(PaddedEPath other) { // int aLen = getSegments().length; // int bLen = other.getSegments().length; // // EPathSegment[] newSegments = new EPathSegment[aLen + bLen]; // // System.arraycopy(getSegments(), 0, newSegments, 0, aLen); // System.arraycopy(other.getSegments(), 0, newSegments, aLen, bLen); // // return new PaddedEPath(newSegments); // } // // } // // }
import java.util.function.Consumer; import com.digitalpetri.enip.cip.epath.EPath; import io.netty.buffer.ByteBuf;
package com.digitalpetri.enip.cip.structs; public class MessageRouterRequest { private final int serviceCode;
// Path: cip-core/src/main/java/com/digitalpetri/enip/cip/epath/EPath.java // public abstract class EPath { // // private final EPathSegment[] segments; // // protected EPath(EPathSegment[] segments) { // this.segments = segments; // } // // public EPathSegment[] getSegments() { // return segments; // } // // public abstract boolean isPadded(); // // public static ByteBuf encode(EPath path, ByteBuf buffer) { // // length placeholder... // int lengthStartIndex = buffer.writerIndex(); // buffer.writeByte(0); // // // encode the path segments... // int dataStartIndex = buffer.writerIndex(); // // for (EPathSegment segment : path.getSegments()) { // if (segment instanceof LogicalSegment) { // LogicalSegment.encode((LogicalSegment) segment, path.isPadded(), buffer); // } else if (segment instanceof PortSegment) { // PortSegment.encode((PortSegment) segment, path.isPadded(), buffer); // } else if (segment instanceof DataSegment) { // DataSegment.encode((DataSegment) segment, path.isPadded(), buffer); // } else { // throw new RuntimeException("no encoder for " + segment.getClass().getSimpleName()); // } // } // // // go back and update the length // int bytesWritten = buffer.writerIndex() - dataStartIndex; // int wordsWritten = bytesWritten / 2; // buffer.markWriterIndex(); // buffer.writerIndex(lengthStartIndex); // buffer.writeByte(wordsWritten); // buffer.resetWriterIndex(); // // return buffer; // } // // public static final class PaddedEPath extends EPath { // // public PaddedEPath(List<EPathSegment> segments) { // this(segments.toArray(new EPathSegment[segments.size()])); // } // // public PaddedEPath(EPathSegment... segments) { // super(segments); // } // // @Override // public boolean isPadded() { // return true; // } // // public PaddedEPath append(PaddedEPath other) { // int aLen = getSegments().length; // int bLen = other.getSegments().length; // // EPathSegment[] newSegments = new EPathSegment[aLen + bLen]; // // System.arraycopy(getSegments(), 0, newSegments, 0, aLen); // System.arraycopy(other.getSegments(), 0, newSegments, aLen, bLen); // // return new PaddedEPath(newSegments); // } // // } // // } // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterRequest.java import java.util.function.Consumer; import com.digitalpetri.enip.cip.epath.EPath; import io.netty.buffer.ByteBuf; package com.digitalpetri.enip.cip.structs; public class MessageRouterRequest { private final int serviceCode;
private final EPath.PaddedEPath requestPath;
digitalpetri/ethernet-ip
enip-core/src/main/java/com/digitalpetri/enip/commands/SendRRData.java
// Path: enip-core/src/main/java/com/digitalpetri/enip/cpf/CpfPacket.java // public final class CpfPacket { // // private final CpfItem[] items; // // public CpfPacket(CpfItem... items) { // this.items = items; // } // // public CpfItem[] getItems() { // return items; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // CpfPacket cpfPacket = (CpfPacket) o; // // return Arrays.equals(items, cpfPacket.items); // } // // @Override // public int hashCode() { // return Arrays.hashCode(items); // } // // public static ByteBuf encode(CpfPacket packet, ByteBuf buffer) { // buffer.writeShort(packet.getItems().length); // // for (CpfItem item : packet.getItems()) { // CpfItem.encode(item, buffer); // } // // return buffer; // } // // public static CpfPacket decode(ByteBuf buffer) { // int itemCount = buffer.readUnsignedShort(); // CpfItem[] items = new CpfItem[itemCount]; // // for (int i = 0; i < itemCount; i++) { // items[i] = CpfItem.decode(buffer); // } // // return new CpfPacket(items); // } // }
import com.digitalpetri.enip.cpf.CpfPacket; import io.netty.buffer.ByteBuf;
package com.digitalpetri.enip.commands; public final class SendRRData extends Command { public static final long DEFAULT_INTERFACE_HANDLE = 0; public static final int DEFAULT_TIMEOUT = 0; private final long interfaceHandle; private final int timeout;
// Path: enip-core/src/main/java/com/digitalpetri/enip/cpf/CpfPacket.java // public final class CpfPacket { // // private final CpfItem[] items; // // public CpfPacket(CpfItem... items) { // this.items = items; // } // // public CpfItem[] getItems() { // return items; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // CpfPacket cpfPacket = (CpfPacket) o; // // return Arrays.equals(items, cpfPacket.items); // } // // @Override // public int hashCode() { // return Arrays.hashCode(items); // } // // public static ByteBuf encode(CpfPacket packet, ByteBuf buffer) { // buffer.writeShort(packet.getItems().length); // // for (CpfItem item : packet.getItems()) { // CpfItem.encode(item, buffer); // } // // return buffer; // } // // public static CpfPacket decode(ByteBuf buffer) { // int itemCount = buffer.readUnsignedShort(); // CpfItem[] items = new CpfItem[itemCount]; // // for (int i = 0; i < itemCount; i++) { // items[i] = CpfItem.decode(buffer); // } // // return new CpfPacket(items); // } // } // Path: enip-core/src/main/java/com/digitalpetri/enip/commands/SendRRData.java import com.digitalpetri.enip.cpf.CpfPacket; import io.netty.buffer.ByteBuf; package com.digitalpetri.enip.commands; public final class SendRRData extends Command { public static final long DEFAULT_INTERFACE_HANDLE = 0; public static final int DEFAULT_TIMEOUT = 0; private final long interfaceHandle; private final int timeout;
private final CpfPacket packet;
digitalpetri/ethernet-ip
cip-core/src/main/java/com/digitalpetri/enip/cip/services/GetAttributesAllService.java
// Path: cip-core/src/main/java/com/digitalpetri/enip/cip/CipResponseException.java // public class CipResponseException extends Exception { // // private final int generalStatus; // private final int[] additionalStatus; // // public CipResponseException(int generalStatus, int[] additionalStatus) { // this.generalStatus = generalStatus; // this.additionalStatus = additionalStatus; // } // // public int getGeneralStatus() { // return generalStatus; // } // // public int[] getAdditionalStatus() { // return additionalStatus; // } // // @Override // public String getMessage() { // StringBuilder sb = new StringBuilder(); // // sb.append(String.format("status=0x%02X", generalStatus)); // // CipStatusCodes.getName(generalStatus).ifPresent(name -> sb.append(" [").append(name).append("] ")); // // List<String> as = Arrays.stream(additionalStatus) // .mapToObj(a -> String.format("0x%04X", a)) // .collect(Collectors.toList()); // // String additional = "[" + String.join(",", as) + "]"; // // sb.append(", additional=").append(additional); // // return sb.toString(); // } // // /** // * If {@code ex} is a {@link CipResponseException}, or if a {@link CipResponseException} can be found by walking // * the exception cause chain, return it. // * // * @param ex the {@link Throwable} to extract from. // * @return a {@link CipResponseException} if one was present in the exception chain. // */ // public static Optional<CipResponseException> extract(Throwable ex) { // if (ex instanceof CipResponseException) { // return Optional.of((CipResponseException) ex); // } else { // Throwable cause = ex.getCause(); // return cause != null ? // extract(cause) : Optional.empty(); // } // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/epath/EPath.java // public static final class PaddedEPath extends EPath { // // public PaddedEPath(List<EPathSegment> segments) { // this(segments.toArray(new EPathSegment[segments.size()])); // } // // public PaddedEPath(EPathSegment... segments) { // super(segments); // } // // @Override // public boolean isPadded() { // return true; // } // // public PaddedEPath append(PaddedEPath other) { // int aLen = getSegments().length; // int bLen = other.getSegments().length; // // EPathSegment[] newSegments = new EPathSegment[aLen + bLen]; // // System.arraycopy(getSegments(), 0, newSegments, 0, aLen); // System.arraycopy(other.getSegments(), 0, newSegments, aLen, bLen); // // return new PaddedEPath(newSegments); // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterRequest.java // public class MessageRouterRequest { // // private final int serviceCode; // private final EPath.PaddedEPath requestPath; // private final Consumer<ByteBuf> dataEncoder; // // public MessageRouterRequest(int serviceCode, EPath.PaddedEPath requestPath, ByteBuf requestData) { // this.serviceCode = serviceCode; // this.requestPath = requestPath; // this.dataEncoder = (buffer) -> buffer.writeBytes(requestData); // } // // public MessageRouterRequest(int serviceCode, EPath.PaddedEPath requestPath, Consumer<ByteBuf> dataEncoder) { // this.serviceCode = serviceCode; // this.requestPath = requestPath; // this.dataEncoder = dataEncoder; // } // // public static void encode(MessageRouterRequest request, ByteBuf buffer) { // buffer.writeByte(request.serviceCode); // EPath.encode(request.requestPath, buffer); // request.dataEncoder.accept(buffer); // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterResponse.java // public class MessageRouterResponse { // // private final int serviceCode; // private final int generalStatus; // private final int[] additionalStatus; // // private final ByteBuf data; // // public MessageRouterResponse(int serviceCode, // int generalStatus, // int[] additionalStatus, // @Nonnull ByteBuf data) { // // this.serviceCode = serviceCode; // this.generalStatus = generalStatus; // this.additionalStatus = additionalStatus; // this.data = data; // } // // public int getServiceCode() { // return serviceCode; // } // // public int getGeneralStatus() { // return generalStatus; // } // // public int[] getAdditionalStatus() { // return additionalStatus; // } // // @Nonnull // public ByteBuf getData() { // return data; // } // // public static MessageRouterResponse decode(ByteBuf buffer) { // int serviceCode = buffer.readUnsignedByte(); // buffer.skipBytes(1); // reserved // int generalStatus = buffer.readUnsignedByte(); // // int count = buffer.readUnsignedByte(); // int[] additionalStatus = new int[count]; // for (int i = 0; i < count; i++) { // additionalStatus[i] = buffer.readShort(); // } // // ByteBuf data = buffer.isReadable() ? // buffer.readSlice(buffer.readableBytes()).retain() : Unpooled.EMPTY_BUFFER; // // return new MessageRouterResponse(serviceCode, generalStatus, additionalStatus, data); // } // // }
import com.digitalpetri.enip.cip.CipResponseException; import com.digitalpetri.enip.cip.epath.EPath.PaddedEPath; import com.digitalpetri.enip.cip.structs.MessageRouterRequest; import com.digitalpetri.enip.cip.structs.MessageRouterResponse; import io.netty.buffer.ByteBuf; import io.netty.util.ReferenceCountUtil;
package com.digitalpetri.enip.cip.services; public class GetAttributesAllService implements CipService<ByteBuf> { public static final int SERVICE_CODE = 0x01;
// Path: cip-core/src/main/java/com/digitalpetri/enip/cip/CipResponseException.java // public class CipResponseException extends Exception { // // private final int generalStatus; // private final int[] additionalStatus; // // public CipResponseException(int generalStatus, int[] additionalStatus) { // this.generalStatus = generalStatus; // this.additionalStatus = additionalStatus; // } // // public int getGeneralStatus() { // return generalStatus; // } // // public int[] getAdditionalStatus() { // return additionalStatus; // } // // @Override // public String getMessage() { // StringBuilder sb = new StringBuilder(); // // sb.append(String.format("status=0x%02X", generalStatus)); // // CipStatusCodes.getName(generalStatus).ifPresent(name -> sb.append(" [").append(name).append("] ")); // // List<String> as = Arrays.stream(additionalStatus) // .mapToObj(a -> String.format("0x%04X", a)) // .collect(Collectors.toList()); // // String additional = "[" + String.join(",", as) + "]"; // // sb.append(", additional=").append(additional); // // return sb.toString(); // } // // /** // * If {@code ex} is a {@link CipResponseException}, or if a {@link CipResponseException} can be found by walking // * the exception cause chain, return it. // * // * @param ex the {@link Throwable} to extract from. // * @return a {@link CipResponseException} if one was present in the exception chain. // */ // public static Optional<CipResponseException> extract(Throwable ex) { // if (ex instanceof CipResponseException) { // return Optional.of((CipResponseException) ex); // } else { // Throwable cause = ex.getCause(); // return cause != null ? // extract(cause) : Optional.empty(); // } // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/epath/EPath.java // public static final class PaddedEPath extends EPath { // // public PaddedEPath(List<EPathSegment> segments) { // this(segments.toArray(new EPathSegment[segments.size()])); // } // // public PaddedEPath(EPathSegment... segments) { // super(segments); // } // // @Override // public boolean isPadded() { // return true; // } // // public PaddedEPath append(PaddedEPath other) { // int aLen = getSegments().length; // int bLen = other.getSegments().length; // // EPathSegment[] newSegments = new EPathSegment[aLen + bLen]; // // System.arraycopy(getSegments(), 0, newSegments, 0, aLen); // System.arraycopy(other.getSegments(), 0, newSegments, aLen, bLen); // // return new PaddedEPath(newSegments); // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterRequest.java // public class MessageRouterRequest { // // private final int serviceCode; // private final EPath.PaddedEPath requestPath; // private final Consumer<ByteBuf> dataEncoder; // // public MessageRouterRequest(int serviceCode, EPath.PaddedEPath requestPath, ByteBuf requestData) { // this.serviceCode = serviceCode; // this.requestPath = requestPath; // this.dataEncoder = (buffer) -> buffer.writeBytes(requestData); // } // // public MessageRouterRequest(int serviceCode, EPath.PaddedEPath requestPath, Consumer<ByteBuf> dataEncoder) { // this.serviceCode = serviceCode; // this.requestPath = requestPath; // this.dataEncoder = dataEncoder; // } // // public static void encode(MessageRouterRequest request, ByteBuf buffer) { // buffer.writeByte(request.serviceCode); // EPath.encode(request.requestPath, buffer); // request.dataEncoder.accept(buffer); // } // // } // // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/structs/MessageRouterResponse.java // public class MessageRouterResponse { // // private final int serviceCode; // private final int generalStatus; // private final int[] additionalStatus; // // private final ByteBuf data; // // public MessageRouterResponse(int serviceCode, // int generalStatus, // int[] additionalStatus, // @Nonnull ByteBuf data) { // // this.serviceCode = serviceCode; // this.generalStatus = generalStatus; // this.additionalStatus = additionalStatus; // this.data = data; // } // // public int getServiceCode() { // return serviceCode; // } // // public int getGeneralStatus() { // return generalStatus; // } // // public int[] getAdditionalStatus() { // return additionalStatus; // } // // @Nonnull // public ByteBuf getData() { // return data; // } // // public static MessageRouterResponse decode(ByteBuf buffer) { // int serviceCode = buffer.readUnsignedByte(); // buffer.skipBytes(1); // reserved // int generalStatus = buffer.readUnsignedByte(); // // int count = buffer.readUnsignedByte(); // int[] additionalStatus = new int[count]; // for (int i = 0; i < count; i++) { // additionalStatus[i] = buffer.readShort(); // } // // ByteBuf data = buffer.isReadable() ? // buffer.readSlice(buffer.readableBytes()).retain() : Unpooled.EMPTY_BUFFER; // // return new MessageRouterResponse(serviceCode, generalStatus, additionalStatus, data); // } // // } // Path: cip-core/src/main/java/com/digitalpetri/enip/cip/services/GetAttributesAllService.java import com.digitalpetri.enip.cip.CipResponseException; import com.digitalpetri.enip.cip.epath.EPath.PaddedEPath; import com.digitalpetri.enip.cip.structs.MessageRouterRequest; import com.digitalpetri.enip.cip.structs.MessageRouterResponse; import io.netty.buffer.ByteBuf; import io.netty.util.ReferenceCountUtil; package com.digitalpetri.enip.cip.services; public class GetAttributesAllService implements CipService<ByteBuf> { public static final int SERVICE_CODE = 0x01;
private final PaddedEPath requestPath;
redomar/JavaGame
src/com/redomar/game/objects/InventoryWindow.java
// Path: src/com/redomar/game/menu/DedicatedJFrame.java // public class DedicatedJFrame extends Canvas { // // private static final long serialVersionUID = 1L; // private static JFrame frame; // // public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME) { // setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // // setFrame(new JFrame(NAME)); // //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setLayout(new BorderLayout()); // frame.add(this, BorderLayout.CENTER); // frame.pack(); // frame.setResizable(false); // frame.setLocationRelativeTo(null); // frame.setVisible(true); // } // // public static JFrame getFrameStatic() { // return frame; // } // // public JFrame getFrame() { // return frame; // } // // public void setFrame(JFrame frame) { // DedicatedJFrame.frame = frame; // } // // public void stopFrame() { // frame.dispose(); // } // // }
import com.redomar.game.menu.DedicatedJFrame; import java.awt.*; import java.awt.image.BufferStrategy;
package com.redomar.game.objects; public class InventoryWindow implements Runnable{ private static final int WIDTH = 160; private static final int HEIGHT = (WIDTH / 3 * 2); private static final int SCALE = 2; private static final String NAME = "Inventory"; private static boolean running = false;
// Path: src/com/redomar/game/menu/DedicatedJFrame.java // public class DedicatedJFrame extends Canvas { // // private static final long serialVersionUID = 1L; // private static JFrame frame; // // public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME) { // setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // // setFrame(new JFrame(NAME)); // //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setLayout(new BorderLayout()); // frame.add(this, BorderLayout.CENTER); // frame.pack(); // frame.setResizable(false); // frame.setLocationRelativeTo(null); // frame.setVisible(true); // } // // public static JFrame getFrameStatic() { // return frame; // } // // public JFrame getFrame() { // return frame; // } // // public void setFrame(JFrame frame) { // DedicatedJFrame.frame = frame; // } // // public void stopFrame() { // frame.dispose(); // } // // } // Path: src/com/redomar/game/objects/InventoryWindow.java import com.redomar.game.menu.DedicatedJFrame; import java.awt.*; import java.awt.image.BufferStrategy; package com.redomar.game.objects; public class InventoryWindow implements Runnable{ private static final int WIDTH = 160; private static final int HEIGHT = (WIDTH / 3 * 2); private static final int SCALE = 2; private static final String NAME = "Inventory"; private static boolean running = false;
private static DedicatedJFrame frame;
redomar/JavaGame
src/com/redomar/game/objects/InventoryHandler.java
// Path: src/com/redomar/game/menu/DedicatedJFrame.java // public class DedicatedJFrame extends Canvas { // // private static final long serialVersionUID = 1L; // private static JFrame frame; // // public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME) { // setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // // setFrame(new JFrame(NAME)); // //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setLayout(new BorderLayout()); // frame.add(this, BorderLayout.CENTER); // frame.pack(); // frame.setResizable(false); // frame.setLocationRelativeTo(null); // frame.setVisible(true); // } // // public static JFrame getFrameStatic() { // return frame; // } // // public JFrame getFrame() { // return frame; // } // // public void setFrame(JFrame frame) { // DedicatedJFrame.frame = frame; // } // // public void stopFrame() { // frame.dispose(); // } // // }
import com.redomar.game.menu.DedicatedJFrame; import java.awt.event.WindowEvent; import java.awt.event.WindowListener;
package com.redomar.game.objects; public class InventoryHandler implements WindowListener { @SuppressWarnings("unused")
// Path: src/com/redomar/game/menu/DedicatedJFrame.java // public class DedicatedJFrame extends Canvas { // // private static final long serialVersionUID = 1L; // private static JFrame frame; // // public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME) { // setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE)); // // setFrame(new JFrame(NAME)); // //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setLayout(new BorderLayout()); // frame.add(this, BorderLayout.CENTER); // frame.pack(); // frame.setResizable(false); // frame.setLocationRelativeTo(null); // frame.setVisible(true); // } // // public static JFrame getFrameStatic() { // return frame; // } // // public JFrame getFrame() { // return frame; // } // // public void setFrame(JFrame frame) { // DedicatedJFrame.frame = frame; // } // // public void stopFrame() { // frame.dispose(); // } // // } // Path: src/com/redomar/game/objects/InventoryHandler.java import com.redomar.game.menu.DedicatedJFrame; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; package com.redomar.game.objects; public class InventoryHandler implements WindowListener { @SuppressWarnings("unused")
private DedicatedJFrame frame;
redomar/JavaGame
src/com/redomar/game/audio/AudioHandler.java
// Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import javax.sound.sampled.*; import java.io.File;
package com.redomar.game.audio; public class AudioHandler { private Clip clip; private boolean active = false;
// Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/audio/AudioHandler.java import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import javax.sound.sampled.*; import java.io.File; package com.redomar.game.audio; public class AudioHandler { private Clip clip; private boolean active = false;
private Printing p = new Printing();
redomar/JavaGame
src/com/redomar/game/audio/AudioHandler.java
// Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import javax.sound.sampled.*; import java.io.File;
package com.redomar.game.audio; public class AudioHandler { private Clip clip; private boolean active = false; private Printing p = new Printing(); public AudioHandler(String path){ check(path); } public AudioHandler(File file){ check(file.toString()); } private void check(String path){ try { if(path != ""){ initiate(path); } else { throw new NullPointerException(); } } catch (NullPointerException e){
// Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/audio/AudioHandler.java import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import javax.sound.sampled.*; import java.io.File; package com.redomar.game.audio; public class AudioHandler { private Clip clip; private boolean active = false; private Printing p = new Printing(); public AudioHandler(String path){ check(path); } public AudioHandler(File file){ check(file.toString()); } private void check(String path){ try { if(path != ""){ initiate(path); } else { throw new NullPointerException(); } } catch (NullPointerException e){
p.print("Destination Cannot be empty", PrintTypes.ERROR);
redomar/JavaGame
src/com/redomar/game/script/Printing.java
// Path: src/com/redomar/game/lib/Time.java // public class Time { // // public Time() { // // } // // public synchronized String getTime() { // Calendar cal = Calendar.getInstance(); // cal.getTime(); // SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); // return (sdf.format(cal.getTime())); // } // // public synchronized String getTimeDate() { // Calendar cal = Calendar.getInstance(); // cal.getTime(); // SimpleDateFormat sdf = new SimpleDateFormat("E dd MMM Y HH:mm:ss"); // return (sdf.format(cal.getTime())); // } // }
import com.redomar.game.lib.Time; import java.io.File; import java.util.Arrays;
package com.redomar.game.script; public class Printing { private static int lineNumber = 0; private PrintTypes type;
// Path: src/com/redomar/game/lib/Time.java // public class Time { // // public Time() { // // } // // public synchronized String getTime() { // Calendar cal = Calendar.getInstance(); // cal.getTime(); // SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); // return (sdf.format(cal.getTime())); // } // // public synchronized String getTimeDate() { // Calendar cal = Calendar.getInstance(); // cal.getTime(); // SimpleDateFormat sdf = new SimpleDateFormat("E dd MMM Y HH:mm:ss"); // return (sdf.format(cal.getTime())); // } // } // Path: src/com/redomar/game/script/Printing.java import com.redomar.game.lib.Time; import java.io.File; import java.util.Arrays; package com.redomar.game.script; public class Printing { private static int lineNumber = 0; private PrintTypes type;
private Time time = new Time();
redomar/JavaGame
src/com/redomar/game/InputHandler.java
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext;
package com.redomar.game; public class InputHandler implements KeyListener { private boolean isAzertyCountry; private Key up = new Key(); private Key down = new Key(); private Key left = new Key(); private Key right = new Key();
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/InputHandler.java import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext; package com.redomar.game; public class InputHandler implements KeyListener { private boolean isAzertyCountry; private Key up = new Key(); private Key down = new Key(); private Key left = new Key(); private Key right = new Key();
private Printing print = new Printing();
redomar/JavaGame
src/com/redomar/game/InputHandler.java
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext;
package com.redomar.game; public class InputHandler implements KeyListener { private boolean isAzertyCountry; private Key up = new Key(); private Key down = new Key(); private Key left = new Key(); private Key right = new Key(); private Printing print = new Printing(); private int map; private boolean ignoreInput = false; private boolean toggleMusic = false;
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/InputHandler.java import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext; package com.redomar.game; public class InputHandler implements KeyListener { private boolean isAzertyCountry; private Key up = new Key(); private Key down = new Key(); private Key left = new Key(); private Key right = new Key(); private Printing print = new Printing(); private int map; private boolean ignoreInput = false; private boolean toggleMusic = false;
private PopUp popup = new PopUp();
redomar/JavaGame
src/com/redomar/game/InputHandler.java
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext;
private void toggleKey(int keyCode, boolean isPressed) { if (!isIgnoreInput()) { if (keyCode == KeyEvent.VK_Z && isAzertyCountry || keyCode == KeyEvent.VK_W && !isAzertyCountry || keyCode == KeyEvent.VK_UP) { up.toggle(isPressed); } if (keyCode == KeyEvent.VK_Q && isAzertyCountry || keyCode == KeyEvent.VK_A && !isAzertyCountry || keyCode == KeyEvent.VK_LEFT) { left.toggle(isPressed); } if (keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_DOWN) { down.toggle(isPressed); } if (keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_RIGHT) { right.toggle(isPressed); } } if (isIgnoreInput()) { up.toggle(false); down.toggle(false); left.toggle(false); right.toggle(false); } if (keyCode == KeyEvent.VK_M) { if(!toggleMusic){ Game.getBackgroundMusic().play();
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/InputHandler.java import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext; private void toggleKey(int keyCode, boolean isPressed) { if (!isIgnoreInput()) { if (keyCode == KeyEvent.VK_Z && isAzertyCountry || keyCode == KeyEvent.VK_W && !isAzertyCountry || keyCode == KeyEvent.VK_UP) { up.toggle(isPressed); } if (keyCode == KeyEvent.VK_Q && isAzertyCountry || keyCode == KeyEvent.VK_A && !isAzertyCountry || keyCode == KeyEvent.VK_LEFT) { left.toggle(isPressed); } if (keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_DOWN) { down.toggle(isPressed); } if (keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_RIGHT) { right.toggle(isPressed); } } if (isIgnoreInput()) { up.toggle(false); down.toggle(false); left.toggle(false); right.toggle(false); } if (keyCode == KeyEvent.VK_M) { if(!toggleMusic){ Game.getBackgroundMusic().play();
print.print("Playing Music", PrintTypes.MUSIC);
redomar/JavaGame
src/com/redomar/game/InputHandler.java
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // }
import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext;
} if (keyCode == KeyEvent.VK_N) { if (Game.getPlayer().isMoving()) { setIgnoreInput(true); int n = popup.Warn("Stop moving before spawning dummy AI"); if (n == 0) { setIgnoreInput(false); } return; } if (!Game.isNpc()) { Game.setNpc(true); Game.npcSpawn(); print.print("Dummy has been spawned", PrintTypes.GAME); } } if (keyCode == KeyEvent.VK_K) { if (Game.isNpc()) { Game.setNpc(false); Game.npcKill(); print.print("Dummy has been removed", PrintTypes.GAME); } } if (keyCode == KeyEvent.VK_A && isAzertyCountry || keyCode == KeyEvent.VK_Q && !isAzertyCountry) this.quitGame(); if (keyCode == KeyEvent.VK_BACK_QUOTE) { if (!Game.isClosing() && !Game.isDevMode()) { Game.setDevMode(true);
// Path: src/com/redomar/game/lib/SleepThread.java // public class SleepThread implements Runnable{ // // public void run() { // try { // Thread.sleep(1500); // Game.setClosing(false); // System.out.println("time up"); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } // } // // Path: src/com/redomar/game/script/PopUp.java // public class PopUp{ // // private JFrame frame; // public boolean active; // // public PopUp(){ // active = true; // } // // public int Warn(String msg){ // Object[] options = {"Continue"}; // if (active) { // frame = Game.getFrame(); // return JOptionPane.showOptionDialog(frame, msg, "Notice", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE, // null, options, options[0]); // } // else // return 1; // } // } // // Path: src/com/redomar/game/script/PrintTypes.java // public enum PrintTypes { // GAME, // LEVEL, // MUSIC, // ERROR, // TEST, // NETWORK, // SERVER // } // // Path: src/com/redomar/game/script/Printing.java // public class Printing { // // private static int lineNumber = 0; // private PrintTypes type; // private Time time = new Time(); // private String message; // private String msgTime; // private String msgType; // private boolean errorMode = false; // private PrintToLog logFile; // // public Printing() { // // } // // public void print(String message, PrintTypes type) { // this.type = type; // setMessage(message); // readMessageType(type); // printOut(); // } // // private void printOut(){ // msgTime = "[" + time.getTime() + "]"; // msgType = "[" + type.toString() + "]"; // // logFile = printToLogType(type); // if (lineNumber == 0) { // // String dashes = ""; // String title = ("[" + time.getTimeDate() + "]"); // char dash = '-'; // int number = title.length() / 3; // // char[] repeat = new char[number]; // Arrays.fill(repeat, dash); // dashes += new String(repeat); // // logFile.log(dashes + title + dashes + "\n" + msgTime + msgType + this.getMessage()); // lineNumber++; // } else { // logFile.log(msgTime + msgType + this.getMessage()); // } // // // if(errorMode) { // System.err.println(msgType + msgTime + message); // }else{ // System.out.println(msgType + msgTime + message); // } // } // // private PrintToLog printToLogType(PrintTypes type){ // if (type == PrintTypes.TEST){ // return new PrintToLog(".PrintType-TEST.txt"); // } else { // return new PrintToLog(".log.txt"); // } // } // // public void removeLog(){ // new File(".log.txt").delete(); // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // private void readMessageType(PrintTypes type){ // this.errorMode = type == PrintTypes.ERROR; // } // } // Path: src/com/redomar/game/InputHandler.java import com.redomar.game.lib.SleepThread; import com.redomar.game.script.PopUp; import com.redomar.game.script.PrintTypes; import com.redomar.game.script.Printing; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.im.InputContext; } if (keyCode == KeyEvent.VK_N) { if (Game.getPlayer().isMoving()) { setIgnoreInput(true); int n = popup.Warn("Stop moving before spawning dummy AI"); if (n == 0) { setIgnoreInput(false); } return; } if (!Game.isNpc()) { Game.setNpc(true); Game.npcSpawn(); print.print("Dummy has been spawned", PrintTypes.GAME); } } if (keyCode == KeyEvent.VK_K) { if (Game.isNpc()) { Game.setNpc(false); Game.npcKill(); print.print("Dummy has been removed", PrintTypes.GAME); } } if (keyCode == KeyEvent.VK_A && isAzertyCountry || keyCode == KeyEvent.VK_Q && !isAzertyCountry) this.quitGame(); if (keyCode == KeyEvent.VK_BACK_QUOTE) { if (!Game.isClosing() && !Game.isDevMode()) { Game.setDevMode(true);
new Thread(new SleepThread());
redomar/JavaGame
src/com/redomar/game/lib/Font.java
// Path: src/com/redomar/game/gfx/Screen.java // public class Screen { // // private static final int MAP_WIDTH = 64; // private static final int MAP_WIDTH_MASK = MAP_WIDTH - 1; // // private static final byte BIT_MIRROR_X = 0x01; // private static final byte BIT_MIRROR_Y = 0x02; // // private int[] pixels; // // private int xOffset = 0; // private int yOffset = 0; // // private int width; // private int height; // // private SpriteSheet sheet; // // /** // * Constructs the draw area // * @param width width of the screen // * @param height height of the screen // * @param sheet Sprite-sheet selector. Constructed Spritesheet needs to be here, // * Sprite-sheet cp requires path only. // */ // public Screen(int width, int height, SpriteSheet sheet) { // // this.setWidth(width); // this.setHeight(height); // this.sheet = sheet; // // setPixels(new int[width * height]); // } // // public static int getMapWidthMask() { // return MAP_WIDTH_MASK; // } // // // /** // * Rendering sprites from Spritesheet onto the game world. // * Render contstucter requires // * @param xPos X Postion of subject // * @param yPos Y Postion of subject // * @param tile tile location. e.g 7 * 32 + 1 is the oblong bullet on the 7th row 2nd colomn // * @param colour Using established colouring nomanclature. i.e. use com.redomar.game.gfx.Colours // * @param mirrorDir flip Direction: 0x01 flip verticle, 0x02 flip horizontal. // * @param scale Scale // */ // public void render(int xPos, int yPos, int tile, int colour, int mirrorDir, // int scale) { // xPos -= xOffset; // yPos -= yOffset; // // boolean mirrorX = (mirrorDir & BIT_MIRROR_X) > 0; // boolean mirrorY = (mirrorDir & BIT_MIRROR_Y) > 0; // // int scaleMap = scale - 1; // int xTile = tile % 32; // int yTile = tile / 32; // int tileOffset = (xTile << 3) + (yTile << 3) * sheet.getWidth(); // // for (int y = 0; y < 8; y++) { // int ySheet = y; // // if (mirrorY) { // ySheet = 7 - y; // } // // int yPixel = y + yPos + (y * scaleMap) - ((scaleMap << 3) / 2); // // for (int x = 0; x < 8; x++) { // int xSheet = x; // // if (mirrorX) { // xSheet = 7 - x; // } // // int xPixel = x + xPos + (x * scaleMap) - ((scaleMap << 3) / 2); // // int col = (colour >> (sheet.pixels[xSheet + ySheet // * sheet.getWidth() + tileOffset] * 8)) & 255; // if (col < 255) { // // for (int yScale = 0; yScale < scale; yScale++) { // // if (yPixel + yScale < 0 // | yPixel + yScale >= getHeight()) { // continue; // } // // for (int xScale = 0; xScale < scale; xScale++) { // // if (xPixel + xScale < 0 // | xPixel + xScale >= getWidth()) { // continue; // } // // getPixels()[(xPixel + xScale) + (yPixel + yScale) // * getWidth()] = col; // } // } // // } // } // } // // } // // public void setOffset(int xOffset, int yOffset) { // this.xOffset = xOffset; // this.yOffset = yOffset; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int[] getPixels() { // return pixels; // } // // public void setPixels(int[] pixels) { // this.pixels = pixels; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // }
import com.redomar.game.gfx.Screen;
package com.redomar.game.lib; public class Font { private static java.awt.Font arial; private static java.awt.Font segoe; private static String chars = "" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + "0123456789.,:;'\"!?$%()-=+/ "; public Font() { Font.setArial(new java.awt.Font("Arial", java.awt.Font.BOLD, 14)); Font.setSegoe(new java.awt.Font("Segoe UI", java.awt.Font.BOLD, 14)); }
// Path: src/com/redomar/game/gfx/Screen.java // public class Screen { // // private static final int MAP_WIDTH = 64; // private static final int MAP_WIDTH_MASK = MAP_WIDTH - 1; // // private static final byte BIT_MIRROR_X = 0x01; // private static final byte BIT_MIRROR_Y = 0x02; // // private int[] pixels; // // private int xOffset = 0; // private int yOffset = 0; // // private int width; // private int height; // // private SpriteSheet sheet; // // /** // * Constructs the draw area // * @param width width of the screen // * @param height height of the screen // * @param sheet Sprite-sheet selector. Constructed Spritesheet needs to be here, // * Sprite-sheet cp requires path only. // */ // public Screen(int width, int height, SpriteSheet sheet) { // // this.setWidth(width); // this.setHeight(height); // this.sheet = sheet; // // setPixels(new int[width * height]); // } // // public static int getMapWidthMask() { // return MAP_WIDTH_MASK; // } // // // /** // * Rendering sprites from Spritesheet onto the game world. // * Render contstucter requires // * @param xPos X Postion of subject // * @param yPos Y Postion of subject // * @param tile tile location. e.g 7 * 32 + 1 is the oblong bullet on the 7th row 2nd colomn // * @param colour Using established colouring nomanclature. i.e. use com.redomar.game.gfx.Colours // * @param mirrorDir flip Direction: 0x01 flip verticle, 0x02 flip horizontal. // * @param scale Scale // */ // public void render(int xPos, int yPos, int tile, int colour, int mirrorDir, // int scale) { // xPos -= xOffset; // yPos -= yOffset; // // boolean mirrorX = (mirrorDir & BIT_MIRROR_X) > 0; // boolean mirrorY = (mirrorDir & BIT_MIRROR_Y) > 0; // // int scaleMap = scale - 1; // int xTile = tile % 32; // int yTile = tile / 32; // int tileOffset = (xTile << 3) + (yTile << 3) * sheet.getWidth(); // // for (int y = 0; y < 8; y++) { // int ySheet = y; // // if (mirrorY) { // ySheet = 7 - y; // } // // int yPixel = y + yPos + (y * scaleMap) - ((scaleMap << 3) / 2); // // for (int x = 0; x < 8; x++) { // int xSheet = x; // // if (mirrorX) { // xSheet = 7 - x; // } // // int xPixel = x + xPos + (x * scaleMap) - ((scaleMap << 3) / 2); // // int col = (colour >> (sheet.pixels[xSheet + ySheet // * sheet.getWidth() + tileOffset] * 8)) & 255; // if (col < 255) { // // for (int yScale = 0; yScale < scale; yScale++) { // // if (yPixel + yScale < 0 // | yPixel + yScale >= getHeight()) { // continue; // } // // for (int xScale = 0; xScale < scale; xScale++) { // // if (xPixel + xScale < 0 // | xPixel + xScale >= getWidth()) { // continue; // } // // getPixels()[(xPixel + xScale) + (yPixel + yScale) // * getWidth()] = col; // } // } // // } // } // } // // } // // public void setOffset(int xOffset, int yOffset) { // this.xOffset = xOffset; // this.yOffset = yOffset; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int[] getPixels() { // return pixels; // } // // public void setPixels(int[] pixels) { // this.pixels = pixels; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // } // Path: src/com/redomar/game/lib/Font.java import com.redomar.game.gfx.Screen; package com.redomar.game.lib; public class Font { private static java.awt.Font arial; private static java.awt.Font segoe; private static String chars = "" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + "0123456789.,:;'\"!?$%()-=+/ "; public Font() { Font.setArial(new java.awt.Font("Arial", java.awt.Font.BOLD, 14)); Font.setSegoe(new java.awt.Font("Segoe UI", java.awt.Font.BOLD, 14)); }
public static void render(String msg, Screen screen, int x, int y,
vsl1978/mybatis-generator-pluginsplus
mybatis-generator-pluginsplus/src/test/java/xyz/vsl/mybatis/generator/pluginsplus/FindAnnotationTest.java
// Path: mybatis-generator-pluginsplus/src/main/java/xyz/vsl/mybatis/generator/pluginsplus/Objects.java // public static int findAnnotaion(List<String> annotations, String annotationClassName) { // return findAnnotaion(annotations, annotationClassName, null); // }
import org.junit.Before; import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.junit.Assert.*; import static xyz.vsl.mybatis.generator.pluginsplus.Objects.findAnnotaion;
package xyz.vsl.mybatis.generator.pluginsplus; /** * @author Vladimir Lokhov */ public class FindAnnotationTest { private List<String> annotations; @Before public void initialize() { annotations = new ArrayList<String>(); annotations.add("@NotNull"); annotations.add("\t@\tColumn(name=\"test\")"); } @Test public void found() {
// Path: mybatis-generator-pluginsplus/src/main/java/xyz/vsl/mybatis/generator/pluginsplus/Objects.java // public static int findAnnotaion(List<String> annotations, String annotationClassName) { // return findAnnotaion(annotations, annotationClassName, null); // } // Path: mybatis-generator-pluginsplus/src/test/java/xyz/vsl/mybatis/generator/pluginsplus/FindAnnotationTest.java import org.junit.Before; import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.junit.Assert.*; import static xyz.vsl.mybatis.generator.pluginsplus.Objects.findAnnotaion; package xyz.vsl.mybatis.generator.pluginsplus; /** * @author Vladimir Lokhov */ public class FindAnnotationTest { private List<String> annotations; @Before public void initialize() { annotations = new ArrayList<String>(); annotations.add("@NotNull"); annotations.add("\t@\tColumn(name=\"test\")"); } @Test public void found() {
assertEquals("#0, null", 0, findAnnotaion(annotations, "javax.validation.constraints.NotNull", null));
chickling/kmanager
src/main/java/com/chickling/kmanager/email/EmailSender.java
// Path: src/main/java/com/chickling/kmanager/config/AppConfig.java // public class AppConfig { // private String clusterName; // private String apiType = ""; // private String esHosts; // private String esIndex = ""; // private Integer dataCollectFrequency = 1; // // private String zkHosts; // private Integer zkSessionTimeout = 30 * 1000; // private Integer zkConnectionTimeout = 30 * 1000; // // private Boolean isAlertEnabled = false; // // private Integer offsetInfoCacheQueue = 500; // private Integer offsetInfoHandler; // private String taskFolder = "tasks"; // // private Boolean smtpAuth = false; // private String smtpUser; // private String smtpPasswd; // private String smtpServer; // private String mailSender; // private String mailSubject; // // private Long excludeByLastSeen = 2592000L; // // public String getApiType() { // return apiType; // } // // public void setApiType(String apiType) { // this.apiType = apiType; // } // // public String getZkHosts() { // return zkHosts; // } // // public void setZkHosts(String zkHosts) { // this.zkHosts = zkHosts; // } // // public Boolean getIsAlertEnabled() { // return isAlertEnabled; // } // // public void setIsAlertEnabled(Boolean isAlertEnabled) { // this.isAlertEnabled = isAlertEnabled; // } // // public String getEsHosts() { // return esHosts; // } // // public void setEsHosts(String esHosts) { // this.esHosts = esHosts; // } // // public String getEsIndex() { // return esIndex.toLowerCase(); // } // // public void setEsIndex(String esIndex) { // this.esIndex = esIndex; // } // // public Integer getDataCollectFrequency() { // return dataCollectFrequency; // } // // public void setDataCollectFrequency(Integer dataCollectFrequency) { // this.dataCollectFrequency = dataCollectFrequency; // } // // public Integer getZkSessionTimeout() { // return zkSessionTimeout; // } // // public void setZkSessionTimeout(Integer zkSessionTimeout) { // this.zkSessionTimeout = zkSessionTimeout; // } // // public Integer getZkConnectionTimeout() { // return zkConnectionTimeout; // } // // public void setZkConnectionTimeout(Integer zkConnectionTimeout) { // this.zkConnectionTimeout = zkConnectionTimeout; // } // // public Integer getOffsetInfoCacheQueue() { // return offsetInfoCacheQueue; // } // // public void setOffsetInfoCacheQueue(Integer offsetInfoCacheQueue) { // this.offsetInfoCacheQueue = offsetInfoCacheQueue; // } // // public Integer getOffsetInfoHandler() { // return offsetInfoHandler; // } // // public void setOffsetInfoHandler(Integer offsetInfoHandler) { // this.offsetInfoHandler = offsetInfoHandler; // } // // public Boolean getSmtpAuth() { // return smtpAuth; // } // // public void setSmtpAuth(Boolean smtpAuth) { // this.smtpAuth = smtpAuth; // } // // public String getSmtpUser() { // return smtpUser; // } // // public void setSmtpUser(String smtpUser) { // this.smtpUser = smtpUser; // } // // public String getSmtpPasswd() { // return smtpPasswd; // } // // public void setSmtpPasswd(String smtpPasswd) { // this.smtpPasswd = smtpPasswd; // } // // public String getSmtpServer() { // return smtpServer; // } // // public void setSmtpServer(String smtpServer) { // this.smtpServer = smtpServer; // } // // public String getMailSender() { // return mailSender; // } // // public void setMailSender(String mailSender) { // this.mailSender = mailSender; // } // // public String getMailSubject() { // return mailSubject; // } // // public void setMailSubject(String mailSubject) { // this.mailSubject = mailSubject; // } // // public String getTaskFolder() { // return taskFolder; // } // // public void setTaskFolder(String taskFolder) { // this.taskFolder = taskFolder; // } // // public Long getExcludeByLastSeen() { // return excludeByLastSeen; // } // // public void setExcludeByLastSeen(Long excludeByLastSeen) { // this.excludeByLastSeen = excludeByLastSeen; // } // // public void setClusterName(String clusterName){ // this.clusterName = clusterName; // } // public String getClusterName(){ // if(this.clusterName == null){ // return ""; // } // return this.clusterName; // } // }
import java.util.Date; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.config.AppConfig;
package com.chickling.kmanager.email; /** * @author Hulva Luva.H * */ public class EmailSender { private static Logger LOG = LoggerFactory.getLogger(EmailSender.class);
// Path: src/main/java/com/chickling/kmanager/config/AppConfig.java // public class AppConfig { // private String clusterName; // private String apiType = ""; // private String esHosts; // private String esIndex = ""; // private Integer dataCollectFrequency = 1; // // private String zkHosts; // private Integer zkSessionTimeout = 30 * 1000; // private Integer zkConnectionTimeout = 30 * 1000; // // private Boolean isAlertEnabled = false; // // private Integer offsetInfoCacheQueue = 500; // private Integer offsetInfoHandler; // private String taskFolder = "tasks"; // // private Boolean smtpAuth = false; // private String smtpUser; // private String smtpPasswd; // private String smtpServer; // private String mailSender; // private String mailSubject; // // private Long excludeByLastSeen = 2592000L; // // public String getApiType() { // return apiType; // } // // public void setApiType(String apiType) { // this.apiType = apiType; // } // // public String getZkHosts() { // return zkHosts; // } // // public void setZkHosts(String zkHosts) { // this.zkHosts = zkHosts; // } // // public Boolean getIsAlertEnabled() { // return isAlertEnabled; // } // // public void setIsAlertEnabled(Boolean isAlertEnabled) { // this.isAlertEnabled = isAlertEnabled; // } // // public String getEsHosts() { // return esHosts; // } // // public void setEsHosts(String esHosts) { // this.esHosts = esHosts; // } // // public String getEsIndex() { // return esIndex.toLowerCase(); // } // // public void setEsIndex(String esIndex) { // this.esIndex = esIndex; // } // // public Integer getDataCollectFrequency() { // return dataCollectFrequency; // } // // public void setDataCollectFrequency(Integer dataCollectFrequency) { // this.dataCollectFrequency = dataCollectFrequency; // } // // public Integer getZkSessionTimeout() { // return zkSessionTimeout; // } // // public void setZkSessionTimeout(Integer zkSessionTimeout) { // this.zkSessionTimeout = zkSessionTimeout; // } // // public Integer getZkConnectionTimeout() { // return zkConnectionTimeout; // } // // public void setZkConnectionTimeout(Integer zkConnectionTimeout) { // this.zkConnectionTimeout = zkConnectionTimeout; // } // // public Integer getOffsetInfoCacheQueue() { // return offsetInfoCacheQueue; // } // // public void setOffsetInfoCacheQueue(Integer offsetInfoCacheQueue) { // this.offsetInfoCacheQueue = offsetInfoCacheQueue; // } // // public Integer getOffsetInfoHandler() { // return offsetInfoHandler; // } // // public void setOffsetInfoHandler(Integer offsetInfoHandler) { // this.offsetInfoHandler = offsetInfoHandler; // } // // public Boolean getSmtpAuth() { // return smtpAuth; // } // // public void setSmtpAuth(Boolean smtpAuth) { // this.smtpAuth = smtpAuth; // } // // public String getSmtpUser() { // return smtpUser; // } // // public void setSmtpUser(String smtpUser) { // this.smtpUser = smtpUser; // } // // public String getSmtpPasswd() { // return smtpPasswd; // } // // public void setSmtpPasswd(String smtpPasswd) { // this.smtpPasswd = smtpPasswd; // } // // public String getSmtpServer() { // return smtpServer; // } // // public void setSmtpServer(String smtpServer) { // this.smtpServer = smtpServer; // } // // public String getMailSender() { // return mailSender; // } // // public void setMailSender(String mailSender) { // this.mailSender = mailSender; // } // // public String getMailSubject() { // return mailSubject; // } // // public void setMailSubject(String mailSubject) { // this.mailSubject = mailSubject; // } // // public String getTaskFolder() { // return taskFolder; // } // // public void setTaskFolder(String taskFolder) { // this.taskFolder = taskFolder; // } // // public Long getExcludeByLastSeen() { // return excludeByLastSeen; // } // // public void setExcludeByLastSeen(Long excludeByLastSeen) { // this.excludeByLastSeen = excludeByLastSeen; // } // // public void setClusterName(String clusterName){ // this.clusterName = clusterName; // } // public String getClusterName(){ // if(this.clusterName == null){ // return ""; // } // return this.clusterName; // } // } // Path: src/main/java/com/chickling/kmanager/email/EmailSender.java import java.util.Date; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.config.AppConfig; package com.chickling.kmanager.email; /** * @author Hulva Luva.H * */ public class EmailSender { private static Logger LOG = LoggerFactory.getLogger(EmailSender.class);
private static AppConfig config;
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/elasticsearch/Ielasticsearch.java
// Path: src/main/java/com/chickling/kmanager/model/OffsetHistoryQueryParams.java // public class OffsetHistoryQueryParams { // private String interval; // 5m, 30m, 1h, 1d // private String range; // 8h, 16h, 1d, 2d, 1w // private String rangeto; // private String topic; // private String group; // // public String getTopic() { // return topic; // } // // public void setTopic(String topic) { // this.topic = topic; // } // // public String getGroup() { // return group; // } // // public void setGroup(String group) { // this.group = group; // } // // public String getInterval() { // return interval; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getRange() { // return range; // } // // public void setRange(String range) { // this.range = range; // } // // public String getRangeto() { // return rangeto; // } // // public void setRangeto(String rangeto) { // this.rangeto = rangeto; // } // // @Override // public String toString() { // return "LagRequestParams [interval=" + interval + ", range=" + range + ", rangeTo=" + rangeto + ", topic=" // + topic + ", group=" + group + "]"; // } // } // // Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // }
import java.util.List; import org.json.JSONObject; import com.chickling.kmanager.model.OffsetHistoryQueryParams; import com.chickling.kmanager.model.OffsetPoints;
package com.chickling.kmanager.utils.elasticsearch; /** * @author Hulva Luva.H * @since 2017-7-19 * */ public interface Ielasticsearch { void bulkIndex(JSONObject data, String docType, String indexPrefix);
// Path: src/main/java/com/chickling/kmanager/model/OffsetHistoryQueryParams.java // public class OffsetHistoryQueryParams { // private String interval; // 5m, 30m, 1h, 1d // private String range; // 8h, 16h, 1d, 2d, 1w // private String rangeto; // private String topic; // private String group; // // public String getTopic() { // return topic; // } // // public void setTopic(String topic) { // this.topic = topic; // } // // public String getGroup() { // return group; // } // // public void setGroup(String group) { // this.group = group; // } // // public String getInterval() { // return interval; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getRange() { // return range; // } // // public void setRange(String range) { // this.range = range; // } // // public String getRangeto() { // return rangeto; // } // // public void setRangeto(String rangeto) { // this.rangeto = rangeto; // } // // @Override // public String toString() { // return "LagRequestParams [interval=" + interval + ", range=" + range + ", rangeTo=" + rangeto + ", topic=" // + topic + ", group=" + group + "]"; // } // } // // Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // } // Path: src/main/java/com/chickling/kmanager/utils/elasticsearch/Ielasticsearch.java import java.util.List; import org.json.JSONObject; import com.chickling.kmanager.model.OffsetHistoryQueryParams; import com.chickling.kmanager.model.OffsetPoints; package com.chickling.kmanager.utils.elasticsearch; /** * @author Hulva Luva.H * @since 2017-7-19 * */ public interface Ielasticsearch { void bulkIndex(JSONObject data, String docType, String indexPrefix);
List<OffsetPoints> offsetHistory(String indexPrefix, String docType, String group, String topic);
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/elasticsearch/Ielasticsearch.java
// Path: src/main/java/com/chickling/kmanager/model/OffsetHistoryQueryParams.java // public class OffsetHistoryQueryParams { // private String interval; // 5m, 30m, 1h, 1d // private String range; // 8h, 16h, 1d, 2d, 1w // private String rangeto; // private String topic; // private String group; // // public String getTopic() { // return topic; // } // // public void setTopic(String topic) { // this.topic = topic; // } // // public String getGroup() { // return group; // } // // public void setGroup(String group) { // this.group = group; // } // // public String getInterval() { // return interval; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getRange() { // return range; // } // // public void setRange(String range) { // this.range = range; // } // // public String getRangeto() { // return rangeto; // } // // public void setRangeto(String rangeto) { // this.rangeto = rangeto; // } // // @Override // public String toString() { // return "LagRequestParams [interval=" + interval + ", range=" + range + ", rangeTo=" + rangeto + ", topic=" // + topic + ", group=" + group + "]"; // } // } // // Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // }
import java.util.List; import org.json.JSONObject; import com.chickling.kmanager.model.OffsetHistoryQueryParams; import com.chickling.kmanager.model.OffsetPoints;
package com.chickling.kmanager.utils.elasticsearch; /** * @author Hulva Luva.H * @since 2017-7-19 * */ public interface Ielasticsearch { void bulkIndex(JSONObject data, String docType, String indexPrefix); List<OffsetPoints> offsetHistory(String indexPrefix, String docType, String group, String topic);
// Path: src/main/java/com/chickling/kmanager/model/OffsetHistoryQueryParams.java // public class OffsetHistoryQueryParams { // private String interval; // 5m, 30m, 1h, 1d // private String range; // 8h, 16h, 1d, 2d, 1w // private String rangeto; // private String topic; // private String group; // // public String getTopic() { // return topic; // } // // public void setTopic(String topic) { // this.topic = topic; // } // // public String getGroup() { // return group; // } // // public void setGroup(String group) { // this.group = group; // } // // public String getInterval() { // return interval; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getRange() { // return range; // } // // public void setRange(String range) { // this.range = range; // } // // public String getRangeto() { // return rangeto; // } // // public void setRangeto(String rangeto) { // this.rangeto = rangeto; // } // // @Override // public String toString() { // return "LagRequestParams [interval=" + interval + ", range=" + range + ", rangeTo=" + rangeto + ", topic=" // + topic + ", group=" + group + "]"; // } // } // // Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // } // Path: src/main/java/com/chickling/kmanager/utils/elasticsearch/Ielasticsearch.java import java.util.List; import org.json.JSONObject; import com.chickling.kmanager.model.OffsetHistoryQueryParams; import com.chickling.kmanager.model.OffsetPoints; package com.chickling.kmanager.utils.elasticsearch; /** * @author Hulva Luva.H * @since 2017-7-19 * */ public interface Ielasticsearch { void bulkIndex(JSONObject data, String docType, String indexPrefix); List<OffsetPoints> offsetHistory(String indexPrefix, String docType, String group, String topic);
List<OffsetPoints> scrollsSearcher(OffsetHistoryQueryParams params, String docType, String indexPrefix);
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/CommonUtils.java
// Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // }
import java.io.File; import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.OffsetPoints;
package com.chickling.kmanager.utils; /** * @author Hulva Luva.H * */ public class CommonUtils { private static Logger LOG = LoggerFactory.getLogger(CommonUtils.class);
// Path: src/main/java/com/chickling/kmanager/model/OffsetPoints.java // public class OffsetPoints { // private Long timestamp; // private Integer partition; // private String owner; // private Long offset; // private Long logSize; // // public OffsetPoints() { // super(); // } // // public OffsetPoints(Long timestamp, Integer partition, String owner, Long offset, Long logSize) { // super(); // this.timestamp = timestamp; // this.partition = partition; // this.owner = owner; // this.offset = offset; // this.logSize = logSize; // } // // public Long getTimestamp() { // return timestamp; // } // // public void setTimestamp(Long timestamp) { // this.timestamp = timestamp; // } // // public Integer getPartition() { // return partition; // } // // public void setPartition(Integer partition) { // this.partition = partition; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public Long getOffset() { // return offset; // } // // public void setOffset(Long offset) { // this.offset = offset; // } // // public Long getLogSize() { // return logSize; // } // // public void setLogSize(Long logSize) { // this.logSize = logSize; // } // // @Override // public String toString() { // return "OffsetPoints [timestamp=" + timestamp + ", partition=" + partition + ", owner=" + owner + ", offset=" + offset + ", logSize=" // + logSize + "]"; // } // // // } // Path: src/main/java/com/chickling/kmanager/utils/CommonUtils.java import java.io.File; import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Collections; import java.util.Comparator; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.OffsetPoints; package com.chickling.kmanager.utils; /** * @author Hulva Luva.H * */ public class CommonUtils { private static Logger LOG = LoggerFactory.getLogger(CommonUtils.class);
public static void sortByTimestampThenPartition(List<OffsetPoints> offsetPointsList) {
chickling/kmanager
src/main/java/com/chickling/kmanager/initialize/GenerateKafkaInfoTask.java
// Path: src/main/java/com/chickling/kmanager/model/KafkaInfo.java // public class KafkaInfo { // private String GroupName; // private List<BrokerInfo> brokers; // private List<OffsetInfo> offsets; // // public KafkaInfo() { // super(); // } // // public KafkaInfo(String name, List<BrokerInfo> brokers, List<OffsetInfo> offsets) { // super(); // this.GroupName = name; // this.brokers = brokers; // this.offsets = offsets; // } // // public String getName() { // return GroupName; // } // // public void setName(String name) { // this.GroupName = name; // } // // public List<BrokerInfo> getBrokers() { // return brokers; // } // // public void setBrokers(List<BrokerInfo> brokers) { // this.brokers = brokers; // } // // public List<OffsetInfo> getOffsets() { // return offsets; // } // // public void setOffsets(List<OffsetInfo> offsets) { // this.offsets = offsets; // } // // @Override // public String toString() { // return "KafkaInfo [GroupName=" + GroupName + ", brokers=" + brokers + ", offsets=" + offsets + "]"; // } // // }
import java.util.ArrayList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.KafkaInfo;
package com.chickling.kmanager.initialize; /** * @author Hulva Luva.H * @since 2017-07-13 * */ public class GenerateKafkaInfoTask implements Runnable { private static Logger LOG = LoggerFactory.getLogger(GenerateKafkaInfoTask.class); private String group; public GenerateKafkaInfoTask(String _group) { this.group = _group; } @Override public void run() {
// Path: src/main/java/com/chickling/kmanager/model/KafkaInfo.java // public class KafkaInfo { // private String GroupName; // private List<BrokerInfo> brokers; // private List<OffsetInfo> offsets; // // public KafkaInfo() { // super(); // } // // public KafkaInfo(String name, List<BrokerInfo> brokers, List<OffsetInfo> offsets) { // super(); // this.GroupName = name; // this.brokers = brokers; // this.offsets = offsets; // } // // public String getName() { // return GroupName; // } // // public void setName(String name) { // this.GroupName = name; // } // // public List<BrokerInfo> getBrokers() { // return brokers; // } // // public void setBrokers(List<BrokerInfo> brokers) { // this.brokers = brokers; // } // // public List<OffsetInfo> getOffsets() { // return offsets; // } // // public void setOffsets(List<OffsetInfo> offsets) { // this.offsets = offsets; // } // // @Override // public String toString() { // return "KafkaInfo [GroupName=" + GroupName + ", brokers=" + brokers + ", offsets=" + offsets + "]"; // } // // } // Path: src/main/java/com/chickling/kmanager/initialize/GenerateKafkaInfoTask.java import java.util.ArrayList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.KafkaInfo; package com.chickling.kmanager.initialize; /** * @author Hulva Luva.H * @since 2017-07-13 * */ public class GenerateKafkaInfoTask implements Runnable { private static Logger LOG = LoggerFactory.getLogger(GenerateKafkaInfoTask.class); private String group; public GenerateKafkaInfoTask(String _group) { this.group = _group; } @Override public void run() {
KafkaInfo kafkaInfo = null;
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/ZKUtils.java
// Path: src/main/java/com/chickling/kmanager/model/BrokerInfo.java // public class BrokerInfo { // private int bid; // private String host; // private int port; // private int jmxPort; // private long timestamp; // private int version; // // public BrokerInfo() { // // } // // public BrokerInfo(int bid, String host, int port) { // super(); // this.bid = bid; // this.host = host; // this.port = port; // } // // public int getBid() { // return bid; // } // // public void setBid(int bid) { // this.bid = bid; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // @Override // public String toString() { // return "BrokerInfo [bid=" + bid + ", host=" + host + ", port=" + port + "]"; // } // // public int getJmxPort() { // return jmxPort; // } // // public void setJmxPort(int jmx_port) { // this.jmxPort = jmx_port; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getVersion() { // return version; // } // // public void setVersion(int version) { // this.version = version; // } // // } // // Path: src/main/java/com/chickling/kmanager/model/ZkDataAndStat.java // public class ZkDataAndStat { // private String data; // private Stat stat; // // public ZkDataAndStat() { // super(); // } // // public ZkDataAndStat(String data, Stat stat) { // super(); // this.data = data; // this.stat = stat; // } // // public String getData() { // return data; // } // // public void setData(String data) { // this.data = data; // } // // public Stat getStat() { // return stat; // } // // public void setStat(Stat stat) { // this.stat = stat; // } // // @Override // public String toString() { // return "ZkDataAndState [data=" + data + ", stat=" + stat + "]"; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.zookeeper.data.Stat; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.BrokerInfo; import com.chickling.kmanager.model.ZkDataAndStat; import kafka.cluster.Broker; import kafka.common.TopicAndPartition; import kafka.utils.ZKStringSerializer; import kafka.utils.ZkUtils; import scala.Option; import scala.collection.JavaConversions;
public static Option<Broker> getBrokerInfo(int brokerId) { // Option[Broker] = zkUtilsFromKafka.getBrokerInfo(zkClient, brokerId) return zkUtilsFromKafka.getBrokerInfo(brokerId); } public static List<String> getConsumersInGroup(String group) { return JavaConversions.seqAsJavaList(zkUtilsFromKafka.getConsumersInGroup(group)); } public static List<String> parseTopicsData(String jsonData) { return JavaConversions.seqAsJavaList(ZkUtils.parseTopicsData(jsonData)); } public static boolean pathExists(String path) { return zkUtilsFromKafka.pathExists(path); } public static List<String> getChildren(String path) { List<String> children = null; try { children = zkClient.getChildren(path); } catch (Exception e) { // that should be // {org.apache.zookeeper.KeeperException$NoNodeException} children = new ArrayList<String>(); } return children; }
// Path: src/main/java/com/chickling/kmanager/model/BrokerInfo.java // public class BrokerInfo { // private int bid; // private String host; // private int port; // private int jmxPort; // private long timestamp; // private int version; // // public BrokerInfo() { // // } // // public BrokerInfo(int bid, String host, int port) { // super(); // this.bid = bid; // this.host = host; // this.port = port; // } // // public int getBid() { // return bid; // } // // public void setBid(int bid) { // this.bid = bid; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // @Override // public String toString() { // return "BrokerInfo [bid=" + bid + ", host=" + host + ", port=" + port + "]"; // } // // public int getJmxPort() { // return jmxPort; // } // // public void setJmxPort(int jmx_port) { // this.jmxPort = jmx_port; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getVersion() { // return version; // } // // public void setVersion(int version) { // this.version = version; // } // // } // // Path: src/main/java/com/chickling/kmanager/model/ZkDataAndStat.java // public class ZkDataAndStat { // private String data; // private Stat stat; // // public ZkDataAndStat() { // super(); // } // // public ZkDataAndStat(String data, Stat stat) { // super(); // this.data = data; // this.stat = stat; // } // // public String getData() { // return data; // } // // public void setData(String data) { // this.data = data; // } // // public Stat getStat() { // return stat; // } // // public void setStat(Stat stat) { // this.stat = stat; // } // // @Override // public String toString() { // return "ZkDataAndState [data=" + data + ", stat=" + stat + "]"; // } // // } // Path: src/main/java/com/chickling/kmanager/utils/ZKUtils.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.zookeeper.data.Stat; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.BrokerInfo; import com.chickling.kmanager.model.ZkDataAndStat; import kafka.cluster.Broker; import kafka.common.TopicAndPartition; import kafka.utils.ZKStringSerializer; import kafka.utils.ZkUtils; import scala.Option; import scala.collection.JavaConversions; public static Option<Broker> getBrokerInfo(int brokerId) { // Option[Broker] = zkUtilsFromKafka.getBrokerInfo(zkClient, brokerId) return zkUtilsFromKafka.getBrokerInfo(brokerId); } public static List<String> getConsumersInGroup(String group) { return JavaConversions.seqAsJavaList(zkUtilsFromKafka.getConsumersInGroup(group)); } public static List<String> parseTopicsData(String jsonData) { return JavaConversions.seqAsJavaList(ZkUtils.parseTopicsData(jsonData)); } public static boolean pathExists(String path) { return zkUtilsFromKafka.pathExists(path); } public static List<String> getChildren(String path) { List<String> children = null; try { children = zkClient.getChildren(path); } catch (Exception e) { // that should be // {org.apache.zookeeper.KeeperException$NoNodeException} children = new ArrayList<String>(); } return children; }
public static ZkDataAndStat readDataMaybeNull(String path) {
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/ZKUtils.java
// Path: src/main/java/com/chickling/kmanager/model/BrokerInfo.java // public class BrokerInfo { // private int bid; // private String host; // private int port; // private int jmxPort; // private long timestamp; // private int version; // // public BrokerInfo() { // // } // // public BrokerInfo(int bid, String host, int port) { // super(); // this.bid = bid; // this.host = host; // this.port = port; // } // // public int getBid() { // return bid; // } // // public void setBid(int bid) { // this.bid = bid; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // @Override // public String toString() { // return "BrokerInfo [bid=" + bid + ", host=" + host + ", port=" + port + "]"; // } // // public int getJmxPort() { // return jmxPort; // } // // public void setJmxPort(int jmx_port) { // this.jmxPort = jmx_port; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getVersion() { // return version; // } // // public void setVersion(int version) { // this.version = version; // } // // } // // Path: src/main/java/com/chickling/kmanager/model/ZkDataAndStat.java // public class ZkDataAndStat { // private String data; // private Stat stat; // // public ZkDataAndStat() { // super(); // } // // public ZkDataAndStat(String data, Stat stat) { // super(); // this.data = data; // this.stat = stat; // } // // public String getData() { // return data; // } // // public void setData(String data) { // this.data = data; // } // // public Stat getStat() { // return stat; // } // // public void setStat(Stat stat) { // this.stat = stat; // } // // @Override // public String toString() { // return "ZkDataAndState [data=" + data + ", stat=" + stat + "]"; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.zookeeper.data.Stat; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.BrokerInfo; import com.chickling.kmanager.model.ZkDataAndStat; import kafka.cluster.Broker; import kafka.common.TopicAndPartition; import kafka.utils.ZKStringSerializer; import kafka.utils.ZkUtils; import scala.Option; import scala.collection.JavaConversions;
public static List<String> parseTopicsData(String jsonData) { return JavaConversions.seqAsJavaList(ZkUtils.parseTopicsData(jsonData)); } public static boolean pathExists(String path) { return zkUtilsFromKafka.pathExists(path); } public static List<String> getChildren(String path) { List<String> children = null; try { children = zkClient.getChildren(path); } catch (Exception e) { // that should be // {org.apache.zookeeper.KeeperException$NoNodeException} children = new ArrayList<String>(); } return children; } public static ZkDataAndStat readDataMaybeNull(String path) { Stat stat = new Stat(); String data = null; try { data = zkClient.readData(path, stat); } catch (Exception e) { LOG.warn("Path: " + path + " do not exits in ZK!" + e.getMessage()); } return new ZkDataAndStat(data, stat); }
// Path: src/main/java/com/chickling/kmanager/model/BrokerInfo.java // public class BrokerInfo { // private int bid; // private String host; // private int port; // private int jmxPort; // private long timestamp; // private int version; // // public BrokerInfo() { // // } // // public BrokerInfo(int bid, String host, int port) { // super(); // this.bid = bid; // this.host = host; // this.port = port; // } // // public int getBid() { // return bid; // } // // public void setBid(int bid) { // this.bid = bid; // } // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public int getPort() { // return port; // } // // public void setPort(int port) { // this.port = port; // } // // @Override // public String toString() { // return "BrokerInfo [bid=" + bid + ", host=" + host + ", port=" + port + "]"; // } // // public int getJmxPort() { // return jmxPort; // } // // public void setJmxPort(int jmx_port) { // this.jmxPort = jmx_port; // } // // public long getTimestamp() { // return timestamp; // } // // public void setTimestamp(long timestamp) { // this.timestamp = timestamp; // } // // public int getVersion() { // return version; // } // // public void setVersion(int version) { // this.version = version; // } // // } // // Path: src/main/java/com/chickling/kmanager/model/ZkDataAndStat.java // public class ZkDataAndStat { // private String data; // private Stat stat; // // public ZkDataAndStat() { // super(); // } // // public ZkDataAndStat(String data, Stat stat) { // super(); // this.data = data; // this.stat = stat; // } // // public String getData() { // return data; // } // // public void setData(String data) { // this.data = data; // } // // public Stat getStat() { // return stat; // } // // public void setStat(Stat stat) { // this.stat = stat; // } // // @Override // public String toString() { // return "ZkDataAndState [data=" + data + ", stat=" + stat + "]"; // } // // } // Path: src/main/java/com/chickling/kmanager/utils/ZKUtils.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.I0Itec.zkclient.exception.ZkMarshallingError; import org.I0Itec.zkclient.serialize.ZkSerializer; import org.apache.zookeeper.data.Stat; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.chickling.kmanager.model.BrokerInfo; import com.chickling.kmanager.model.ZkDataAndStat; import kafka.cluster.Broker; import kafka.common.TopicAndPartition; import kafka.utils.ZKStringSerializer; import kafka.utils.ZkUtils; import scala.Option; import scala.collection.JavaConversions; public static List<String> parseTopicsData(String jsonData) { return JavaConversions.seqAsJavaList(ZkUtils.parseTopicsData(jsonData)); } public static boolean pathExists(String path) { return zkUtilsFromKafka.pathExists(path); } public static List<String> getChildren(String path) { List<String> children = null; try { children = zkClient.getChildren(path); } catch (Exception e) { // that should be // {org.apache.zookeeper.KeeperException$NoNodeException} children = new ArrayList<String>(); } return children; } public static ZkDataAndStat readDataMaybeNull(String path) { Stat stat = new Stat(); String data = null; try { data = zkClient.readData(path, stat); } catch (Exception e) { LOG.warn("Path: " + path + " do not exits in ZK!" + e.getMessage()); } return new ZkDataAndStat(data, stat); }
public static List<BrokerInfo> getBrokers() throws Exception {
chickling/kmanager
src/main/java/com/chickling/kmanager/jmx/FormatedMeterMetric.java
// Path: src/main/java/com/chickling/kmanager/utils/MetricUtils.java // public class MetricUtils { // private static char[] UNIT = { 'k', 'm', 'b' }; // // public static String rateFormat(Double rate, int interation) { // if (rate < 100) { // return new BigDecimal(rate).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); // } else { // double value = (rate.longValue() / 100) / 10.0; // boolean isRound = (value * 10) % 10 == 0; // if (value < 1000) { // if (value > 99.9 || isRound || (!isRound && value > 9.99)) { // return new Double(value).intValue() * 10 / 10 + "" + UNIT[interation]; // } else { // return value + "" + UNIT[interation]; // } // } else { // return rateFormat(value, interation + 1); // } // } // } // // public static String sizeFormat(Double bytes) { // int unit = 1024; // if (bytes < unit) { // return new BigDecimal(bytes).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + " B"; // } else { // int exp = new Double((Math.log(bytes) / Math.log(unit))).intValue(); // char pre = "KMGTPE".charAt(exp - 1); // return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); // } // } // }
import com.chickling.kmanager.utils.MetricUtils;
package com.chickling.kmanager.jmx; /** * @author Hulva Luva.H from ECBD * @date 2017年7月20日 * @description * */ public class FormatedMeterMetric { private Long count; private String meanRate; private String oneMinuteRate; private String fiveMinuteRate; private String fifteenMinuteRate; public FormatedMeterMetric() { super(); } public FormatedMeterMetric(MeterMetric metric) {
// Path: src/main/java/com/chickling/kmanager/utils/MetricUtils.java // public class MetricUtils { // private static char[] UNIT = { 'k', 'm', 'b' }; // // public static String rateFormat(Double rate, int interation) { // if (rate < 100) { // return new BigDecimal(rate).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); // } else { // double value = (rate.longValue() / 100) / 10.0; // boolean isRound = (value * 10) % 10 == 0; // if (value < 1000) { // if (value > 99.9 || isRound || (!isRound && value > 9.99)) { // return new Double(value).intValue() * 10 / 10 + "" + UNIT[interation]; // } else { // return value + "" + UNIT[interation]; // } // } else { // return rateFormat(value, interation + 1); // } // } // } // // public static String sizeFormat(Double bytes) { // int unit = 1024; // if (bytes < unit) { // return new BigDecimal(bytes).setScale(2, BigDecimal.ROUND_HALF_UP).toString() + " B"; // } else { // int exp = new Double((Math.log(bytes) / Math.log(unit))).intValue(); // char pre = "KMGTPE".charAt(exp - 1); // return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); // } // } // } // Path: src/main/java/com/chickling/kmanager/jmx/FormatedMeterMetric.java import com.chickling.kmanager.utils.MetricUtils; package com.chickling.kmanager.jmx; /** * @author Hulva Luva.H from ECBD * @date 2017年7月20日 * @description * */ public class FormatedMeterMetric { private Long count; private String meanRate; private String oneMinuteRate; private String fiveMinuteRate; private String fifteenMinuteRate; public FormatedMeterMetric() { super(); } public FormatedMeterMetric(MeterMetric metric) {
this(metric.getCount(), MetricUtils.sizeFormat(metric.getMeanRate()), MetricUtils.sizeFormat(metric.getOneMinuteRate()),
chickling/kmanager
src/main/java/com/chickling/kmanager/utils/elasticsearch/restapi/ScrollSearchTemplate.java
// Path: src/main/java/com/chickling/kmanager/model/ElasticsearchAssistEntity.java // public class ElasticsearchAssistEntity { // private String interval; // private List<String> indexs; // private Date start; // private Date end; // // public ElasticsearchAssistEntity() { // super(); // } // // public ElasticsearchAssistEntity(String interval, List<String> indexs, Date start, Date end) { // super(); // this.interval = interval; // this.indexs = indexs; // this.start = start; // this.end = end; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getInterval() { // return this.interval; // } // // public void setIndexs(List<String> indexs) { // this.indexs = indexs; // } // // public List<String> getIndexs() { // return this.indexs; // } // // public void setStart(Date start){ // this.start = start; // } // // public Date getStart(){ // return this.start; // } // public void setEnd(Date end){ // this.end = end; // } // // public Date getEnd(){ // return this.end; // } // }
import java.util.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.time.Instant; import java.time.LocalDate; import com.chickling.kmanager.model.ElasticsearchAssistEntity;
} public static String getScrollNextBody(String scrollId) { return "{\"scroll\":\"1m\",\"scroll_id\":\"" + scrollId + "\"}"; } public static String getInterval(int diff) { if (diff / 5 < 100) { return "5m"; } if (diff / 10 < 100) { return "10m"; } if (diff / 30 < 100) { return "30m"; } if (diff / 60 < 100) { return "1h"; } if (diff / (4 * 60) < 100) { return "4h"; } if (diff / (8 * 60) < 100) { return "8h"; } if (diff / (16 * 60) < 100) { return "16h"; } return "1d"; }
// Path: src/main/java/com/chickling/kmanager/model/ElasticsearchAssistEntity.java // public class ElasticsearchAssistEntity { // private String interval; // private List<String> indexs; // private Date start; // private Date end; // // public ElasticsearchAssistEntity() { // super(); // } // // public ElasticsearchAssistEntity(String interval, List<String> indexs, Date start, Date end) { // super(); // this.interval = interval; // this.indexs = indexs; // this.start = start; // this.end = end; // } // // public void setInterval(String interval) { // this.interval = interval; // } // // public String getInterval() { // return this.interval; // } // // public void setIndexs(List<String> indexs) { // this.indexs = indexs; // } // // public List<String> getIndexs() { // return this.indexs; // } // // public void setStart(Date start){ // this.start = start; // } // // public Date getStart(){ // return this.start; // } // public void setEnd(Date end){ // this.end = end; // } // // public Date getEnd(){ // return this.end; // } // } // Path: src/main/java/com/chickling/kmanager/utils/elasticsearch/restapi/ScrollSearchTemplate.java import java.util.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.time.Instant; import java.time.LocalDate; import com.chickling.kmanager.model.ElasticsearchAssistEntity; } public static String getScrollNextBody(String scrollId) { return "{\"scroll\":\"1m\",\"scroll_id\":\"" + scrollId + "\"}"; } public static String getInterval(int diff) { if (diff / 5 < 100) { return "5m"; } if (diff / 10 < 100) { return "10m"; } if (diff / 30 < 100) { return "30m"; } if (diff / 60 < 100) { return "1h"; } if (diff / (4 * 60) < 100) { return "4h"; } if (diff / (8 * 60) < 100) { return "8h"; } if (diff / (16 * 60) < 100) { return "16h"; } return "1d"; }
public static ElasticsearchAssistEntity getInterval(String start, String end) {
chickling/kmanager
src/test/java/com/chickling/kmanager/test/CollectionTest.java
// Path: src/main/java/com/chickling/kmanager/jmx/ObjectNameHolder.java // public class ObjectNameHolder { // private String metric; // private String type; // private String name; // /** // * <code> // * kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=test -> extra<"topic=test", JSONObject.NULL> // * kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=test,partition=p1 -> extra<"topic=test", <"partition=p1", JSONObject.NULL>> // * </code> // */ // private Map<String, Object> extra; // // public ObjectNameHolder() { // super(); // } // // public ObjectNameHolder(String metric, String type, String name, Map<String, Object> extra) { // super(); // this.metric = metric; // this.type = type; // this.name = name; // this.extra = extra; // } // // public String getMetric() { // return metric; // } // // public void setMetric(String metric) { // this.metric = metric; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Map<String, Object> getExtra() { // return extra; // } // // public void setExtra(Map<String, Object> extra) { // this.extra = extra; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((metric == null) ? 0 : metric.hashCode()); // result = prime * result + ((name == null) ? 0 : name.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // ObjectNameHolder other = (ObjectNameHolder) obj; // if (metric == null) { // if (other.metric != null) // return false; // } else if (!metric.equals(other.metric)) // return false; // if (name == null) { // if (other.name != null) // return false; // } else if (!name.equals(other.name)) // return false; // if (type == null) { // if (other.type != null) // return false; // } else if (!type.equals(other.type)) // return false; // return true; // } // // }
import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import com.chickling.kmanager.jmx.ObjectNameHolder;
package com.chickling.kmanager.test; /** * @author Hulva Luva.H from ECBD * @date 2017年7月22日 * @description * */ public class CollectionTest { /** * @param args */ public static void main(String[] args) {
// Path: src/main/java/com/chickling/kmanager/jmx/ObjectNameHolder.java // public class ObjectNameHolder { // private String metric; // private String type; // private String name; // /** // * <code> // * kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=test -> extra<"topic=test", JSONObject.NULL> // * kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=test,partition=p1 -> extra<"topic=test", <"partition=p1", JSONObject.NULL>> // * </code> // */ // private Map<String, Object> extra; // // public ObjectNameHolder() { // super(); // } // // public ObjectNameHolder(String metric, String type, String name, Map<String, Object> extra) { // super(); // this.metric = metric; // this.type = type; // this.name = name; // this.extra = extra; // } // // public String getMetric() { // return metric; // } // // public void setMetric(String metric) { // this.metric = metric; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Map<String, Object> getExtra() { // return extra; // } // // public void setExtra(Map<String, Object> extra) { // this.extra = extra; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((metric == null) ? 0 : metric.hashCode()); // result = prime * result + ((name == null) ? 0 : name.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // ObjectNameHolder other = (ObjectNameHolder) obj; // if (metric == null) { // if (other.metric != null) // return false; // } else if (!metric.equals(other.metric)) // return false; // if (name == null) { // if (other.name != null) // return false; // } else if (!name.equals(other.name)) // return false; // if (type == null) { // if (other.type != null) // return false; // } else if (!type.equals(other.type)) // return false; // return true; // } // // } // Path: src/test/java/com/chickling/kmanager/test/CollectionTest.java import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import com.chickling.kmanager.jmx.ObjectNameHolder; package com.chickling.kmanager.test; /** * @author Hulva Luva.H from ECBD * @date 2017年7月22日 * @description * */ public class CollectionTest { /** * @param args */ public static void main(String[] args) {
Set<ObjectNameHolder> objectNames = new HashSet<ObjectNameHolder>();
crescentflare/UniLayout
UniLayoutAndroid/UniLayoutLib/src/main/java/com/crescentflare/unilayout/views/UniWebView.java
// Path: UniLayoutAndroid/UniLayoutLib/src/main/java/com/crescentflare/unilayout/helpers/UniScrollListener.java // public interface UniScrollListener // { // void onScrollChanged(int x, int y, int oldX, int oldY); // }
import android.content.Context; import android.util.AttributeSet; import android.webkit.WebView; import android.widget.Button; import com.crescentflare.unilayout.helpers.UniScrollListener;
package com.crescentflare.unilayout.views; /** * UniLayout view: a web view * Extends WebView to enable listening for scroll events */ public class UniWebView extends WebView { // --- // Members // ---
// Path: UniLayoutAndroid/UniLayoutLib/src/main/java/com/crescentflare/unilayout/helpers/UniScrollListener.java // public interface UniScrollListener // { // void onScrollChanged(int x, int y, int oldX, int oldY); // } // Path: UniLayoutAndroid/UniLayoutLib/src/main/java/com/crescentflare/unilayout/views/UniWebView.java import android.content.Context; import android.util.AttributeSet; import android.webkit.WebView; import android.widget.Button; import com.crescentflare.unilayout.helpers.UniScrollListener; package com.crescentflare.unilayout.views; /** * UniLayout view: a web view * Extends WebView to enable listening for scroll events */ public class UniWebView extends WebView { // --- // Members // ---
private UniScrollListener scrollListener;
crescentflare/UniLayout
UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/MainActivity.java
// Path: UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/nestedlayouts/NestedLayoutsActivity.java // public class NestedLayoutsActivity extends AppCompatActivity // { // // --- // // Initialization // // --- // // @Override // protected void onCreate(Bundle savedInstanceState) // { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_nested_layouts); // setTitle(getString(R.string.example_nested_layouts)); // // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) // { // actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setHomeButtonEnabled(true); // } // } // // // // --- // // Menu handling // // --- // // @Override // public boolean onOptionsItemSelected(MenuItem item) // { // if (item.getItemId() == android.R.id.home) // { // onBackPressed(); // return true; // } // return super.onOptionsItemSelected(item); // } // } // // Path: UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/reusingcontainer/ReusingContainerActivity.java // public class ReusingContainerActivity extends AppCompatActivity // { // // --- // // Members // // --- // // private ReusingContainerAdapter adapter = new ReusingContainerAdapter(); // // // // --- // // Initialization // // --- // // @Override // protected void onCreate(Bundle savedInstanceState) // { // // Configure title // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_reusing_container); // setTitle(getString(R.string.example_reusing_container)); // // // Set up action bar // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) // { // actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setHomeButtonEnabled(true); // } // // // Initialize reusing container // UniReusingContainer reusingView = (UniReusingContainer)findViewById(R.id.activity_reusing_container_view); // reusingView.setAdapter(adapter); // // // Add all items // adapter.addItem(new ReusableItem(ReusableItem.Type.Section, "Supported containers")); // adapter.addItem(new ReusableItem(ReusableItem.Type.TopDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Horizontal scroll container", "Contains a single content view which can scroll horizontally, use linear container as a content view for scrollable layouts", "Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Vertical scroll container", "Contains a single content view which can scroll vertically, use linear container as a content view for scrollable layouts", "Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Linear container", "Aligns items horizontally or vertically, depending on its orientation", "Layout")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Frame container", "A simple container to contain one view, or add multiple overlapping views", "Layout")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Reusing container", "A vertical layout container with scrolling with reusable views, also supports selection and swiping", "Layout/Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.BottomDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Section, "Supported views")); // adapter.addItem(new ReusableItem(ReusableItem.Type.TopDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Button view", "Extends Button, currently only used to match the naming convention with iOS", "Button")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Image view", "Extends ImageView, currently only used to match the naming convention with iOS", "Image")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Text view", "Extends TextView, currently only used to match the naming convention with iOS", "Text")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Switch view", "Extends SwitchCompat, currently only used to match the naming convention with iOS", "Control")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Spinner view", "Extends ProgressBar, currently only used to match the naming convention with iOS", "Indicator")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Web view", "Extends WebView, currently only used to match the naming convention with iOS", "Web content")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "View", "Extends View to support padding for size calculation", "Container")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Reusable view", "A view to be used by the reusing container which can be reused while scrolling", "Container")); // adapter.addItem(new ReusableItem(ReusableItem.Type.BottomDivider)); // // // Disable interaction // for (int i = 0; i < adapter.getItemCount(); i++) // { // adapter.setItemEnabled(i, false); // } // } // // // // --- // // Menu handling // // --- // // @Override // public boolean onOptionsItemSelected(MenuItem item) // { // if (item.getItemId() == android.R.id.home) // { // onBackPressed(); // return true; // } // return super.onOptionsItemSelected(item); // } // }
import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import com.crescentflare.unilayoutexample.nestedlayouts.NestedLayoutsActivity; import com.crescentflare.unilayoutexample.reusingcontainer.ReusingContainerActivity;
public void onClick(View v) { showNestedLayouts(); } }); // Button to open reusing container example findViewById(R.id.activity_main_reusingcontainer).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showReusingContainer(); } }); } // --- // Interaction // --- private void showNestedLayouts() { Intent intent = new Intent(this, NestedLayoutsActivity.class); startActivity(intent); } private void showReusingContainer() {
// Path: UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/nestedlayouts/NestedLayoutsActivity.java // public class NestedLayoutsActivity extends AppCompatActivity // { // // --- // // Initialization // // --- // // @Override // protected void onCreate(Bundle savedInstanceState) // { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_nested_layouts); // setTitle(getString(R.string.example_nested_layouts)); // // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) // { // actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setHomeButtonEnabled(true); // } // } // // // // --- // // Menu handling // // --- // // @Override // public boolean onOptionsItemSelected(MenuItem item) // { // if (item.getItemId() == android.R.id.home) // { // onBackPressed(); // return true; // } // return super.onOptionsItemSelected(item); // } // } // // Path: UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/reusingcontainer/ReusingContainerActivity.java // public class ReusingContainerActivity extends AppCompatActivity // { // // --- // // Members // // --- // // private ReusingContainerAdapter adapter = new ReusingContainerAdapter(); // // // // --- // // Initialization // // --- // // @Override // protected void onCreate(Bundle savedInstanceState) // { // // Configure title // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_reusing_container); // setTitle(getString(R.string.example_reusing_container)); // // // Set up action bar // ActionBar actionBar = getSupportActionBar(); // if (actionBar != null) // { // actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setHomeButtonEnabled(true); // } // // // Initialize reusing container // UniReusingContainer reusingView = (UniReusingContainer)findViewById(R.id.activity_reusing_container_view); // reusingView.setAdapter(adapter); // // // Add all items // adapter.addItem(new ReusableItem(ReusableItem.Type.Section, "Supported containers")); // adapter.addItem(new ReusableItem(ReusableItem.Type.TopDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Horizontal scroll container", "Contains a single content view which can scroll horizontally, use linear container as a content view for scrollable layouts", "Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Vertical scroll container", "Contains a single content view which can scroll vertically, use linear container as a content view for scrollable layouts", "Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Linear container", "Aligns items horizontally or vertically, depending on its orientation", "Layout")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Frame container", "A simple container to contain one view, or add multiple overlapping views", "Layout")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Reusing container", "A vertical layout container with scrolling with reusable views, also supports selection and swiping", "Layout/Scroll")); // adapter.addItem(new ReusableItem(ReusableItem.Type.BottomDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Section, "Supported views")); // adapter.addItem(new ReusableItem(ReusableItem.Type.TopDivider)); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Button view", "Extends Button, currently only used to match the naming convention with iOS", "Button")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Image view", "Extends ImageView, currently only used to match the naming convention with iOS", "Image")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Text view", "Extends TextView, currently only used to match the naming convention with iOS", "Text")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Switch view", "Extends SwitchCompat, currently only used to match the naming convention with iOS", "Control")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Spinner view", "Extends ProgressBar, currently only used to match the naming convention with iOS", "Indicator")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Web view", "Extends WebView, currently only used to match the naming convention with iOS", "Web content")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "View", "Extends View to support padding for size calculation", "Container")); // adapter.addItem(new ReusableItem(ReusableItem.Type.Item, "Reusable view", "A view to be used by the reusing container which can be reused while scrolling", "Container")); // adapter.addItem(new ReusableItem(ReusableItem.Type.BottomDivider)); // // // Disable interaction // for (int i = 0; i < adapter.getItemCount(); i++) // { // adapter.setItemEnabled(i, false); // } // } // // // // --- // // Menu handling // // --- // // @Override // public boolean onOptionsItemSelected(MenuItem item) // { // if (item.getItemId() == android.R.id.home) // { // onBackPressed(); // return true; // } // return super.onOptionsItemSelected(item); // } // } // Path: UniLayoutAndroid/UniLayoutExample/src/main/java/com/crescentflare/unilayoutexample/MainActivity.java import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import com.crescentflare.unilayoutexample.nestedlayouts.NestedLayoutsActivity; import com.crescentflare.unilayoutexample.reusingcontainer.ReusingContainerActivity; public void onClick(View v) { showNestedLayouts(); } }); // Button to open reusing container example findViewById(R.id.activity_main_reusingcontainer).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showReusingContainer(); } }); } // --- // Interaction // --- private void showNestedLayouts() { Intent intent = new Intent(this, NestedLayoutsActivity.class); startActivity(intent); } private void showReusingContainer() {
Intent intent = new Intent(this, ReusingContainerActivity.class);
alanhay/html-exporter
src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableWriter.java
// Path: src/main/java/uk/co/certait/htmlexporter/css/StyleMap.java // public class StyleMap { // private static final String CLASS_PREFIX = "."; // // Map<String, Style> styles; // private StyleGenerator generator; // // public StyleMap(Map<String, Style> styles) { // this.styles = styles != null ? styles : new HashMap<String, Style>(); // generator = new StyleGenerator(); // } // // public Style getStyleForElement(Element element) { // Style style = new Style(); // // if (getStyleForTag(element) != null) { // style = StyleMerger.mergeStyles(style, getStyleForTag(element)); // } // // if (!getStylesForClass(element).isEmpty()) { // List<Style> classStyles = getStylesForClass(element); // // for (Style classStyle : classStyles) { // style = StyleMerger.mergeStyles(style, classStyle); // } // } // // if (getInlineStyle(element) != null) { // style = StyleMerger.mergeStyles(style, getInlineStyle(element)); // } // // return style; // } // // private Style getStyleForTag(Element element) { // return styles.get(element.tagName()); // } // // private List<Style> getStylesForClass(Element element) { // List<Style> classStyles = new ArrayList<Style>(); // // if (StringUtils.isNotEmpty(element.className())) { // String[] classNames = element.className().split(" "); // // for (String className : classNames) { // String qualifiedClassName = CLASS_PREFIX + className.trim(); // // if (styles.containsKey(qualifiedClassName)) { // classStyles.add(styles.get(qualifiedClassName)); // } // } // } // // return classStyles; // } // // private Style getInlineStyle(Element element) { // Style style = null; // // if (element.hasAttr("style")) { // List<Rule> inlineRules; // try { // String inlineStyle = element.attr("style").endsWith(";") ? element.attr("style") : element // .attr("style") + ";"; // inlineRules = CSSParser.parse("x{" + inlineStyle + "}"); // } catch (Exception e) { // throw new RuntimeException("Error parsing inline style for element " + element.tagName()); // } // // style = generator.createStyle(inlineRules.get(0), inlineRules.get(0).getSelectors().get(0)); // } // // return style; // } // }
import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.css.StyleMap;
/** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer; public abstract class AbstractTableWriter implements TableWriter { private TableRowWriter rowWriter; public AbstractTableWriter(TableRowWriter rowWriter) { this.rowWriter = rowWriter; }
// Path: src/main/java/uk/co/certait/htmlexporter/css/StyleMap.java // public class StyleMap { // private static final String CLASS_PREFIX = "."; // // Map<String, Style> styles; // private StyleGenerator generator; // // public StyleMap(Map<String, Style> styles) { // this.styles = styles != null ? styles : new HashMap<String, Style>(); // generator = new StyleGenerator(); // } // // public Style getStyleForElement(Element element) { // Style style = new Style(); // // if (getStyleForTag(element) != null) { // style = StyleMerger.mergeStyles(style, getStyleForTag(element)); // } // // if (!getStylesForClass(element).isEmpty()) { // List<Style> classStyles = getStylesForClass(element); // // for (Style classStyle : classStyles) { // style = StyleMerger.mergeStyles(style, classStyle); // } // } // // if (getInlineStyle(element) != null) { // style = StyleMerger.mergeStyles(style, getInlineStyle(element)); // } // // return style; // } // // private Style getStyleForTag(Element element) { // return styles.get(element.tagName()); // } // // private List<Style> getStylesForClass(Element element) { // List<Style> classStyles = new ArrayList<Style>(); // // if (StringUtils.isNotEmpty(element.className())) { // String[] classNames = element.className().split(" "); // // for (String className : classNames) { // String qualifiedClassName = CLASS_PREFIX + className.trim(); // // if (styles.containsKey(qualifiedClassName)) { // classStyles.add(styles.get(qualifiedClassName)); // } // } // } // // return classStyles; // } // // private Style getInlineStyle(Element element) { // Style style = null; // // if (element.hasAttr("style")) { // List<Rule> inlineRules; // try { // String inlineStyle = element.attr("style").endsWith(";") ? element.attr("style") : element // .attr("style") + ";"; // inlineRules = CSSParser.parse("x{" + inlineStyle + "}"); // } catch (Exception e) { // throw new RuntimeException("Error parsing inline style for element " + element.tagName()); // } // // style = generator.createStyle(inlineRules.get(0), inlineRules.get(0).getSelectors().get(0)); // } // // return style; // } // } // Path: src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableWriter.java import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.css.StyleMap; /** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer; public abstract class AbstractTableWriter implements TableWriter { private TableRowWriter rowWriter; public AbstractTableWriter(TableRowWriter rowWriter) { this.rowWriter = rowWriter; }
public int writeTable(Element table, StyleMap styleMapper, int startRow) {
alanhay/html-exporter
src/main/java/uk/co/certait/htmlexporter/writer/ods/OdsTableRowWriter.java
// Path: src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableRowWriter.java // public abstract class AbstractTableRowWriter implements TableRowWriter { // private TableCellWriter cellWriter; // private RowTracker rowTracker; // // public AbstractTableRowWriter(TableCellWriter cellWriter) { // this.cellWriter = cellWriter; // rowTracker = new RowTracker(); // } // // public void writeRow(Element row, int rowIndex) { // renderRow(row, rowIndex); // // for (Element element : row.getAllElements()) { // if (element.tag().getName().equals(TD_TAG) || element.tag().getName().equals(TH_TAG)) { // int columnIndex = rowTracker.getNextColumnIndexForRow(rowIndex); // cellWriter.writeCell(element, rowIndex, columnIndex); // // int rowSpan = getRowSpan(element); // int columnSpan = getColumnSpan(element); // // rowTracker.addCell(rowIndex, columnIndex, rowSpan, columnSpan); // // if (rowSpan > 1 || columnSpan > 1) { // doMerge(rowIndex, columnIndex, rowSpan, columnSpan); // } // } // } // } // // protected boolean isRowGrouped(Element row) { // return row.hasAttr(""); // } // // protected String[] getRowGroups(Element row) { // return getAttributeValues(row, ""); // } // // protected String[] getAttributeValues(Element element, String attributeName) { // String values[] = null; // // if (element.hasAttr(attributeName)) { // values = element.attr(attributeName).toLowerCase().split(","); // // for (String value : values) { // value = value.trim().toLowerCase(); // } // } // // return values; // } // // protected int getColumnSpan(Element element) { // int columnSpan = 1; // // if (element.hasAttr("colspan")) { // columnSpan = Integer.parseInt(element.attr("colspan")); // } // // return columnSpan; // } // // protected int getRowSpan(Element element) { // int rowSpan = 1; // // if (element.hasAttr("rowSpan")) { // rowSpan = Integer.parseInt(element.attr("rowSpan")); // } // // return rowSpan; // } // // public abstract void renderRow(Element row, int rowIndex); // // public abstract void doMerge(int rowIndex, int columnIndex, int rowSpan, int columnSpan); // } // // Path: src/main/java/uk/co/certait/htmlexporter/writer/TableCellWriter.java // public interface TableCellWriter { // public static final String COLUMN_SPAN_ATTRIBUTE = "colspan"; // public static final String DATA_GROUP_ATTRIBUTE = "data-group"; // public static final String DATA_GROUP_OUTPUT_ATTRIBUTE = "data-group-output"; // public static final String DATE_CELL_ATTRIBUTE = "data-date-cell-format"; // public static final String DATA_CELL_COMMENT_ATTRIBUTE = "data-cell-comment"; // public static final String DATA_CELL_COMMENT_DIMENSION_ATTRIBUTE = "data-cell-comment-dimension"; // public static final String DATA_TEXT_CELL = "data-text-cell"; // public static final String DATA_FREEZE_PANE_CELL = "data-freeze-pane-cell"; // // public void writeCell(Element cell, int row, int column); // }
import org.jsoup.nodes.Element; import org.odftoolkit.simple.table.Table; import uk.co.certait.htmlexporter.writer.AbstractTableRowWriter; import uk.co.certait.htmlexporter.writer.TableCellWriter;
/** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer.ods; public class OdsTableRowWriter extends AbstractTableRowWriter { private Table table;
// Path: src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableRowWriter.java // public abstract class AbstractTableRowWriter implements TableRowWriter { // private TableCellWriter cellWriter; // private RowTracker rowTracker; // // public AbstractTableRowWriter(TableCellWriter cellWriter) { // this.cellWriter = cellWriter; // rowTracker = new RowTracker(); // } // // public void writeRow(Element row, int rowIndex) { // renderRow(row, rowIndex); // // for (Element element : row.getAllElements()) { // if (element.tag().getName().equals(TD_TAG) || element.tag().getName().equals(TH_TAG)) { // int columnIndex = rowTracker.getNextColumnIndexForRow(rowIndex); // cellWriter.writeCell(element, rowIndex, columnIndex); // // int rowSpan = getRowSpan(element); // int columnSpan = getColumnSpan(element); // // rowTracker.addCell(rowIndex, columnIndex, rowSpan, columnSpan); // // if (rowSpan > 1 || columnSpan > 1) { // doMerge(rowIndex, columnIndex, rowSpan, columnSpan); // } // } // } // } // // protected boolean isRowGrouped(Element row) { // return row.hasAttr(""); // } // // protected String[] getRowGroups(Element row) { // return getAttributeValues(row, ""); // } // // protected String[] getAttributeValues(Element element, String attributeName) { // String values[] = null; // // if (element.hasAttr(attributeName)) { // values = element.attr(attributeName).toLowerCase().split(","); // // for (String value : values) { // value = value.trim().toLowerCase(); // } // } // // return values; // } // // protected int getColumnSpan(Element element) { // int columnSpan = 1; // // if (element.hasAttr("colspan")) { // columnSpan = Integer.parseInt(element.attr("colspan")); // } // // return columnSpan; // } // // protected int getRowSpan(Element element) { // int rowSpan = 1; // // if (element.hasAttr("rowSpan")) { // rowSpan = Integer.parseInt(element.attr("rowSpan")); // } // // return rowSpan; // } // // public abstract void renderRow(Element row, int rowIndex); // // public abstract void doMerge(int rowIndex, int columnIndex, int rowSpan, int columnSpan); // } // // Path: src/main/java/uk/co/certait/htmlexporter/writer/TableCellWriter.java // public interface TableCellWriter { // public static final String COLUMN_SPAN_ATTRIBUTE = "colspan"; // public static final String DATA_GROUP_ATTRIBUTE = "data-group"; // public static final String DATA_GROUP_OUTPUT_ATTRIBUTE = "data-group-output"; // public static final String DATE_CELL_ATTRIBUTE = "data-date-cell-format"; // public static final String DATA_CELL_COMMENT_ATTRIBUTE = "data-cell-comment"; // public static final String DATA_CELL_COMMENT_DIMENSION_ATTRIBUTE = "data-cell-comment-dimension"; // public static final String DATA_TEXT_CELL = "data-text-cell"; // public static final String DATA_FREEZE_PANE_CELL = "data-freeze-pane-cell"; // // public void writeCell(Element cell, int row, int column); // } // Path: src/main/java/uk/co/certait/htmlexporter/writer/ods/OdsTableRowWriter.java import org.jsoup.nodes.Element; import org.odftoolkit.simple.table.Table; import uk.co.certait.htmlexporter.writer.AbstractTableRowWriter; import uk.co.certait.htmlexporter.writer.TableCellWriter; /** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer.ods; public class OdsTableRowWriter extends AbstractTableRowWriter { private Table table;
public OdsTableRowWriter(Table table, TableCellWriter cellWriter) {
alanhay/html-exporter
src/main/java/uk/co/certait/htmlexporter/writer/excel/ExcelTableRowWriter.java
// Path: src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableRowWriter.java // public abstract class AbstractTableRowWriter implements TableRowWriter { // private TableCellWriter cellWriter; // private RowTracker rowTracker; // // public AbstractTableRowWriter(TableCellWriter cellWriter) { // this.cellWriter = cellWriter; // rowTracker = new RowTracker(); // } // // public void writeRow(Element row, int rowIndex) { // renderRow(row, rowIndex); // // for (Element element : row.getAllElements()) { // if (element.tag().getName().equals(TD_TAG) || element.tag().getName().equals(TH_TAG)) { // int columnIndex = rowTracker.getNextColumnIndexForRow(rowIndex); // cellWriter.writeCell(element, rowIndex, columnIndex); // // int rowSpan = getRowSpan(element); // int columnSpan = getColumnSpan(element); // // rowTracker.addCell(rowIndex, columnIndex, rowSpan, columnSpan); // // if (rowSpan > 1 || columnSpan > 1) { // doMerge(rowIndex, columnIndex, rowSpan, columnSpan); // } // } // } // } // // protected boolean isRowGrouped(Element row) { // return row.hasAttr(""); // } // // protected String[] getRowGroups(Element row) { // return getAttributeValues(row, ""); // } // // protected String[] getAttributeValues(Element element, String attributeName) { // String values[] = null; // // if (element.hasAttr(attributeName)) { // values = element.attr(attributeName).toLowerCase().split(","); // // for (String value : values) { // value = value.trim().toLowerCase(); // } // } // // return values; // } // // protected int getColumnSpan(Element element) { // int columnSpan = 1; // // if (element.hasAttr("colspan")) { // columnSpan = Integer.parseInt(element.attr("colspan")); // } // // return columnSpan; // } // // protected int getRowSpan(Element element) { // int rowSpan = 1; // // if (element.hasAttr("rowSpan")) { // rowSpan = Integer.parseInt(element.attr("rowSpan")); // } // // return rowSpan; // } // // public abstract void renderRow(Element row, int rowIndex); // // public abstract void doMerge(int rowIndex, int columnIndex, int rowSpan, int columnSpan); // } // // Path: src/main/java/uk/co/certait/htmlexporter/writer/TableCellWriter.java // public interface TableCellWriter { // public static final String COLUMN_SPAN_ATTRIBUTE = "colspan"; // public static final String DATA_GROUP_ATTRIBUTE = "data-group"; // public static final String DATA_GROUP_OUTPUT_ATTRIBUTE = "data-group-output"; // public static final String DATE_CELL_ATTRIBUTE = "data-date-cell-format"; // public static final String DATA_CELL_COMMENT_ATTRIBUTE = "data-cell-comment"; // public static final String DATA_CELL_COMMENT_DIMENSION_ATTRIBUTE = "data-cell-comment-dimension"; // public static final String DATA_TEXT_CELL = "data-text-cell"; // public static final String DATA_FREEZE_PANE_CELL = "data-freeze-pane-cell"; // // public void writeCell(Element cell, int row, int column); // }
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.RegionUtil; import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.writer.AbstractTableRowWriter; import uk.co.certait.htmlexporter.writer.TableCellWriter;
/** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer.excel; public class ExcelTableRowWriter extends AbstractTableRowWriter { private Sheet sheet;
// Path: src/main/java/uk/co/certait/htmlexporter/writer/AbstractTableRowWriter.java // public abstract class AbstractTableRowWriter implements TableRowWriter { // private TableCellWriter cellWriter; // private RowTracker rowTracker; // // public AbstractTableRowWriter(TableCellWriter cellWriter) { // this.cellWriter = cellWriter; // rowTracker = new RowTracker(); // } // // public void writeRow(Element row, int rowIndex) { // renderRow(row, rowIndex); // // for (Element element : row.getAllElements()) { // if (element.tag().getName().equals(TD_TAG) || element.tag().getName().equals(TH_TAG)) { // int columnIndex = rowTracker.getNextColumnIndexForRow(rowIndex); // cellWriter.writeCell(element, rowIndex, columnIndex); // // int rowSpan = getRowSpan(element); // int columnSpan = getColumnSpan(element); // // rowTracker.addCell(rowIndex, columnIndex, rowSpan, columnSpan); // // if (rowSpan > 1 || columnSpan > 1) { // doMerge(rowIndex, columnIndex, rowSpan, columnSpan); // } // } // } // } // // protected boolean isRowGrouped(Element row) { // return row.hasAttr(""); // } // // protected String[] getRowGroups(Element row) { // return getAttributeValues(row, ""); // } // // protected String[] getAttributeValues(Element element, String attributeName) { // String values[] = null; // // if (element.hasAttr(attributeName)) { // values = element.attr(attributeName).toLowerCase().split(","); // // for (String value : values) { // value = value.trim().toLowerCase(); // } // } // // return values; // } // // protected int getColumnSpan(Element element) { // int columnSpan = 1; // // if (element.hasAttr("colspan")) { // columnSpan = Integer.parseInt(element.attr("colspan")); // } // // return columnSpan; // } // // protected int getRowSpan(Element element) { // int rowSpan = 1; // // if (element.hasAttr("rowSpan")) { // rowSpan = Integer.parseInt(element.attr("rowSpan")); // } // // return rowSpan; // } // // public abstract void renderRow(Element row, int rowIndex); // // public abstract void doMerge(int rowIndex, int columnIndex, int rowSpan, int columnSpan); // } // // Path: src/main/java/uk/co/certait/htmlexporter/writer/TableCellWriter.java // public interface TableCellWriter { // public static final String COLUMN_SPAN_ATTRIBUTE = "colspan"; // public static final String DATA_GROUP_ATTRIBUTE = "data-group"; // public static final String DATA_GROUP_OUTPUT_ATTRIBUTE = "data-group-output"; // public static final String DATE_CELL_ATTRIBUTE = "data-date-cell-format"; // public static final String DATA_CELL_COMMENT_ATTRIBUTE = "data-cell-comment"; // public static final String DATA_CELL_COMMENT_DIMENSION_ATTRIBUTE = "data-cell-comment-dimension"; // public static final String DATA_TEXT_CELL = "data-text-cell"; // public static final String DATA_FREEZE_PANE_CELL = "data-freeze-pane-cell"; // // public void writeCell(Element cell, int row, int column); // } // Path: src/main/java/uk/co/certait/htmlexporter/writer/excel/ExcelTableRowWriter.java import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.RegionUtil; import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.writer.AbstractTableRowWriter; import uk.co.certait.htmlexporter.writer.TableCellWriter; /** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer.excel; public class ExcelTableRowWriter extends AbstractTableRowWriter { private Sheet sheet;
public ExcelTableRowWriter(Sheet sheet, TableCellWriter cellWriter) {
alanhay/html-exporter
src/main/java/uk/co/certait/htmlexporter/writer/TableWriter.java
// Path: src/main/java/uk/co/certait/htmlexporter/css/StyleMap.java // public class StyleMap { // private static final String CLASS_PREFIX = "."; // // Map<String, Style> styles; // private StyleGenerator generator; // // public StyleMap(Map<String, Style> styles) { // this.styles = styles != null ? styles : new HashMap<String, Style>(); // generator = new StyleGenerator(); // } // // public Style getStyleForElement(Element element) { // Style style = new Style(); // // if (getStyleForTag(element) != null) { // style = StyleMerger.mergeStyles(style, getStyleForTag(element)); // } // // if (!getStylesForClass(element).isEmpty()) { // List<Style> classStyles = getStylesForClass(element); // // for (Style classStyle : classStyles) { // style = StyleMerger.mergeStyles(style, classStyle); // } // } // // if (getInlineStyle(element) != null) { // style = StyleMerger.mergeStyles(style, getInlineStyle(element)); // } // // return style; // } // // private Style getStyleForTag(Element element) { // return styles.get(element.tagName()); // } // // private List<Style> getStylesForClass(Element element) { // List<Style> classStyles = new ArrayList<Style>(); // // if (StringUtils.isNotEmpty(element.className())) { // String[] classNames = element.className().split(" "); // // for (String className : classNames) { // String qualifiedClassName = CLASS_PREFIX + className.trim(); // // if (styles.containsKey(qualifiedClassName)) { // classStyles.add(styles.get(qualifiedClassName)); // } // } // } // // return classStyles; // } // // private Style getInlineStyle(Element element) { // Style style = null; // // if (element.hasAttr("style")) { // List<Rule> inlineRules; // try { // String inlineStyle = element.attr("style").endsWith(";") ? element.attr("style") : element // .attr("style") + ";"; // inlineRules = CSSParser.parse("x{" + inlineStyle + "}"); // } catch (Exception e) { // throw new RuntimeException("Error parsing inline style for element " + element.tagName()); // } // // style = generator.createStyle(inlineRules.get(0), inlineRules.get(0).getSelectors().get(0)); // } // // return style; // } // }
import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.css.StyleMap;
/** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer; public interface TableWriter { public static final String TABLE_ROW_ELEMENT_NAME = "tr";
// Path: src/main/java/uk/co/certait/htmlexporter/css/StyleMap.java // public class StyleMap { // private static final String CLASS_PREFIX = "."; // // Map<String, Style> styles; // private StyleGenerator generator; // // public StyleMap(Map<String, Style> styles) { // this.styles = styles != null ? styles : new HashMap<String, Style>(); // generator = new StyleGenerator(); // } // // public Style getStyleForElement(Element element) { // Style style = new Style(); // // if (getStyleForTag(element) != null) { // style = StyleMerger.mergeStyles(style, getStyleForTag(element)); // } // // if (!getStylesForClass(element).isEmpty()) { // List<Style> classStyles = getStylesForClass(element); // // for (Style classStyle : classStyles) { // style = StyleMerger.mergeStyles(style, classStyle); // } // } // // if (getInlineStyle(element) != null) { // style = StyleMerger.mergeStyles(style, getInlineStyle(element)); // } // // return style; // } // // private Style getStyleForTag(Element element) { // return styles.get(element.tagName()); // } // // private List<Style> getStylesForClass(Element element) { // List<Style> classStyles = new ArrayList<Style>(); // // if (StringUtils.isNotEmpty(element.className())) { // String[] classNames = element.className().split(" "); // // for (String className : classNames) { // String qualifiedClassName = CLASS_PREFIX + className.trim(); // // if (styles.containsKey(qualifiedClassName)) { // classStyles.add(styles.get(qualifiedClassName)); // } // } // } // // return classStyles; // } // // private Style getInlineStyle(Element element) { // Style style = null; // // if (element.hasAttr("style")) { // List<Rule> inlineRules; // try { // String inlineStyle = element.attr("style").endsWith(";") ? element.attr("style") : element // .attr("style") + ";"; // inlineRules = CSSParser.parse("x{" + inlineStyle + "}"); // } catch (Exception e) { // throw new RuntimeException("Error parsing inline style for element " + element.tagName()); // } // // style = generator.createStyle(inlineRules.get(0), inlineRules.get(0).getSelectors().get(0)); // } // // return style; // } // } // Path: src/main/java/uk/co/certait/htmlexporter/writer/TableWriter.java import org.jsoup.nodes.Element; import uk.co.certait.htmlexporter.css.StyleMap; /** * Copyright (C) 2012 alanhay <alanhay99@hotmail.com> * * 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 uk.co.certait.htmlexporter.writer; public interface TableWriter { public static final String TABLE_ROW_ELEMENT_NAME = "tr";
public int writeTable(Element table, StyleMap styleMapper, int startRow);
Crab2died/Excel4J
src/main/java/com/github/crab2died/utils/DateUtils.java
// Path: src/main/java/com/github/crab2died/exceptions/TimeMatchFormatException.java // public class TimeMatchFormatException extends RuntimeException { // // private static final long serialVersionUID = 206910143412957809L; // // public TimeMatchFormatException() { // } // // public TimeMatchFormatException(String message) { // super(message); // } // // public TimeMatchFormatException(String message, Throwable cause) { // super(message, cause); // } // }
import com.github.crab2died.exceptions.TimeMatchFormatException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;
} /** * <p>将{@link Date}类型转换为默认为[yyyy-MM-dd HH:mm:ss]类型的字符串</p> * author : Crab2Died * date : 2017年06月02日 15:30:01 * * @param date {@link Date}类型的时间 * @return 返回格式化后的时间字符串 */ public static String date2Str(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_SEC); return sdf.format(date); } /** * <p>根据给出的格式化类型将时间字符串转为{@link Date}类型</p> * author : Crab2Died * date : 2017年06月02日 15:27:22 * * @param strDate 时间字符串 * @param format 格式化类型 * @return 返回{@link java.util.Date}类型 */ public static Date str2Date(String strDate, String format) { Date date = null; SimpleDateFormat sdf = new SimpleDateFormat(format); try { date = sdf.parse(strDate); } catch (ParseException e) {
// Path: src/main/java/com/github/crab2died/exceptions/TimeMatchFormatException.java // public class TimeMatchFormatException extends RuntimeException { // // private static final long serialVersionUID = 206910143412957809L; // // public TimeMatchFormatException() { // } // // public TimeMatchFormatException(String message) { // super(message); // } // // public TimeMatchFormatException(String message, Throwable cause) { // super(message, cause); // } // } // Path: src/main/java/com/github/crab2died/utils/DateUtils.java import com.github.crab2died.exceptions.TimeMatchFormatException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; } /** * <p>将{@link Date}类型转换为默认为[yyyy-MM-dd HH:mm:ss]类型的字符串</p> * author : Crab2Died * date : 2017年06月02日 15:30:01 * * @param date {@link Date}类型的时间 * @return 返回格式化后的时间字符串 */ public static String date2Str(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_SEC); return sdf.format(date); } /** * <p>根据给出的格式化类型将时间字符串转为{@link Date}类型</p> * author : Crab2Died * date : 2017年06月02日 15:27:22 * * @param strDate 时间字符串 * @param format 格式化类型 * @return 返回{@link java.util.Date}类型 */ public static Date str2Date(String strDate, String format) { Date date = null; SimpleDateFormat sdf = new SimpleDateFormat(format); try { date = sdf.parse(strDate); } catch (ParseException e) {
throw new TimeMatchFormatException("[" + strDate + "] parse to [" + format + "] exception", e);
Crab2died/Excel4J
src/main/java/com/github/crab2died/annotation/ExcelField.java
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // } // Path: src/main/java/com/github/crab2died/annotation/ExcelField.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */
Class<? extends WriteConvertible> writeConverter()
Crab2died/Excel4J
src/main/java/com/github/crab2died/annotation/ExcelField.java
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */ Class<? extends WriteConvertible> writeConverter()
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // } // Path: src/main/java/com/github/crab2died/annotation/ExcelField.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */ Class<? extends WriteConvertible> writeConverter()
default DefaultConvertible.class;
Crab2died/Excel4J
src/main/java/com/github/crab2died/annotation/ExcelField.java
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */ Class<? extends WriteConvertible> writeConverter() default DefaultConvertible.class; /** * 读数据转换器 * * @return 读取Excel数据转换器 * @see ReadConvertible */
// Path: src/main/java/com/github/crab2died/converter/DefaultConvertible.java // public class DefaultConvertible implements WriteConvertible, ReadConvertible { // // @Override // public Object execRead(String object) { // throw new UnsupportedOperationException(); // } // // @Override // public Object execWrite(Object object) { // throw new UnsupportedOperationException(); // } // } // // Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // } // Path: src/main/java/com/github/crab2died/annotation/ExcelField.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.github.crab2died.converter.DefaultConvertible; import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.annotation; /** * 功能说明: 用来在对象的属性上加入的annotation,通过该annotation说明某个属性所对应的标题 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ExcelField { /** * 属性的标题名称 * * @return 表头名 */ String title(); /** * 写数据转换器 * * @return 写入Excel数据转换器 * @see WriteConvertible */ Class<? extends WriteConvertible> writeConverter() default DefaultConvertible.class; /** * 读数据转换器 * * @return 读取Excel数据转换器 * @see ReadConvertible */
Class<? extends ReadConvertible> readConverter()
Crab2died/Excel4J
src/main/java/com/github/crab2died/handler/SheetTemplateHandler.java
// Path: src/main/java/com/github/crab2died/exceptions/Excel4JException.java // public class Excel4JException extends Exception { // // public Excel4JException() { // } // // public Excel4JException(String message) { // super(message); // } // // public Excel4JException(String message, Throwable cause) { // super(message, cause); // } // // public Excel4JException(Throwable cause) { // super(cause); // } // }
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; import java.util.Date; import java.util.Map; import com.github.crab2died.exceptions.Excel4JException; import org.apache.poi.ss.usermodel.*; import java.io.File;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; public class SheetTemplateHandler { // 构建SheetTemplate public static SheetTemplate sheetTemplateBuilder(String templatePath)
// Path: src/main/java/com/github/crab2died/exceptions/Excel4JException.java // public class Excel4JException extends Exception { // // public Excel4JException() { // } // // public Excel4JException(String message) { // super(message); // } // // public Excel4JException(String message, Throwable cause) { // super(message, cause); // } // // public Excel4JException(Throwable cause) { // super(cause); // } // } // Path: src/main/java/com/github/crab2died/handler/SheetTemplateHandler.java import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; import java.util.Date; import java.util.Map; import com.github.crab2died.exceptions.Excel4JException; import org.apache.poi.ss.usermodel.*; import java.io.File; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; public class SheetTemplateHandler { // 构建SheetTemplate public static SheetTemplate sheetTemplateBuilder(String templatePath)
throws Excel4JException {
Crab2died/Excel4J
src/main/java/com/github/crab2died/handler/SheetTemplate.java
// Path: src/main/java/com/github/crab2died/exceptions/Excel4JException.java // public class Excel4JException extends Exception { // // public Excel4JException() { // } // // public Excel4JException(String message) { // super(message); // } // // public Excel4JException(String message, Throwable cause) { // super(message, cause); // } // // public Excel4JException(Throwable cause) { // super(cause); // } // }
import org.apache.poi.ss.usermodel.Workbook; import java.io.Closeable; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import com.github.crab2died.exceptions.Excel4JException; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; public class SheetTemplate implements Closeable { /** * 当前工作簿 */ Workbook workbook; /** * 当前工作sheet表 */ Sheet sheet; /** * 当前表编号 */ int sheetIndex; /** * 当前行 */ Row currentRow; /** * 当前列数 */ int currentColumnIndex; /** * 当前行数 */ int currentRowIndex; /** * 默认样式 */ CellStyle defaultStyle; /** * 指定行样式 */ Map<Integer, CellStyle> appointLineStyle = new HashMap<>(); /** * 分类样式模板 */ Map<String, CellStyle> classifyStyle = new HashMap<>(); /** * 单数行样式 */ CellStyle singleLineStyle; /** * 双数行样式 */ CellStyle doubleLineStyle; /** * 数据的初始化列数 */ int initColumnIndex; /** * 数据的初始化行数 */ int initRowIndex; /** * 最后一行的数据 */ int lastRowIndex; /** * 默认行高 */ float rowHeight; /** * 序号坐标点 */ int serialNumberColumnIndex = -1; /** * 当前序号 */ int serialNumber; /*-----------------------------------写出数据开始-----------------------------------*/ /** * 将文件写到相应的路径下 * * @param filePath 输出文件路径 */
// Path: src/main/java/com/github/crab2died/exceptions/Excel4JException.java // public class Excel4JException extends Exception { // // public Excel4JException() { // } // // public Excel4JException(String message) { // super(message); // } // // public Excel4JException(String message, Throwable cause) { // super(message, cause); // } // // public Excel4JException(Throwable cause) { // super(cause); // } // } // Path: src/main/java/com/github/crab2died/handler/SheetTemplate.java import org.apache.poi.ss.usermodel.Workbook; import java.io.Closeable; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; import com.github.crab2died.exceptions.Excel4JException; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; public class SheetTemplate implements Closeable { /** * 当前工作簿 */ Workbook workbook; /** * 当前工作sheet表 */ Sheet sheet; /** * 当前表编号 */ int sheetIndex; /** * 当前行 */ Row currentRow; /** * 当前列数 */ int currentColumnIndex; /** * 当前行数 */ int currentRowIndex; /** * 默认样式 */ CellStyle defaultStyle; /** * 指定行样式 */ Map<Integer, CellStyle> appointLineStyle = new HashMap<>(); /** * 分类样式模板 */ Map<String, CellStyle> classifyStyle = new HashMap<>(); /** * 单数行样式 */ CellStyle singleLineStyle; /** * 双数行样式 */ CellStyle doubleLineStyle; /** * 数据的初始化列数 */ int initColumnIndex; /** * 数据的初始化行数 */ int initRowIndex; /** * 最后一行的数据 */ int lastRowIndex; /** * 默认行高 */ float rowHeight; /** * 序号坐标点 */ int serialNumberColumnIndex = -1; /** * 当前序号 */ int serialNumber; /*-----------------------------------写出数据开始-----------------------------------*/ /** * 将文件写到相应的路径下 * * @param filePath 输出文件路径 */
public void write2File(String filePath) throws Excel4JException {
Crab2died/Excel4J
src/main/java/com/github/crab2died/handler/ExcelHeader.java
// Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // }
import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; /** * 功能说明: 用来存储Excel标题的对象,通过该对象可以获取标题和方法的对应关系 */ public class ExcelHeader implements Comparable<ExcelHeader> { /** * excel的标题名称 */ private String title; /** * 每一个标题的顺序 */ private int order; /** * 写数据转换器 */
// Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // } // Path: src/main/java/com/github/crab2died/handler/ExcelHeader.java import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; /** * 功能说明: 用来存储Excel标题的对象,通过该对象可以获取标题和方法的对应关系 */ public class ExcelHeader implements Comparable<ExcelHeader> { /** * excel的标题名称 */ private String title; /** * 每一个标题的顺序 */ private int order; /** * 写数据转换器 */
private WriteConvertible writeConverter;
Crab2died/Excel4J
src/main/java/com/github/crab2died/handler/ExcelHeader.java
// Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // }
import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; /** * 功能说明: 用来存储Excel标题的对象,通过该对象可以获取标题和方法的对应关系 */ public class ExcelHeader implements Comparable<ExcelHeader> { /** * excel的标题名称 */ private String title; /** * 每一个标题的顺序 */ private int order; /** * 写数据转换器 */ private WriteConvertible writeConverter; /** * 读数据转换器 */
// Path: src/main/java/com/github/crab2died/converter/ReadConvertible.java // public interface ReadConvertible { // // /** // * 读取Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#readConverter() // */ // Object execRead(String object); // } // // Path: src/main/java/com/github/crab2died/converter/WriteConvertible.java // public interface WriteConvertible { // // /** // * 写入Excel列内容转换 // * // * @param object 待转换数据 // * @return 转换完成的结果 // * @see com.github.crab2died.annotation.ExcelField#writeConverter() // */ // Object execWrite(Object object); // } // Path: src/main/java/com/github/crab2died/handler/ExcelHeader.java import com.github.crab2died.converter.ReadConvertible; import com.github.crab2died.converter.WriteConvertible; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.handler; /** * 功能说明: 用来存储Excel标题的对象,通过该对象可以获取标题和方法的对应关系 */ public class ExcelHeader implements Comparable<ExcelHeader> { /** * excel的标题名称 */ private String title; /** * 每一个标题的顺序 */ private int order; /** * 写数据转换器 */ private WriteConvertible writeConverter; /** * 读数据转换器 */
private ReadConvertible readConverter;
Crab2died/Excel4J
src/main/java/com/github/crab2died/utils/RegularUtils.java
// Path: src/main/java/com/github/crab2died/exceptions/IllegalGroupIndexException.java // public class IllegalGroupIndexException extends RuntimeException { // // private static final long serialVersionUID = 7725478743860387475L; // // public IllegalGroupIndexException(String message) { // super(message); // } // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import com.github.crab2died.exceptions.IllegalGroupIndexException; import java.util.ArrayList; import java.util.List;
/* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.utils; /** * <p>正则匹配相关工具</p> * author : Crab2Died * date : 2017/5/24 9:43 */ public class RegularUtils { /** * <p>判断内容是否匹配</p> * author : Crab2Died * date : 2017年06月02日 15:46:25 * * @param pattern 匹配目标内容 * @param reg 正则表达式 * @return 返回boolean */ public static boolean isMatched(String pattern, String reg) { Pattern compile = Pattern.compile(reg); return compile.matcher(pattern).matches(); } /** * <p>正则提取匹配到的内容</p> * <p>例如:</p> * <p> * author : Crab2Died * date : 2017年06月02日 15:49:51 * * @param pattern 匹配目标内容 * @param reg 正则表达式 * @param group 提取内容索引 * @return 提取内容集合 */ public static List<String> match(String pattern, String reg, int group) { List<String> matchGroups = new ArrayList<>(); Pattern compile = Pattern.compile(reg); Matcher matcher = compile.matcher(pattern); if (group > matcher.groupCount() || group < 0)
// Path: src/main/java/com/github/crab2died/exceptions/IllegalGroupIndexException.java // public class IllegalGroupIndexException extends RuntimeException { // // private static final long serialVersionUID = 7725478743860387475L; // // public IllegalGroupIndexException(String message) { // super(message); // } // } // Path: src/main/java/com/github/crab2died/utils/RegularUtils.java import java.util.regex.Matcher; import java.util.regex.Pattern; import com.github.crab2died.exceptions.IllegalGroupIndexException; import java.util.ArrayList; import java.util.List; /* * * Copyright 2017 Crab2Died * All rights reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * * Browse for more information : * 1) https://gitee.com/Crab2Died/Excel4J * 2) https://github.com/Crab2died/Excel4J * */ package com.github.crab2died.utils; /** * <p>正则匹配相关工具</p> * author : Crab2Died * date : 2017/5/24 9:43 */ public class RegularUtils { /** * <p>判断内容是否匹配</p> * author : Crab2Died * date : 2017年06月02日 15:46:25 * * @param pattern 匹配目标内容 * @param reg 正则表达式 * @return 返回boolean */ public static boolean isMatched(String pattern, String reg) { Pattern compile = Pattern.compile(reg); return compile.matcher(pattern).matches(); } /** * <p>正则提取匹配到的内容</p> * <p>例如:</p> * <p> * author : Crab2Died * date : 2017年06月02日 15:49:51 * * @param pattern 匹配目标内容 * @param reg 正则表达式 * @param group 提取内容索引 * @return 提取内容集合 */ public static List<String> match(String pattern, String reg, int group) { List<String> matchGroups = new ArrayList<>(); Pattern compile = Pattern.compile(reg); Matcher matcher = compile.matcher(pattern); if (group > matcher.groupCount() || group < 0)
throw new IllegalGroupIndexException("Illegal match group :" + group);
Crab2died/Excel4J
src/test/java/modules/Student2.java
// Path: src/test/java/converter/Student2DateConverter.java // public class Student2DateConverter implements WriteConvertible { // // // @Override // public Object execWrite(Object object) { // // Date date = (Date) object; // return DateUtils.date2Str(date, DateUtils.DATE_FORMAT_MSEC_T_Z); // } // } // // Path: src/test/java/converter/Student2ExpelConverter.java // public class Student2ExpelConverter implements ReadConvertible{ // // @Override // public Object execRead(String object) { // // return object.equals("是"); // } // }
import com.github.crab2died.annotation.ExcelField; import converter.Student2DateConverter; import converter.Student2ExpelConverter; import java.util.Date;
package modules; public class Student2 { @ExcelField(title = "学号", order = 1) private Long id; @ExcelField(title = "姓名", order = 2) private String name; // 写入数据转换器 Student2DateConverter
// Path: src/test/java/converter/Student2DateConverter.java // public class Student2DateConverter implements WriteConvertible { // // // @Override // public Object execWrite(Object object) { // // Date date = (Date) object; // return DateUtils.date2Str(date, DateUtils.DATE_FORMAT_MSEC_T_Z); // } // } // // Path: src/test/java/converter/Student2ExpelConverter.java // public class Student2ExpelConverter implements ReadConvertible{ // // @Override // public Object execRead(String object) { // // return object.equals("是"); // } // } // Path: src/test/java/modules/Student2.java import com.github.crab2died.annotation.ExcelField; import converter.Student2DateConverter; import converter.Student2ExpelConverter; import java.util.Date; package modules; public class Student2 { @ExcelField(title = "学号", order = 1) private Long id; @ExcelField(title = "姓名", order = 2) private String name; // 写入数据转换器 Student2DateConverter
@ExcelField(title = "入学日期", order = 3, writeConverter = Student2DateConverter.class)
Crab2died/Excel4J
src/test/java/modules/Student2.java
// Path: src/test/java/converter/Student2DateConverter.java // public class Student2DateConverter implements WriteConvertible { // // // @Override // public Object execWrite(Object object) { // // Date date = (Date) object; // return DateUtils.date2Str(date, DateUtils.DATE_FORMAT_MSEC_T_Z); // } // } // // Path: src/test/java/converter/Student2ExpelConverter.java // public class Student2ExpelConverter implements ReadConvertible{ // // @Override // public Object execRead(String object) { // // return object.equals("是"); // } // }
import com.github.crab2died.annotation.ExcelField; import converter.Student2DateConverter; import converter.Student2ExpelConverter; import java.util.Date;
package modules; public class Student2 { @ExcelField(title = "学号", order = 1) private Long id; @ExcelField(title = "姓名", order = 2) private String name; // 写入数据转换器 Student2DateConverter @ExcelField(title = "入学日期", order = 3, writeConverter = Student2DateConverter.class) private Date date; @ExcelField(title = "班级", order = 4) private Integer classes; // 读取数据转换器 Student2ExpelConverter
// Path: src/test/java/converter/Student2DateConverter.java // public class Student2DateConverter implements WriteConvertible { // // // @Override // public Object execWrite(Object object) { // // Date date = (Date) object; // return DateUtils.date2Str(date, DateUtils.DATE_FORMAT_MSEC_T_Z); // } // } // // Path: src/test/java/converter/Student2ExpelConverter.java // public class Student2ExpelConverter implements ReadConvertible{ // // @Override // public Object execRead(String object) { // // return object.equals("是"); // } // } // Path: src/test/java/modules/Student2.java import com.github.crab2died.annotation.ExcelField; import converter.Student2DateConverter; import converter.Student2ExpelConverter; import java.util.Date; package modules; public class Student2 { @ExcelField(title = "学号", order = 1) private Long id; @ExcelField(title = "姓名", order = 2) private String name; // 写入数据转换器 Student2DateConverter @ExcelField(title = "入学日期", order = 3, writeConverter = Student2DateConverter.class) private Date date; @ExcelField(title = "班级", order = 4) private Integer classes; // 读取数据转换器 Student2ExpelConverter
@ExcelField(title = "是否开除", order = 5, readConverter = Student2ExpelConverter.class)
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/adapter/WrapperCircularPagerAdapter.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CircularViewPager.java // public class CircularViewPager extends ViewPager { // // private WrapperCircularPagerAdapter wrapperCircularPagerAdapter; // // public CircularViewPager(Context context) { // super(context); // } // // public CircularViewPager(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // public void setAdapter(PagerAdapter adapter) { // if (!(adapter instanceof WrapperCircularPagerAdapter)) { // throw new IllegalArgumentException("The CircularViewPager accepts only instances of WrapperCircularPagerAdapter. Please, use this class to wrap your Adapter."); // } // super.setAdapter(adapter); // this.wrapperCircularPagerAdapter = (WrapperCircularPagerAdapter) adapter; // this.wrapperCircularPagerAdapter.setCircularViewPager(this); // // offset first element so that we can scroll to the left // setCurrentItem(wrapperCircularPagerAdapter.getOffsetAmount(), false); // } // // // public void setCurrentVirtualItem(int virtualItem) { // setCurrentVirtualItem(virtualItem, true); // } // // public void setCurrentVirtualItem(int virtualItem, boolean smoothScroll){ // setCurrentVirtualItem(virtualItem, getCurrentItem(), smoothScroll); // } // // public void setCurrentVirtualItem(int virtualItem, int currentItem, boolean smoothScroll){ // int currentVirtualItem = getCurrentVirtualItem(); // // int leftDistance; // int rightDistance; // int size = wrapperCircularPagerAdapter.getVirtualCount(); // // if(virtualItem < currentVirtualItem){ // leftDistance = currentVirtualItem - virtualItem; // // int stepsToArriveToFirstElement = size - currentVirtualItem; // rightDistance = stepsToArriveToFirstElement + virtualItem; // } // else { // rightDistance = virtualItem - currentVirtualItem; // // int lastIndex = size - 1; // int stepsToArriveToLastElement = currentVirtualItem + 1; // leftDistance = stepsToArriveToLastElement + (lastIndex - virtualItem); // } // // if(leftDistance < rightDistance){ // setCurrentItem(currentItem - leftDistance, smoothScroll); // } // else { // setCurrentItem(currentItem + rightDistance, smoothScroll); // } // } // // /** // * // * @return Current item or -1 if the ViewPager is empty. // */ // public int getCurrentVirtualItem() { // final int virtualCount = wrapperCircularPagerAdapter.getVirtualCount(); // if(virtualCount > 0) { // return getCurrentItem() % virtualCount; // } // return -1; // } // // public PagerAdapter getVirtualAdapter() { // return wrapperCircularPagerAdapter != null ? wrapperCircularPagerAdapter.getAdapter() : null; // } // }
import android.os.Parcelable; import android.support.v4.view.PagerAdapter; import android.view.View; import android.view.ViewGroup; import br.com.cybereagle.androidwidgets.view.CircularViewPager;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.adapter; public class WrapperCircularPagerAdapter extends PagerAdapter { private static final int DEFAULT_QUANTITY_OF_CYCLES = 100; private PagerAdapter adapter; private int quantityOfCycles;
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CircularViewPager.java // public class CircularViewPager extends ViewPager { // // private WrapperCircularPagerAdapter wrapperCircularPagerAdapter; // // public CircularViewPager(Context context) { // super(context); // } // // public CircularViewPager(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // public void setAdapter(PagerAdapter adapter) { // if (!(adapter instanceof WrapperCircularPagerAdapter)) { // throw new IllegalArgumentException("The CircularViewPager accepts only instances of WrapperCircularPagerAdapter. Please, use this class to wrap your Adapter."); // } // super.setAdapter(adapter); // this.wrapperCircularPagerAdapter = (WrapperCircularPagerAdapter) adapter; // this.wrapperCircularPagerAdapter.setCircularViewPager(this); // // offset first element so that we can scroll to the left // setCurrentItem(wrapperCircularPagerAdapter.getOffsetAmount(), false); // } // // // public void setCurrentVirtualItem(int virtualItem) { // setCurrentVirtualItem(virtualItem, true); // } // // public void setCurrentVirtualItem(int virtualItem, boolean smoothScroll){ // setCurrentVirtualItem(virtualItem, getCurrentItem(), smoothScroll); // } // // public void setCurrentVirtualItem(int virtualItem, int currentItem, boolean smoothScroll){ // int currentVirtualItem = getCurrentVirtualItem(); // // int leftDistance; // int rightDistance; // int size = wrapperCircularPagerAdapter.getVirtualCount(); // // if(virtualItem < currentVirtualItem){ // leftDistance = currentVirtualItem - virtualItem; // // int stepsToArriveToFirstElement = size - currentVirtualItem; // rightDistance = stepsToArriveToFirstElement + virtualItem; // } // else { // rightDistance = virtualItem - currentVirtualItem; // // int lastIndex = size - 1; // int stepsToArriveToLastElement = currentVirtualItem + 1; // leftDistance = stepsToArriveToLastElement + (lastIndex - virtualItem); // } // // if(leftDistance < rightDistance){ // setCurrentItem(currentItem - leftDistance, smoothScroll); // } // else { // setCurrentItem(currentItem + rightDistance, smoothScroll); // } // } // // /** // * // * @return Current item or -1 if the ViewPager is empty. // */ // public int getCurrentVirtualItem() { // final int virtualCount = wrapperCircularPagerAdapter.getVirtualCount(); // if(virtualCount > 0) { // return getCurrentItem() % virtualCount; // } // return -1; // } // // public PagerAdapter getVirtualAdapter() { // return wrapperCircularPagerAdapter != null ? wrapperCircularPagerAdapter.getAdapter() : null; // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/adapter/WrapperCircularPagerAdapter.java import android.os.Parcelable; import android.support.v4.view.PagerAdapter; import android.view.View; import android.view.ViewGroup; import br.com.cybereagle.androidwidgets.view.CircularViewPager; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.adapter; public class WrapperCircularPagerAdapter extends PagerAdapter { private static final int DEFAULT_QUANTITY_OF_CYCLES = 100; private PagerAdapter adapter; private int quantityOfCycles;
private CircularViewPager circularViewPager;
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareGridLayout.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.GridLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareGridLayout extends GridLayout { public SquareGridLayout(Context context) { super(context); } public SquareGridLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareGridLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareGridLayout.java import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.GridLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareGridLayout extends GridLayout { public SquareGridLayout(Context context) { super(context); } public SquareGridLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareGridLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareFrameLayout.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.RelativeLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareFrameLayout extends FrameLayout { public SquareFrameLayout(Context context) { super(context); } public SquareFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareFrameLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareFrameLayout.java import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.RelativeLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareFrameLayout extends FrameLayout { public SquareFrameLayout(Context context) { super(context); } public SquareFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareFrameLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/helper/UninterceptableViewPagerHelper.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/interfaces/UninterceptableViewPager.java // public interface UninterceptableViewPager { // boolean callRealOnInterceptTouchEvent(MotionEvent motionEvent); // }
import android.support.v4.view.ViewPager; import android.view.MotionEvent; import br.com.cybereagle.androidwidgets.interfaces.UninterceptableViewPager;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.helper; public class UninterceptableViewPagerHelper { private ViewPager viewPager; public UninterceptableViewPagerHelper(ViewPager viewPager) { this.viewPager = viewPager;
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/interfaces/UninterceptableViewPager.java // public interface UninterceptableViewPager { // boolean callRealOnInterceptTouchEvent(MotionEvent motionEvent); // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/helper/UninterceptableViewPagerHelper.java import android.support.v4.view.ViewPager; import android.view.MotionEvent; import br.com.cybereagle.androidwidgets.interfaces.UninterceptableViewPager; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.helper; public class UninterceptableViewPagerHelper { private ViewPager viewPager; public UninterceptableViewPagerHelper(ViewPager viewPager) { this.viewPager = viewPager;
if(!(viewPager instanceof UninterceptableViewPager)){
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareImageView.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.ImageView; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareImageView extends ImageView { public SquareImageView(Context context) { super(context); } public SquareImageView(Context context, AttributeSet attrs) { super(context, attrs); } public SquareImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareImageView.java import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.ImageView; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareImageView extends ImageView { public SquareImageView(Context context) { super(context); } public SquareImageView(Context context, AttributeSet attrs) { super(context, attrs); } public SquareImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareLinearLayout.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.LinearLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareLinearLayout extends LinearLayout { public SquareLinearLayout(Context context) { super(context); } public SquareLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareLinearLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareLinearLayout.java import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; import android.widget.LinearLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareLinearLayout extends LinearLayout { public SquareLinearLayout(Context context) { super(context); } public SquareLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareLinearLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/PagerContainer.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.graphics.Point; import android.os.Build; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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. * * Copyright (c) 2012 Wireless Designs, LLC * * 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 br.com.cybereagle.androidwidgets.view; /** * PagerContainer: A layout that displays a ViewPager with its children that are outside * the typical pager bounds. * * To use this, wrap your ViewPager with it, set the ViewPager's width to be equal the width * of its child, set the ViewPager's gravity to center and make this PagerContainer larger * than the ViewPager. You should also set the offscreenPageLimit of the ViewPager in a way * that it prepares more children that is really show, so that it loads the children before * you reach the last children, that gives a poor effect. * */ public class PagerContainer extends FrameLayout implements ViewPager.OnPageChangeListener { protected ViewPager pager; boolean needsRedraw = false; protected Point center = new Point(); protected Point initialTouch = new Point(); public PagerContainer(Context context) { super(context); init(); } public PagerContainer(Context context, AttributeSet attrs) { super(context, attrs); init(); } public PagerContainer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { //Disable clipping of children so non-selected pages are visible setClipChildren(false); //Child clipping doesn't work with hardware acceleration in Android 3.x/4.x //You need to set this value here if using hardware acceleration in an // application targeted at these releases.
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/PagerContainer.java import android.content.Context; import android.graphics.Point; import android.os.Build; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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. * * Copyright (c) 2012 Wireless Designs, LLC * * 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 br.com.cybereagle.androidwidgets.view; /** * PagerContainer: A layout that displays a ViewPager with its children that are outside * the typical pager bounds. * * To use this, wrap your ViewPager with it, set the ViewPager's width to be equal the width * of its child, set the ViewPager's gravity to center and make this PagerContainer larger * than the ViewPager. You should also set the offscreenPageLimit of the ViewPager in a way * that it prepares more children that is really show, so that it loads the children before * you reach the last children, that gives a poor effect. * */ public class PagerContainer extends FrameLayout implements ViewPager.OnPageChangeListener { protected ViewPager pager; boolean needsRedraw = false; protected Point center = new Point(); protected Point initialTouch = new Point(); public PagerContainer(Context context) { super(context); init(); } public PagerContainer(Context context, AttributeSet attrs) { super(context, attrs); init(); } public PagerContainer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } private void init() { //Disable clipping of children so non-selected pages are visible setClipChildren(false); //Child clipping doesn't work with hardware acceleration in Android 3.x/4.x //You need to set this value here if using hardware acceleration in an // application targeted at these releases.
ViewUtils.enableSoftwareLayer(this);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareRelativeLayout.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.widget.RelativeLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareRelativeLayout extends RelativeLayout { public SquareRelativeLayout(Context context) { super(context); } public SquareRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/SquareRelativeLayout.java import android.content.Context; import android.util.AttributeSet; import android.widget.RelativeLayout; import br.com.cybereagle.androidwidgets.util.ViewUtils; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class SquareRelativeLayout extends RelativeLayout { public SquareRelativeLayout(Context context) { super(context); } public SquareRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int finalMeasureSpec = ViewUtils.makeSquareMeasureSpec(widthMeasureSpec, heightMeasureSpec);
CyberEagle/AndroidWidgets
library/src/main/java/br/com/cybereagle/androidwidgets/view/CoverFlowPagerContainer.java
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // }
import android.content.Context; import android.util.AttributeSet; import android.view.View; import br.com.cybereagle.androidwidgets.util.ViewUtils; import java.util.ArrayList; import java.util.List;
/* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class CoverFlowPagerContainer extends PagerContainer{ private static final int MAX_ROTATION_ANGLE = 60; public CoverFlowPagerContainer(Context context) { super(context); } public CoverFlowPagerContainer(Context context, AttributeSet attrs) { super(context, attrs); } public CoverFlowPagerContainer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } private List<View> getViewPagerChildren(){ int childCount = pager.getChildCount(); List<View> children = new ArrayList<View>(childCount); for(int i=0; i<childCount; i++){ children.add(pager.getChildAt(i)); } return children; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { updateCoverFlow(); super.onPageScrolled(position, positionOffset, positionOffsetPixels); } public void updateCoverFlow() { int childCount = pager.getChildCount(); int[] xy = new int[2]; for(int i=0; i<childCount; i++){ View child = pager.getChildAt(i);
// Path: library/src/main/java/br/com/cybereagle/androidwidgets/util/ViewUtils.java // public class ViewUtils { // // public static final boolean IS_API_11_OR_ABOVE; // // static { // IS_API_11_OR_ABOVE = Build.VERSION.SDK_INT >= 11; // } // // public static int makeSquareMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) { // int widthMode = View.MeasureSpec.getMode(widthMeasureSpec); // int widthSize = View.MeasureSpec.getSize(widthMeasureSpec); // int heightMode = View.MeasureSpec.getMode(heightMeasureSpec); // int heightSize = View.MeasureSpec.getSize(heightMeasureSpec); // // int size; // if(widthMode == View.MeasureSpec.EXACTLY && widthSize == 0){ // size = widthSize; // } // else if(heightMode == View.MeasureSpec.EXACTLY && heightSize == 0){ // size = heightSize; // } // else{ // size = widthSize < heightSize ? widthSize : heightSize; // } // // return View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableHardwareLayer(View view) { // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_HARDWARE); // } // // @TargetApi(Build.VERSION_CODES.HONEYCOMB) // public static void enableSoftwareLayer(View view){ // if(!ViewUtils.IS_API_11_OR_ABOVE){ // return; // } // // setLayer(view, View.LAYER_TYPE_SOFTWARE); // } // // private static void setLayer(View view, int layer) { // if(view.getLayerType() != layer){ // view.setLayerType(layer, null); // } // } // } // Path: library/src/main/java/br/com/cybereagle/androidwidgets/view/CoverFlowPagerContainer.java import android.content.Context; import android.util.AttributeSet; import android.view.View; import br.com.cybereagle.androidwidgets.util.ViewUtils; import java.util.ArrayList; import java.util.List; /* * Copyright 2013 Cyber Eagle * * 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 br.com.cybereagle.androidwidgets.view; public class CoverFlowPagerContainer extends PagerContainer{ private static final int MAX_ROTATION_ANGLE = 60; public CoverFlowPagerContainer(Context context) { super(context); } public CoverFlowPagerContainer(Context context, AttributeSet attrs) { super(context, attrs); } public CoverFlowPagerContainer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } private List<View> getViewPagerChildren(){ int childCount = pager.getChildCount(); List<View> children = new ArrayList<View>(childCount); for(int i=0; i<childCount; i++){ children.add(pager.getChildAt(i)); } return children; } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { updateCoverFlow(); super.onPageScrolled(position, positionOffset, positionOffsetPixels); } public void updateCoverFlow() { int childCount = pager.getChildCount(); int[] xy = new int[2]; for(int i=0; i<childCount; i++){ View child = pager.getChildAt(i);
ViewUtils.enableHardwareLayer(child);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListActivity.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import com.microsoft.o365_android_onenote_rest.util.User;
.setActivateOnItemClick(true); } } @Override public void onItemSelected(int position) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putInt(SnippetDetailFragment.ARG_ITEM_ID, position); SnippetDetailFragment fragment = new SnippetDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .replace(R.id.snippet_detail_container, fragment) .commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, SnippetDetailActivity.class); detailIntent.putExtra(SnippetDetailFragment.ARG_ITEM_ID, position); startActivity(detailIntent); } } @Override public void onDisconnectClicked() { finish();
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import com.microsoft.o365_android_onenote_rest.util.User; .setActivateOnItemClick(true); } } @Override public void onItemSelected(int position) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putInt(SnippetDetailFragment.ARG_ITEM_ID, position); SnippetDetailFragment fragment = new SnippetDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .replace(R.id.snippet_detail_container, fragment) .commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, SnippetDetailActivity.class); detailIntent.putExtra(SnippetDetailFragment.ARG_ITEM_ID, position); startActivity(detailIntent); } } @Override public void onDisconnectClicked() { finish();
if (User.isOrg()) {
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListActivity.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import com.microsoft.o365_android_onenote_rest.util.User;
if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putInt(SnippetDetailFragment.ARG_ITEM_ID, position); SnippetDetailFragment fragment = new SnippetDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .replace(R.id.snippet_detail_container, fragment) .commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, SnippetDetailActivity.class); detailIntent.putExtra(SnippetDetailFragment.ARG_ITEM_ID, position); startActivity(detailIntent); } } @Override public void onDisconnectClicked() { finish(); if (User.isOrg()) { mAuthenticationManager.disconnect(); } else if (User.isMsa()) { mLiveAuthClient.logout(null); } // drop the application shared preferences to clear any old auth tokens
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import com.microsoft.o365_android_onenote_rest.util.User; if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putInt(SnippetDetailFragment.ARG_ITEM_ID, position); SnippetDetailFragment fragment = new SnippetDetailFragment(); fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction() .replace(R.id.snippet_detail_container, fragment) .commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, SnippetDetailActivity.class); detailIntent.putExtra(SnippetDetailFragment.ARG_ITEM_ID, position); startActivity(detailIntent); } } @Override public void onDisconnectClicked() { finish(); if (User.isOrg()) { mAuthenticationManager.disconnect(); } else if (User.isMsa()) { mLiveAuthClient.logout(null); } // drop the application shared preferences to clear any old auth tokens
getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE)
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // }
import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = {
SnippetApp.class
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // }
import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = { SnippetApp.class } ) public class AppModule { public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; @Provides public String providesRestEndpoint() {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = { SnippetApp.class } ) public class AppModule { public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; @Provides public String providesRestEndpoint() {
return ServiceConstants.ONENOTE_API;
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // }
import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = { SnippetApp.class } ) public class AppModule { public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; @Provides public String providesRestEndpoint() { return ServiceConstants.ONENOTE_API; } @Provides public RestAdapter.LogLevel providesLogLevel() { return RestAdapter.LogLevel.FULL; } @Provides public Converter providesConverter() { return new GsonConverter(GsonDateTime.getOneNoteBuilder() .create()); } @Provides public RequestInterceptor providesRequestInterceptor() { return new RequestInterceptor() { @Override public void intercept(RequestFacade request) { // apply the Authorization header if we had a token... final SharedPreferences preferences = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); final String token =
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java import android.content.Context; import android.content.SharedPreferences; import com.microsoft.live.LiveAuthClient; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.onenoteapi.service.GsonDateTime; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import retrofit.converter.GsonConverter; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.inject; @Module(library = true, injects = { SnippetApp.class } ) public class AppModule { public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; @Provides public String providesRestEndpoint() { return ServiceConstants.ONENOTE_API; } @Provides public RestAdapter.LogLevel providesLogLevel() { return RestAdapter.LogLevel.FULL; } @Provides public Converter providesConverter() { return new GsonConverter(GsonDateTime.getOneNoteBuilder() .create()); } @Provides public RequestInterceptor providesRequestInterceptor() { return new RequestInterceptor() { @Override public void intercept(RequestFacade request) { // apply the Authorization header if we had a token... final SharedPreferences preferences = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); final String token =
preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // }
import android.content.Context; import android.content.SharedPreferences; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveConnectSession; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.inject.AppModule;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.util; public class SharedPrefsUtil { public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; public static SharedPreferences getSharedPreferences() {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java import android.content.Context; import android.content.SharedPreferences; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveConnectSession; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.inject.AppModule; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.util; public class SharedPrefsUtil { public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; public static SharedPreferences getSharedPreferences() {
return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // }
import android.content.Context; import android.content.SharedPreferences; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveConnectSession; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.inject.AppModule;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.util; public class SharedPrefsUtil { public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; public static SharedPreferences getSharedPreferences() {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java import android.content.Context; import android.content.SharedPreferences; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveConnectSession; import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import com.microsoft.o365_android_onenote_rest.inject.AppModule; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.util; public class SharedPrefsUtil { public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; public static SharedPreferences getSharedPreferences() {
return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // }
import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SignInActivity extends BaseActivity implements AuthenticationCallback<AuthenticationResult>, LiveAuthListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signin);
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SignInActivity extends BaseActivity implements AuthenticationCallback<AuthenticationResult>, LiveAuthListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signin);
if (User.isOrg()) {
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // }
import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin;
private void warnBadClient() { Toast.makeText(this, R.string.warning_clientid_redirecturi_incorrect, Toast.LENGTH_LONG) .show(); } private void authenticateOrganization() throws IllegalArgumentException { validateOrganizationArgs(); if (!User.isOrg()) { mLiveAuthClient.logout(new LiveAuthListener() { @Override public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) { mAuthenticationManager.connect(SignInActivity.this); } @Override public void onAuthError(LiveAuthException exception, Object userState) { mAuthenticationManager.connect(SignInActivity.this); } }); } else { mAuthenticationManager.connect(this); } } private void validateOrganizationArgs() throws IllegalArgumentException {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin; private void warnBadClient() { Toast.makeText(this, R.string.warning_clientid_redirecturi_incorrect, Toast.LENGTH_LONG) .show(); } private void authenticateOrganization() throws IllegalArgumentException { validateOrganizationArgs(); if (!User.isOrg()) { mLiveAuthClient.logout(new LiveAuthListener() { @Override public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) { mAuthenticationManager.connect(SignInActivity.this); } @Override public void onAuthError(LiveAuthException exception, Object userState) { mAuthenticationManager.connect(SignInActivity.this); } }); } else { mAuthenticationManager.connect(this); } } private void validateOrganizationArgs() throws IllegalArgumentException {
UUID.fromString(ServiceConstants.CLIENT_ID);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // }
import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin;
} private void validateOrganizationArgs() throws IllegalArgumentException { UUID.fromString(ServiceConstants.CLIENT_ID); URI.create(ServiceConstants.REDIRECT_URI); } @OnClick(msa_signin) public void onSignInMsaClicked() { authenticateMsa(); } private void authenticateMsa() { try { validateMsaArgs(); mLiveAuthClient.login(this, sSCOPES, this); } catch (IllegalArgumentException e) { warnBadClient(); } } private void validateMsaArgs() throws IllegalArgumentException { if (ServiceConstants.MSA_CLIENT_ID.equals("<Your MSA CLIENT ID>")) { throw new IllegalArgumentException(); } } @Override public void onSuccess(AuthenticationResult authenticationResult) { finish();
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java // public class ServiceConstants { // // // MSA // public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>"; // public static final String ONENOTE_API = "https://www.onenote.com/api"; // // Org // public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com"; // public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; // public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>"; // public static final String CLIENT_ID = "<Your CLIENT ID HERE>"; // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java // public class SharedPrefsUtil { // // public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN"; // // public static SharedPreferences getSharedPreferences() { // return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE); // } // // public static void persistAuthToken(AuthenticationResult result) { // setAccessToken(result.getAccessToken()); // User.isOrg(true); // } // // public static void persistAuthToken(LiveConnectSession session) { // setAccessToken(session.getAccessToken()); // User.isMsa(true); // } // // private static void setAccessToken(String accessToken) { // getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit(); // } // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java // public class User { // // private static final String PREF_MSA = "PREF_MSA"; // private static final String PREF_ORG = "PREF_ORG"; // // static void isMsa(boolean msa) { // set(PREF_MSA, msa); // } // // static void isOrg(boolean org) { // set(PREF_ORG, org); // } // // public static boolean isMsa() { // return is(PREF_MSA); // } // // public static boolean isOrg() { // return is(PREF_ORG); // } // // private static boolean is(String which) { // return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false); // } // // private static void set(String which, boolean state) { // SharedPrefsUtil // .getSharedPreferences() // .edit() // .putBoolean(which, state) // .commit(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java import android.content.Intent; import android.os.Bundle; import android.widget.Toast; import com.microsoft.aad.adal.AuthenticationCallback; import com.microsoft.aad.adal.AuthenticationResult; import com.microsoft.live.LiveAuthException; import com.microsoft.live.LiveAuthListener; import com.microsoft.live.LiveConnectSession; import com.microsoft.live.LiveStatus; import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants; import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil; import com.microsoft.o365_android_onenote_rest.util.User; import java.net.URI; import java.util.UUID; import butterknife.ButterKnife; import butterknife.OnClick; import timber.log.Timber; import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin; import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin; } private void validateOrganizationArgs() throws IllegalArgumentException { UUID.fromString(ServiceConstants.CLIENT_ID); URI.create(ServiceConstants.REDIRECT_URI); } @OnClick(msa_signin) public void onSignInMsaClicked() { authenticateMsa(); } private void authenticateMsa() { try { validateMsaArgs(); mLiveAuthClient.login(this, sSCOPES, this); } catch (IllegalArgumentException e) { warnBadClient(); } } private void validateMsaArgs() throws IllegalArgumentException { if (ServiceConstants.MSA_CLIENT_ID.equals("<Your MSA CLIENT ID>")) { throw new IllegalArgumentException(); } } @Override public void onSuccess(AuthenticationResult authenticationResult) { finish();
SharedPrefsUtil.persistAuthToken(authenticationResult);
OneNoteDev/Android-REST-API-Explorer
onenoteapi/src/main/java/com/microsoft/onenoteapi/service/PagesService.java
// Path: onenotevos/src/main/java/com/microsoft/onenotevos/Page.java // public class Page extends BaseVO { // public String title; // public String contentUrl; // }
import com.microsoft.onenotevos.Envelope; import com.microsoft.onenotevos.Page; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.Body; import retrofit.http.DELETE; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.Multipart; import retrofit.http.PATCH; import retrofit.http.POST; import retrofit.http.PartMap; import retrofit.http.Path; import retrofit.http.Query; import retrofit.mime.TypedString;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.onenoteapi.service; public interface PagesService { /** * Gets the collection of a users OneNote pages * Allows for query parameters to filter, order, sort... etc * * @param filter * @param order * @param select * @param top * @param skip * @param search * @param callback */ @GET("/{version}/me/notes/pages") void getPages( @Path("version") String version, @Query("filter") String filter, @Query("orderby") String order, @Query("select") String select, @Query("top") Integer top, @Query("skip") Integer skip, @Query("search") String search,
// Path: onenotevos/src/main/java/com/microsoft/onenotevos/Page.java // public class Page extends BaseVO { // public String title; // public String contentUrl; // } // Path: onenoteapi/src/main/java/com/microsoft/onenoteapi/service/PagesService.java import com.microsoft.onenotevos.Envelope; import com.microsoft.onenotevos.Page; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.Body; import retrofit.http.DELETE; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.Multipart; import retrofit.http.PATCH; import retrofit.http.POST; import retrofit.http.PartMap; import retrofit.http.Path; import retrofit.http.Query; import retrofit.mime.TypedString; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.onenoteapi.service; public interface PagesService { /** * Gets the collection of a users OneNote pages * Allows for query parameters to filter, order, sort... etc * * @param filter * @param order * @param select * @param top * @param skip * @param search * @param callback */ @GET("/{version}/me/notes/pages") void getPages( @Path("version") String version, @Query("filter") String filter, @Query("orderby") String order, @Query("select") String select, @Query("top") Integer top, @Query("skip") Integer skip, @Query("search") String search,
Callback<Envelope<Page>> callback
OneNoteDev/Android-REST-API-Explorer
onenoteapi/src/main/java/com/microsoft/onenoteapi/service/SectionsService.java
// Path: onenotevos/src/main/java/com/microsoft/onenotevos/Section.java // public class Section extends BaseVO { // // public String pagesUrl; // public Notebook parentNotebook; // public SectionGroup parentSectionGroup; // // @SerializedName("parentSectionGroup@odata.context") // public String parentSectionGroup_odata_context; // // @SerializedName("parentNotebook@odata.context") // public String parentNotebook_odata_context; // // }
import com.microsoft.onenotevos.Envelope; import com.microsoft.onenotevos.Section; import retrofit.Callback; import retrofit.http.Body; import retrofit.http.DELETE; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.POST; import retrofit.http.Path; import retrofit.http.Query; import retrofit.mime.TypedString;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.onenoteapi.service; public interface SectionsService { /** * Performs GET requests against the sections resource. * * @param filter * @param order * @param select * @param top * @param skip * @param search * @param callback */ @GET("/{version}/me/notes/sections") void getSections( @Path("version") String version, @Query("filter") String filter, @Query("orderby") String order, @Query("select") String select, @Query("top") Integer top, @Query("skip") Integer skip, @Query("search") String search,
// Path: onenotevos/src/main/java/com/microsoft/onenotevos/Section.java // public class Section extends BaseVO { // // public String pagesUrl; // public Notebook parentNotebook; // public SectionGroup parentSectionGroup; // // @SerializedName("parentSectionGroup@odata.context") // public String parentSectionGroup_odata_context; // // @SerializedName("parentNotebook@odata.context") // public String parentNotebook_odata_context; // // } // Path: onenoteapi/src/main/java/com/microsoft/onenoteapi/service/SectionsService.java import com.microsoft.onenotevos.Envelope; import com.microsoft.onenotevos.Section; import retrofit.Callback; import retrofit.http.Body; import retrofit.http.DELETE; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.POST; import retrofit.http.Path; import retrofit.http.Query; import retrofit.mime.TypedString; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.onenoteapi.service; public interface SectionsService { /** * Performs GET requests against the sections resource. * * @param filter * @param order * @param select * @param top * @param skip * @param search * @param callback */ @GET("/{version}/me/notes/sections") void getSections( @Path("version") String version, @Query("filter") String filter, @Query("orderby") String order, @Query("select") String select, @Query("top") Integer top, @Query("skip") Integer skip, @Query("search") String search,
Callback<Envelope<Section>> callback
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/model/Scope.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // }
import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import static com.microsoft.o365_android_onenote_rest.R.string.on_base; import static com.microsoft.o365_android_onenote_rest.R.string.on_create; import static com.microsoft.o365_android_onenote_rest.R.string.on_update; import static com.microsoft.o365_android_onenote_rest.R.string.wl_offline_access; import static com.microsoft.o365_android_onenote_rest.R.string.wl_signin;
} @Override public String toString() { return getScope() + DELIM + mDescription; } } public enum office { onenote_create(on_create), onenote_update(on_update), onenote(on_base); public final String mDescription; office(int desc) { mDescription = getString(desc); } public String getScope() { return "office." + name(); } @Override public String toString() { return getScope() + DELIM + mDescription; } } private static String getString(int res) {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java // public class SnippetApp extends Application { // /** // * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations // * // * @see javax.inject.Inject // * @see dagger.Provides // * @see javax.inject.Singleton // */ // public ObjectGraph mObjectGraph; // // private static SnippetApp sSnippetApp; // // @Inject // protected String endpoint; // // @Inject // protected Converter converter; // // @Inject // protected RestAdapter.LogLevel logLevel; // // @Inject // protected RequestInterceptor requestInterceptor; // // @Override // public void onCreate() { // super.onCreate(); // sSnippetApp = this; // mObjectGraph = ObjectGraph.create(new AppModule()); // mObjectGraph.inject(this); // if (BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } // } // // public static SnippetApp getApp() { // return sSnippetApp; // } // // public RestAdapter getRestAdapter() { // return new RestAdapter.Builder() // .setEndpoint(endpoint) // .setLogLevel(logLevel) // .setConverter(converter) // .setRequestInterceptor(requestInterceptor) // .build(); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/model/Scope.java import com.microsoft.o365_android_onenote_rest.application.SnippetApp; import static com.microsoft.o365_android_onenote_rest.R.string.on_base; import static com.microsoft.o365_android_onenote_rest.R.string.on_create; import static com.microsoft.o365_android_onenote_rest.R.string.on_update; import static com.microsoft.o365_android_onenote_rest.R.string.wl_offline_access; import static com.microsoft.o365_android_onenote_rest.R.string.wl_signin; } @Override public String toString() { return getScope() + DELIM + mDescription; } } public enum office { onenote_create(on_create), onenote_update(on_update), onenote(on_base); public final String mDescription; office(int desc) { mDescription = getString(desc); } public String getScope() { return "office." + name(); } @Override public String toString() { return getScope() + DELIM + mDescription; } } private static String getString(int res) {
return SnippetApp.getApp().getString(res);
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // }
import android.app.Application; import com.microsoft.o365_android_onenote_rest.BuildConfig; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import javax.inject.Inject; import dagger.ObjectGraph; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import timber.log.Timber;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.application; public class SnippetApp extends Application { /** * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations * * @see javax.inject.Inject * @see dagger.Provides * @see javax.inject.Singleton */ public ObjectGraph mObjectGraph; private static SnippetApp sSnippetApp; @Inject protected String endpoint; @Inject protected Converter converter; @Inject protected RestAdapter.LogLevel logLevel; @Inject protected RequestInterceptor requestInterceptor; @Override public void onCreate() { super.onCreate(); sSnippetApp = this;
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/inject/AppModule.java // @Module(library = true, // injects = { // SnippetApp.class // } // ) // public class AppModule { // // public static final String PREFS = "com.microsoft.o365_android_onenote_rest"; // // @Provides // public String providesRestEndpoint() { // return ServiceConstants.ONENOTE_API; // } // // @Provides // public RestAdapter.LogLevel providesLogLevel() { // return RestAdapter.LogLevel.FULL; // } // // @Provides // public Converter providesConverter() { // return new GsonConverter(GsonDateTime.getOneNoteBuilder() // .create()); // } // // @Provides // public RequestInterceptor providesRequestInterceptor() { // return new RequestInterceptor() { // @Override // public void intercept(RequestFacade request) { // // apply the Authorization header if we had a token... // final SharedPreferences preferences // = SnippetApp.getApp().getSharedPreferences(PREFS, Context.MODE_PRIVATE); // final String token = // preferences.getString(SharedPrefsUtil.PREF_AUTH_TOKEN, null); // if (null != token) { // request.addHeader("Authorization", "Bearer " + token); // } // } // }; // } // // @Provides // @Singleton // public LiveAuthClient providesLiveAuthClient() { // return new LiveAuthClient(SnippetApp.getApp(), ServiceConstants.MSA_CLIENT_ID); // } // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/application/SnippetApp.java import android.app.Application; import com.microsoft.o365_android_onenote_rest.BuildConfig; import com.microsoft.o365_android_onenote_rest.inject.AppModule; import javax.inject.Inject; import dagger.ObjectGraph; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.Converter; import timber.log.Timber; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest.application; public class SnippetApp extends Application { /** * The {@link dagger.ObjectGraph} used by Dagger to fulfill <code>@inject</code> annotations * * @see javax.inject.Inject * @see dagger.Provides * @see javax.inject.Singleton */ public ObjectGraph mObjectGraph; private static SnippetApp sSnippetApp; @Inject protected String endpoint; @Inject protected Converter converter; @Inject protected RestAdapter.LogLevel logLevel; @Inject protected RequestInterceptor requestInterceptor; @Override public void onCreate() { super.onCreate(); sSnippetApp = this;
mObjectGraph = ObjectGraph.create(new AppModule());
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListAdapter.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/AbstractSnippet.java // public abstract class AbstractSnippet<Service, Result> { // // public static final Services sServices = new Services(); // // private String mName, mDesc, mSection, mUrl, mO365Version, mMSAVersion; // public final Service mService; // public final Input mInputArgs; // // private static final int sNameIndex = 0; // private static final int sDescIndex = 1; // private static final int sUrlIndex = 2; // private static final int sO365VersionIndex = 3; // private static final int sMSAVersionIndex = 4; // // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mService = category.mService; // mInputArgs = Input.None; // } // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // * @param inputArgs any input arguments // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray, // Input inputArgs) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mSection = category.mSection; // mService = category.mService; // mInputArgs = inputArgs; // } // // /** // * Gets the items from the specified snippet XML string array and stores the values // * in private class fields // * // * @param category // * @param descriptionArray // */ // private void getSnippetArrayContent(SnippetCategory<Service> category, Integer descriptionArray) { // if (null != descriptionArray) { // String[] params = SnippetApp.getApp().getResources().getStringArray(descriptionArray); // // try { // mName = params[sNameIndex]; // mDesc = params[sDescIndex]; // mUrl = params[sUrlIndex]; // mO365Version = params[sO365VersionIndex]; // mMSAVersion = params[sMSAVersionIndex]; // } catch (IndexOutOfBoundsException ex) { // throw new RuntimeException( // "Invalid array in " // + category.mSection // + " snippet XML file" // , ex); // } // } else { // mName = category.mSection; // mDesc = mUrl = null; // mO365Version = null; // mMSAVersion = null; // } // mSection = category.mSection; // } // // protected static class Services { // // public final NotebooksService mNotebooksService; // public final PagesService mPagesService; // public final SectionGroupsService mSectionGroupsService; // public final SectionsService mSectionsService; // // Services() { // mNotebooksService = notebookSnippetCategory.mService; // mPagesService = pagesSnippetCategory.mService; // mSectionGroupsService = sectionGroupsSnippetCategory.mService; // mSectionsService = sectionsSnippetCategory.mService; // } // } // // @SuppressWarnings("unused") // public void setUp(Services services, retrofit.Callback<String[]> callback) { // // Optional method.... // callback.success(new String[]{}, null); // } // // /** // * Returns the version segment of the endpoint url with input from // * XML snippet description and authentication method (Office 365, MSA) // * // * @return the version of the endpoint to use // */ // public String getVersion() { // return User.isMsa() ? mMSAVersion : mO365Version; // } // // // public String getName() { // return mName; // } // // public String getDescription() { // return mDesc; // } // // public String getUrl() { // return mUrl; // } // // public String getSection() { // return mSection; // } // // /** // * Abstract declaration of method which subclasses must define to actually run the snippet // * // * @param service the service instance to use // * @param callback the recipient of the result // */ // public abstract void request(Service service, Callback<Result> callback); // // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/SnippetContent.java // public class SnippetContent { // // public static List<AbstractSnippet<?, ?>> ITEMS = new ArrayList<>(); // // static { // AbstractSnippet<?, ?>[][] baseSnippets = new AbstractSnippet<?, ?>[][]{ // getNotebookSnippets(), // getPagesSnippets(), // getSectionGroupsSnippets(), // getSectionsServiceSnippets() // }; // // for (AbstractSnippet<?, ?>[] snippetArray : baseSnippets) { // Collections.addAll(ITEMS, snippetArray); // } // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.microsoft.o365_android_onenote_rest.snippet.AbstractSnippet; import com.microsoft.o365_android_onenote_rest.snippet.SnippetContent;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SnippetListAdapter extends BaseAdapter { public static final String UNAVAILABLE = "unavailable"; public static final String BETA = "beta"; private Context mContext; private LayoutInflater mLayoutInflater; @Override public int getCount() {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/AbstractSnippet.java // public abstract class AbstractSnippet<Service, Result> { // // public static final Services sServices = new Services(); // // private String mName, mDesc, mSection, mUrl, mO365Version, mMSAVersion; // public final Service mService; // public final Input mInputArgs; // // private static final int sNameIndex = 0; // private static final int sDescIndex = 1; // private static final int sUrlIndex = 2; // private static final int sO365VersionIndex = 3; // private static final int sMSAVersionIndex = 4; // // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mService = category.mService; // mInputArgs = Input.None; // } // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // * @param inputArgs any input arguments // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray, // Input inputArgs) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mSection = category.mSection; // mService = category.mService; // mInputArgs = inputArgs; // } // // /** // * Gets the items from the specified snippet XML string array and stores the values // * in private class fields // * // * @param category // * @param descriptionArray // */ // private void getSnippetArrayContent(SnippetCategory<Service> category, Integer descriptionArray) { // if (null != descriptionArray) { // String[] params = SnippetApp.getApp().getResources().getStringArray(descriptionArray); // // try { // mName = params[sNameIndex]; // mDesc = params[sDescIndex]; // mUrl = params[sUrlIndex]; // mO365Version = params[sO365VersionIndex]; // mMSAVersion = params[sMSAVersionIndex]; // } catch (IndexOutOfBoundsException ex) { // throw new RuntimeException( // "Invalid array in " // + category.mSection // + " snippet XML file" // , ex); // } // } else { // mName = category.mSection; // mDesc = mUrl = null; // mO365Version = null; // mMSAVersion = null; // } // mSection = category.mSection; // } // // protected static class Services { // // public final NotebooksService mNotebooksService; // public final PagesService mPagesService; // public final SectionGroupsService mSectionGroupsService; // public final SectionsService mSectionsService; // // Services() { // mNotebooksService = notebookSnippetCategory.mService; // mPagesService = pagesSnippetCategory.mService; // mSectionGroupsService = sectionGroupsSnippetCategory.mService; // mSectionsService = sectionsSnippetCategory.mService; // } // } // // @SuppressWarnings("unused") // public void setUp(Services services, retrofit.Callback<String[]> callback) { // // Optional method.... // callback.success(new String[]{}, null); // } // // /** // * Returns the version segment of the endpoint url with input from // * XML snippet description and authentication method (Office 365, MSA) // * // * @return the version of the endpoint to use // */ // public String getVersion() { // return User.isMsa() ? mMSAVersion : mO365Version; // } // // // public String getName() { // return mName; // } // // public String getDescription() { // return mDesc; // } // // public String getUrl() { // return mUrl; // } // // public String getSection() { // return mSection; // } // // /** // * Abstract declaration of method which subclasses must define to actually run the snippet // * // * @param service the service instance to use // * @param callback the recipient of the result // */ // public abstract void request(Service service, Callback<Result> callback); // // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/SnippetContent.java // public class SnippetContent { // // public static List<AbstractSnippet<?, ?>> ITEMS = new ArrayList<>(); // // static { // AbstractSnippet<?, ?>[][] baseSnippets = new AbstractSnippet<?, ?>[][]{ // getNotebookSnippets(), // getPagesSnippets(), // getSectionGroupsSnippets(), // getSectionsServiceSnippets() // }; // // for (AbstractSnippet<?, ?>[] snippetArray : baseSnippets) { // Collections.addAll(ITEMS, snippetArray); // } // } // // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.microsoft.o365_android_onenote_rest.snippet.AbstractSnippet; import com.microsoft.o365_android_onenote_rest.snippet.SnippetContent; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SnippetListAdapter extends BaseAdapter { public static final String UNAVAILABLE = "unavailable"; public static final String BETA = "beta"; private Context mContext; private LayoutInflater mLayoutInflater; @Override public int getCount() {
return SnippetContent.ITEMS.size();
OneNoteDev/Android-REST-API-Explorer
app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListAdapter.java
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/AbstractSnippet.java // public abstract class AbstractSnippet<Service, Result> { // // public static final Services sServices = new Services(); // // private String mName, mDesc, mSection, mUrl, mO365Version, mMSAVersion; // public final Service mService; // public final Input mInputArgs; // // private static final int sNameIndex = 0; // private static final int sDescIndex = 1; // private static final int sUrlIndex = 2; // private static final int sO365VersionIndex = 3; // private static final int sMSAVersionIndex = 4; // // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mService = category.mService; // mInputArgs = Input.None; // } // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // * @param inputArgs any input arguments // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray, // Input inputArgs) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mSection = category.mSection; // mService = category.mService; // mInputArgs = inputArgs; // } // // /** // * Gets the items from the specified snippet XML string array and stores the values // * in private class fields // * // * @param category // * @param descriptionArray // */ // private void getSnippetArrayContent(SnippetCategory<Service> category, Integer descriptionArray) { // if (null != descriptionArray) { // String[] params = SnippetApp.getApp().getResources().getStringArray(descriptionArray); // // try { // mName = params[sNameIndex]; // mDesc = params[sDescIndex]; // mUrl = params[sUrlIndex]; // mO365Version = params[sO365VersionIndex]; // mMSAVersion = params[sMSAVersionIndex]; // } catch (IndexOutOfBoundsException ex) { // throw new RuntimeException( // "Invalid array in " // + category.mSection // + " snippet XML file" // , ex); // } // } else { // mName = category.mSection; // mDesc = mUrl = null; // mO365Version = null; // mMSAVersion = null; // } // mSection = category.mSection; // } // // protected static class Services { // // public final NotebooksService mNotebooksService; // public final PagesService mPagesService; // public final SectionGroupsService mSectionGroupsService; // public final SectionsService mSectionsService; // // Services() { // mNotebooksService = notebookSnippetCategory.mService; // mPagesService = pagesSnippetCategory.mService; // mSectionGroupsService = sectionGroupsSnippetCategory.mService; // mSectionsService = sectionsSnippetCategory.mService; // } // } // // @SuppressWarnings("unused") // public void setUp(Services services, retrofit.Callback<String[]> callback) { // // Optional method.... // callback.success(new String[]{}, null); // } // // /** // * Returns the version segment of the endpoint url with input from // * XML snippet description and authentication method (Office 365, MSA) // * // * @return the version of the endpoint to use // */ // public String getVersion() { // return User.isMsa() ? mMSAVersion : mO365Version; // } // // // public String getName() { // return mName; // } // // public String getDescription() { // return mDesc; // } // // public String getUrl() { // return mUrl; // } // // public String getSection() { // return mSection; // } // // /** // * Abstract declaration of method which subclasses must define to actually run the snippet // * // * @param service the service instance to use // * @param callback the recipient of the result // */ // public abstract void request(Service service, Callback<Result> callback); // // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/SnippetContent.java // public class SnippetContent { // // public static List<AbstractSnippet<?, ?>> ITEMS = new ArrayList<>(); // // static { // AbstractSnippet<?, ?>[][] baseSnippets = new AbstractSnippet<?, ?>[][]{ // getNotebookSnippets(), // getPagesSnippets(), // getSectionGroupsSnippets(), // getSectionsServiceSnippets() // }; // // for (AbstractSnippet<?, ?>[] snippetArray : baseSnippets) { // Collections.addAll(ITEMS, snippetArray); // } // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.microsoft.o365_android_onenote_rest.snippet.AbstractSnippet; import com.microsoft.o365_android_onenote_rest.snippet.SnippetContent;
/* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SnippetListAdapter extends BaseAdapter { public static final String UNAVAILABLE = "unavailable"; public static final String BETA = "beta"; private Context mContext; private LayoutInflater mLayoutInflater; @Override public int getCount() { return SnippetContent.ITEMS.size(); } @Override
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/AbstractSnippet.java // public abstract class AbstractSnippet<Service, Result> { // // public static final Services sServices = new Services(); // // private String mName, mDesc, mSection, mUrl, mO365Version, mMSAVersion; // public final Service mService; // public final Input mInputArgs; // // private static final int sNameIndex = 0; // private static final int sDescIndex = 1; // private static final int sUrlIndex = 2; // private static final int sO365VersionIndex = 3; // private static final int sMSAVersionIndex = 4; // // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mService = category.mService; // mInputArgs = Input.None; // } // // /** // * Snippet constructor // * // * @param category Snippet category (Notebook, sectionGroup, section, page) // * @param descriptionArray The String array for the specified snippet // * @param inputArgs any input arguments // */ // public AbstractSnippet( // SnippetCategory<Service> category, // Integer descriptionArray, // Input inputArgs) { // // //Get snippet configuration information from the // //XML configuration for the snippet // getSnippetArrayContent(category, descriptionArray); // // mSection = category.mSection; // mService = category.mService; // mInputArgs = inputArgs; // } // // /** // * Gets the items from the specified snippet XML string array and stores the values // * in private class fields // * // * @param category // * @param descriptionArray // */ // private void getSnippetArrayContent(SnippetCategory<Service> category, Integer descriptionArray) { // if (null != descriptionArray) { // String[] params = SnippetApp.getApp().getResources().getStringArray(descriptionArray); // // try { // mName = params[sNameIndex]; // mDesc = params[sDescIndex]; // mUrl = params[sUrlIndex]; // mO365Version = params[sO365VersionIndex]; // mMSAVersion = params[sMSAVersionIndex]; // } catch (IndexOutOfBoundsException ex) { // throw new RuntimeException( // "Invalid array in " // + category.mSection // + " snippet XML file" // , ex); // } // } else { // mName = category.mSection; // mDesc = mUrl = null; // mO365Version = null; // mMSAVersion = null; // } // mSection = category.mSection; // } // // protected static class Services { // // public final NotebooksService mNotebooksService; // public final PagesService mPagesService; // public final SectionGroupsService mSectionGroupsService; // public final SectionsService mSectionsService; // // Services() { // mNotebooksService = notebookSnippetCategory.mService; // mPagesService = pagesSnippetCategory.mService; // mSectionGroupsService = sectionGroupsSnippetCategory.mService; // mSectionsService = sectionsSnippetCategory.mService; // } // } // // @SuppressWarnings("unused") // public void setUp(Services services, retrofit.Callback<String[]> callback) { // // Optional method.... // callback.success(new String[]{}, null); // } // // /** // * Returns the version segment of the endpoint url with input from // * XML snippet description and authentication method (Office 365, MSA) // * // * @return the version of the endpoint to use // */ // public String getVersion() { // return User.isMsa() ? mMSAVersion : mO365Version; // } // // // public String getName() { // return mName; // } // // public String getDescription() { // return mDesc; // } // // public String getUrl() { // return mUrl; // } // // public String getSection() { // return mSection; // } // // /** // * Abstract declaration of method which subclasses must define to actually run the snippet // * // * @param service the service instance to use // * @param callback the recipient of the result // */ // public abstract void request(Service service, Callback<Result> callback); // // } // // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/snippet/SnippetContent.java // public class SnippetContent { // // public static List<AbstractSnippet<?, ?>> ITEMS = new ArrayList<>(); // // static { // AbstractSnippet<?, ?>[][] baseSnippets = new AbstractSnippet<?, ?>[][]{ // getNotebookSnippets(), // getPagesSnippets(), // getSectionGroupsSnippets(), // getSectionsServiceSnippets() // }; // // for (AbstractSnippet<?, ?>[] snippetArray : baseSnippets) { // Collections.addAll(ITEMS, snippetArray); // } // } // // } // Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SnippetListAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.microsoft.o365_android_onenote_rest.snippet.AbstractSnippet; import com.microsoft.o365_android_onenote_rest.snippet.SnippetContent; /* * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. */ package com.microsoft.o365_android_onenote_rest; public class SnippetListAdapter extends BaseAdapter { public static final String UNAVAILABLE = "unavailable"; public static final String BETA = "beta"; private Context mContext; private LayoutInflater mLayoutInflater; @Override public int getCount() { return SnippetContent.ITEMS.size(); } @Override
public AbstractSnippet<?, ?> getItem(int position) {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/fragments/base/BaseFragment.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/IInjectable.java // public interface IInjectable { // // /** // * Called when object is ready to be injected. // */ // void onInject(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/base/ViewModel.java // public abstract class ViewModel { // // @Nullable // private CompositeSubscription mSubscriptions; // // /** // * Cleans up the view model // */ // public void dispose() { // unsubscribeFromDataStore(); // } // // /** // * Cleans up current subscriptions and subscribes to new events. // */ // public void subscribeToDataStore() { // unsubscribeFromDataStore(); // mSubscriptions = new CompositeSubscription(); // subscribeToData(mSubscriptions); // } // // private void unsubscribeFromDataStore() { // if (mSubscriptions != null) { // mSubscriptions.clear(); // mSubscriptions = null; // } // } // // /** // * Provides {@link CompositeSubscription} that all bindings should be registered to. // * // * @param subscription that holds the {@link Subscription}s created by view model // */ // protected abstract void subscribeToData(@NonNull final CompositeSubscription subscription); // }
import com.lucilu.rxdynamicsearch.IInjectable; import com.lucilu.rxdynamicsearch.viewmodel.base.ViewModel; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import rx.subscriptions.CompositeSubscription;
package com.lucilu.rxdynamicsearch.fragments.base; /** * This base fragment provides the common functionality to all fragments in the app. */ public abstract class BaseFragment extends Fragment implements IInjectable { @NonNull private final CompositeSubscription mSubscription = new CompositeSubscription(); @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); onInject(); getViewModel().subscribeToDataStore(); } @Override public void onResume() { super.onResume(); onBind(mSubscription); } @Override public void onPause() { mSubscription.clear(); super.onPause(); } @Override public void onDestroyView() { getViewModel().dispose(); super.onDestroyView(); } protected abstract void onBind(@NonNull final CompositeSubscription subscription); @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/IInjectable.java // public interface IInjectable { // // /** // * Called when object is ready to be injected. // */ // void onInject(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/base/ViewModel.java // public abstract class ViewModel { // // @Nullable // private CompositeSubscription mSubscriptions; // // /** // * Cleans up the view model // */ // public void dispose() { // unsubscribeFromDataStore(); // } // // /** // * Cleans up current subscriptions and subscribes to new events. // */ // public void subscribeToDataStore() { // unsubscribeFromDataStore(); // mSubscriptions = new CompositeSubscription(); // subscribeToData(mSubscriptions); // } // // private void unsubscribeFromDataStore() { // if (mSubscriptions != null) { // mSubscriptions.clear(); // mSubscriptions = null; // } // } // // /** // * Provides {@link CompositeSubscription} that all bindings should be registered to. // * // * @param subscription that holds the {@link Subscription}s created by view model // */ // protected abstract void subscribeToData(@NonNull final CompositeSubscription subscription); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/fragments/base/BaseFragment.java import com.lucilu.rxdynamicsearch.IInjectable; import com.lucilu.rxdynamicsearch.viewmodel.base.ViewModel; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import rx.subscriptions.CompositeSubscription; package com.lucilu.rxdynamicsearch.fragments.base; /** * This base fragment provides the common functionality to all fragments in the app. */ public abstract class BaseFragment extends Fragment implements IInjectable { @NonNull private final CompositeSubscription mSubscription = new CompositeSubscription(); @Override public void onActivityCreated(@Nullable final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); onInject(); getViewModel().subscribeToDataStore(); } @Override public void onResume() { super.onResume(); onBind(mSubscription); } @Override public void onPause() { mSubscription.clear(); super.onPause(); } @Override public void onDestroyView() { getViewModel().dispose(); super.onDestroyView(); } protected abstract void onBind(@NonNull final CompositeSubscription subscription); @NonNull
protected abstract ViewModel getViewModel();
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/ViewUtils.java // public final class ViewUtils { // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final Activity activity, int id) { // checkNotNull(activity, "The activity cannot be null"); // // return (T) get(activity.findViewById(id)); // } // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final View view, int id) { // return (T) get(view.findViewById(id)); // } // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.utils.ViewUtils; import android.support.annotation.NonNull; import android.view.View; import android.widget.TextView;
package com.lucilu.rxdynamicsearch.ui.adapter.viewholder; public final class CountryViewHolder extends SimpleViewHolder<Country> { @NonNull private final TextView mCountryName; @NonNull private final TextView mCapital; public CountryViewHolder(@NonNull final View itemView) { super(itemView);
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/ViewUtils.java // public final class ViewUtils { // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final Activity activity, int id) { // checkNotNull(activity, "The activity cannot be null"); // // return (T) get(activity.findViewById(id)); // } // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final View view, int id) { // return (T) get(view.findViewById(id)); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.utils.ViewUtils; import android.support.annotation.NonNull; import android.view.View; import android.widget.TextView; package com.lucilu.rxdynamicsearch.ui.adapter.viewholder; public final class CountryViewHolder extends SimpleViewHolder<Country> { @NonNull private final TextView mCountryName; @NonNull private final TextView mCapital; public CountryViewHolder(@NonNull final View itemView) { super(itemView);
mCountryName = ViewUtils.find(itemView, R.id.item_textView_country);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable
private MainActivityComponent mComponent;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() {
return get(mComponent);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() { return get(mComponent); } private MainActivityComponent createComponent() {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() { return get(mComponent); } private MainActivityComponent createComponent() {
SearchApplication app = (SearchApplication) getApplication();
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() { return get(mComponent); } private MainActivityComponent createComponent() { SearchApplication app = (SearchApplication) getApplication();
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java // public final class SearchApplication extends Application { // // @Inject // Timber.Tree mTimberTree; // // @Nullable // private AppComponent mComponent; // // @Override // public void onCreate() { // super.onCreate(); // // onInject(); // initializeLogging(); // } // // private void onInject() { // mComponent = AppComponent.Initializer.init(this); // mComponent.inject(this); // } // // private void initializeLogging() { // Timber.plant(mTimberTree); // } // // @NonNull // public AppComponent getAppComponent() { // return get(mComponent); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/base/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements IInjectable { // // @Override // protected void onCreate(@Nullable final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // onInject(); // } // // protected abstract void onBind(@NonNull final CompositeSubscription subscription); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/MainActivityComponent.java // @ActivityScope // @Subcomponent(modules = {ActivityModule.class, RepositoryModule.class}) // public interface MainActivityComponent { // // void inject(MainActivity activity); // // CountryListComponent plusSearchFragment(SearchFragmentModule module); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java // @Module // public final class ActivityModule { // // @NonNull // private final Activity mActivity; // // public ActivityModule(@NonNull final Activity activity) { // mActivity = get(activity); // } // // @ActivityScope // @Provides // Activity providesActivity() { // return mActivity; // } // // @ActivityScope // @ForActivity // @Provides // Context providesActivityContext() { // return mActivity; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/activities/MainActivity.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.SearchApplication; import com.lucilu.rxdynamicsearch.activities.base.BaseActivity; import com.lucilu.rxdynamicsearch.dagger.component.MainActivityComponent; import com.lucilu.rxdynamicsearch.dagger.module.ActivityModule; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import rx.subscriptions.CompositeSubscription; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.activities; public final class MainActivity extends BaseActivity { @Nullable private MainActivityComponent mComponent; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onBind(@NonNull final CompositeSubscription subscription) { // DO nothing (for now) } @Override public void onInject() { mComponent = createComponent(); mComponent.inject(this); } @NonNull public MainActivityComponent getComponent() { return get(mComponent); } private MainActivityComponent createComponent() { SearchApplication app = (SearchApplication) getApplication();
ActivityModule activityModule = new ActivityModule(this);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull
private final IJsonParserProvider mJsonParserProvider;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull private final IJsonParserProvider mJsonParserProvider; public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull private final IJsonParserProvider mJsonParserProvider; public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) {
mJsonParserProvider = get(jsonParserProvider);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull private final IJsonParserProvider mJsonParserProvider; public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { mJsonParserProvider = get(jsonParserProvider); } @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java // public final class Country { // // @NonNull // @SerializedName("name") // private final String mName; // // @NonNull // @SerializedName("capital") // private final String mCapital; // // @NonNull // @SerializedName("region") // private final String mRegion; // // public Country(@NonNull final String name, // @NonNull final String capital, // @NonNull final String region) { // mName = get(name); // mCapital = get(capital); // mRegion = get(region); // } // // @NonNull // public String getName() { // return mName; // } // // @NonNull // public String getCapital() { // return mCapital; // } // // @NonNull // public String getRegion() { // return mRegion; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final Country country = (Country) o; // // if (!mName.equals(country.mName)) { // return false; // } // if (!mCapital.equals(country.mCapital)) { // return false; // } // return mRegion.equals(country.mRegion); // // } // // @Override // public int hashCode() { // int result = mName.hashCode(); // result = 31 * result + mCapital.hashCode(); // result = 31 * result + mRegion.hashCode(); // return result; // } // // @Override // public String toString() { // return "Country{" + // "mName='" + mName + '\'' + // ", mCapital='" + mCapital + '\'' + // ", mRegion='" + mRegion + '\'' + // '}'; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Country; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import android.support.annotation.NonNull; import java.util.List; import polanski.option.Option; import rx.Observable; import rx.Subscriber; import rx.schedulers.Schedulers; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.repository; public class CountryRepository implements ICountryRepository { @NonNull private final IJsonParserProvider mJsonParserProvider; public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { mJsonParserProvider = get(jsonParserProvider); } @NonNull
public Observable<Option<List<Country>>> getAllCountries() {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/rx/transformer/ChooseTransformer.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/rx/utils/ObservableEx.java // public final class ObservableEx { // // private ObservableEx() { // } // // /** // * Filters NONE {@link Option} items that are converted by selector. // * // * @param observable to be filtered // * @param selector to convert value to {@link Option} // * @return Filtered observable // */ // @NonNull // public static <IN, OUT> Observable<OUT> choose(@NonNull final Observable<IN> observable, // @NonNull final Func1<IN, Option<OUT>> selector) { // return observable.map(selector) // .filter(Option::isSome) // .map(OptionUnsafe::getUnsafe); // } // // /** // * Filters NONE {@link Option} items that are converted by selector. // * // * @param observable to be filtered // * @return Filtered observable // */ // @NonNull // public static <T> Observable<T> choose(@NonNull final Observable<Option<T>> observable) { // return choose(observable, it -> it); // } // }
import com.lucilu.rxdynamicsearch.rx.utils.ObservableEx; import polanski.option.Option; import rx.Observable;
package com.lucilu.rxdynamicsearch.rx.transformer; /** * Filters out all Option of NONE if any, but if Some, then unwraps and returns the * value. */ public final class ChooseTransformer<T> implements Observable.Transformer<Option<T>, T> { @Override public Observable<T> call(final Observable<Option<T>> optionObservable) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/rx/utils/ObservableEx.java // public final class ObservableEx { // // private ObservableEx() { // } // // /** // * Filters NONE {@link Option} items that are converted by selector. // * // * @param observable to be filtered // * @param selector to convert value to {@link Option} // * @return Filtered observable // */ // @NonNull // public static <IN, OUT> Observable<OUT> choose(@NonNull final Observable<IN> observable, // @NonNull final Func1<IN, Option<OUT>> selector) { // return observable.map(selector) // .filter(Option::isSome) // .map(OptionUnsafe::getUnsafe); // } // // /** // * Filters NONE {@link Option} items that are converted by selector. // * // * @param observable to be filtered // * @return Filtered observable // */ // @NonNull // public static <T> Observable<T> choose(@NonNull final Observable<Option<T>> observable) { // return choose(observable, it -> it); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/rx/transformer/ChooseTransformer.java import com.lucilu.rxdynamicsearch.rx.utils.ObservableEx; import polanski.option.Option; import rx.Observable; package com.lucilu.rxdynamicsearch.rx.transformer; /** * Filters out all Option of NONE if any, but if Some, then unwraps and returns the * value. */ public final class ChooseTransformer<T> implements Observable.Transformer<Option<T>, T> { @Override public Observable<T> call(final Observable<Option<T>> optionObservable) {
return ObservableEx.choose(optionObservable);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // }
import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides
ICountryRepository provideCountryRepository(final IJsonParserProvider jsonParserProvider) {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // }
import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides
ICountryRepository provideCountryRepository(final IJsonParserProvider jsonParserProvider) {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // }
import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides ICountryRepository provideCountryRepository(final IJsonParserProvider jsonParserProvider) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/CountryRepository.java // public class CountryRepository implements ICountryRepository { // // @NonNull // private final IJsonParserProvider mJsonParserProvider; // // public CountryRepository(@NonNull final IJsonParserProvider jsonParserProvider) { // mJsonParserProvider = get(jsonParserProvider); // } // // @NonNull // public Observable<Option<List<Country>>> getAllCountries() { // return Observable.create(new Observable.OnSubscribe<Option<List<Country>>>() { // @Override // public void call(final Subscriber<? super Option<List<Country>>> subscriber) { // Option<List<Country>> // countries = mJsonParserProvider.parseListFromRawJsonFile(R.raw.countries, // Country.class); // // subscriber.onNext(countries); // subscriber.onCompleted(); // } // }).subscribeOn(Schedulers.computation()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/repository/base/ICountryRepository.java // public interface ICountryRepository { // // /** // * Gets all the countries. // * // * @return list with all the countries. // */ // @NonNull // Observable<Option<List<Country>>> getAllCountries(); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/RepositoryModule.java import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.repository.CountryRepository; import com.lucilu.rxdynamicsearch.repository.base.ICountryRepository; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class RepositoryModule { @Provides ICountryRepository provideCountryRepository(final IJsonParserProvider jsonParserProvider) {
return new CountryRepository(jsonParserProvider);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.google.gson.annotations.SerializedName; import android.support.annotation.NonNull; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.data.pojo; public final class Country { @NonNull @SerializedName("name") private final String mName; @NonNull @SerializedName("capital") private final String mCapital; @NonNull @SerializedName("region") private final String mRegion; public Country(@NonNull final String name, @NonNull final String capital, @NonNull final String region) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Country.java import com.google.gson.annotations.SerializedName; import android.support.annotation.NonNull; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.data.pojo; public final class Country { @NonNull @SerializedName("name") private final String mName; @NonNull @SerializedName("capital") private final String mCapital; @NonNull @SerializedName("region") private final String mRegion; public Country(@NonNull final String name, @NonNull final String capital, @NonNull final String region) {
mName = get(name);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListItemComparator.java // public final class CountryListItemComparator implements IListItemComparator { // // public boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // // public boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderBinder.java // public final class CountryListViewHolderBinder implements IViewHolderBinder<DisplayableItem> { // // public CountryListViewHolderBinder() { // } // // @Override // public void bind(@NonNull final ViewHolder viewHolder, // @NonNull final DisplayableItem displayableItem) { // switch (displayableItem.type()) { // case COUNTRY: // CountryViewHolder countryViewHolder = CountryViewHolder.class.cast(viewHolder); // Country country = Country.class.cast(displayableItem.model()); // countryViewHolder.bind(country); // break; // case AD: // AdViewHolder AdViewHolder = AdViewHolder.class.cast(viewHolder); // Ad ad = Ad.class.cast(displayableItem.model()); // AdViewHolder.bind(ad); // break; // default: // throw new IllegalStateException("The type is not supported " + displayableItem // .type()); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java // public final class CountryListViewHolderFactory implements IViewHolderFactory { // // @NonNull // private final Context mContext; // // public CountryListViewHolderFactory(@NonNull final Context context) { // mContext = context; // } // // @NonNull // @Override // public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { // switch (itemType) { // case COUNTRY: // return new CountryViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_country, parent, // false)); // case AD: // return new AdViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_ad, parent, false)); // default: // throw new IllegalStateException("Unknown type " + itemType); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderBinder.java // public interface IViewHolderBinder<T> { // // /** // * Populates the passed {@link ViewHolder} with the details of the passed model. // */ // void bind(@NonNull final ViewHolder viewHolder, @NonNull final T model); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // }
import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.content.Context; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class CountryListModule { @Provides
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListItemComparator.java // public final class CountryListItemComparator implements IListItemComparator { // // public boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // // public boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderBinder.java // public final class CountryListViewHolderBinder implements IViewHolderBinder<DisplayableItem> { // // public CountryListViewHolderBinder() { // } // // @Override // public void bind(@NonNull final ViewHolder viewHolder, // @NonNull final DisplayableItem displayableItem) { // switch (displayableItem.type()) { // case COUNTRY: // CountryViewHolder countryViewHolder = CountryViewHolder.class.cast(viewHolder); // Country country = Country.class.cast(displayableItem.model()); // countryViewHolder.bind(country); // break; // case AD: // AdViewHolder AdViewHolder = AdViewHolder.class.cast(viewHolder); // Ad ad = Ad.class.cast(displayableItem.model()); // AdViewHolder.bind(ad); // break; // default: // throw new IllegalStateException("The type is not supported " + displayableItem // .type()); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java // public final class CountryListViewHolderFactory implements IViewHolderFactory { // // @NonNull // private final Context mContext; // // public CountryListViewHolderFactory(@NonNull final Context context) { // mContext = context; // } // // @NonNull // @Override // public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { // switch (itemType) { // case COUNTRY: // return new CountryViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_country, parent, // false)); // case AD: // return new AdViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_ad, parent, false)); // default: // throw new IllegalStateException("Unknown type " + itemType); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderBinder.java // public interface IViewHolderBinder<T> { // // /** // * Populates the passed {@link ViewHolder} with the details of the passed model. // */ // void bind(@NonNull final ViewHolder viewHolder, @NonNull final T model); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.content.Context; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class CountryListModule { @Provides
IViewHolderFactory provideViewHolderFactory(@ForActivity Context context) {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListItemComparator.java // public final class CountryListItemComparator implements IListItemComparator { // // public boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // // public boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderBinder.java // public final class CountryListViewHolderBinder implements IViewHolderBinder<DisplayableItem> { // // public CountryListViewHolderBinder() { // } // // @Override // public void bind(@NonNull final ViewHolder viewHolder, // @NonNull final DisplayableItem displayableItem) { // switch (displayableItem.type()) { // case COUNTRY: // CountryViewHolder countryViewHolder = CountryViewHolder.class.cast(viewHolder); // Country country = Country.class.cast(displayableItem.model()); // countryViewHolder.bind(country); // break; // case AD: // AdViewHolder AdViewHolder = AdViewHolder.class.cast(viewHolder); // Ad ad = Ad.class.cast(displayableItem.model()); // AdViewHolder.bind(ad); // break; // default: // throw new IllegalStateException("The type is not supported " + displayableItem // .type()); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java // public final class CountryListViewHolderFactory implements IViewHolderFactory { // // @NonNull // private final Context mContext; // // public CountryListViewHolderFactory(@NonNull final Context context) { // mContext = context; // } // // @NonNull // @Override // public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { // switch (itemType) { // case COUNTRY: // return new CountryViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_country, parent, // false)); // case AD: // return new AdViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_ad, parent, false)); // default: // throw new IllegalStateException("Unknown type " + itemType); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderBinder.java // public interface IViewHolderBinder<T> { // // /** // * Populates the passed {@link ViewHolder} with the details of the passed model. // */ // void bind(@NonNull final ViewHolder viewHolder, @NonNull final T model); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // }
import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.content.Context; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class CountryListModule { @Provides IViewHolderFactory provideViewHolderFactory(@ForActivity Context context) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListItemComparator.java // public final class CountryListItemComparator implements IListItemComparator { // // public boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // // public boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2) { // return false; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderBinder.java // public final class CountryListViewHolderBinder implements IViewHolderBinder<DisplayableItem> { // // public CountryListViewHolderBinder() { // } // // @Override // public void bind(@NonNull final ViewHolder viewHolder, // @NonNull final DisplayableItem displayableItem) { // switch (displayableItem.type()) { // case COUNTRY: // CountryViewHolder countryViewHolder = CountryViewHolder.class.cast(viewHolder); // Country country = Country.class.cast(displayableItem.model()); // countryViewHolder.bind(country); // break; // case AD: // AdViewHolder AdViewHolder = AdViewHolder.class.cast(viewHolder); // Ad ad = Ad.class.cast(displayableItem.model()); // AdViewHolder.bind(ad); // break; // default: // throw new IllegalStateException("The type is not supported " + displayableItem // .type()); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java // public final class CountryListViewHolderFactory implements IViewHolderFactory { // // @NonNull // private final Context mContext; // // public CountryListViewHolderFactory(@NonNull final Context context) { // mContext = context; // } // // @NonNull // @Override // public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { // switch (itemType) { // case COUNTRY: // return new CountryViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_country, parent, // false)); // case AD: // return new AdViewHolder(LayoutInflater.from(mContext) // .inflate(R.layout.item_ad, parent, false)); // default: // throw new IllegalStateException("Unknown type " + itemType); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderBinder.java // public interface IViewHolderBinder<T> { // // /** // * Populates the passed {@link ViewHolder} with the details of the passed model. // */ // void bind(@NonNull final ViewHolder viewHolder, @NonNull final T model); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.CountryListViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderBinder; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.content.Context; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module public final class CountryListModule { @Provides IViewHolderFactory provideViewHolderFactory(@ForActivity Context context) {
return new CountryListViewHolderFactory(context);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/AppComponent.java // @Singleton // @Component(modules = {InstrumentationModule.class, AppModule.class, ProviderModule.class}) // public interface AppComponent { // // void inject(SearchApplication app); // // MainActivityComponent plusMainActivity(ActivityModule activityModule); // // class Initializer { // // private Initializer() { // throw new AssertionError("Do not create an instance!"); // } // // /** // * Creates the top level injection component. // * // * @param app application object // * @return component object // */ // public static AppComponent init(final SearchApplication app) { // return DaggerAppComponent.builder() // .appModule(new AppModule(app)) // .build(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.dagger.component.AppComponent; import android.app.Application; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch; public final class SearchApplication extends Application { @Inject Timber.Tree mTimberTree; @Nullable
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/AppComponent.java // @Singleton // @Component(modules = {InstrumentationModule.class, AppModule.class, ProviderModule.class}) // public interface AppComponent { // // void inject(SearchApplication app); // // MainActivityComponent plusMainActivity(ActivityModule activityModule); // // class Initializer { // // private Initializer() { // throw new AssertionError("Do not create an instance!"); // } // // /** // * Creates the top level injection component. // * // * @param app application object // * @return component object // */ // public static AppComponent init(final SearchApplication app) { // return DaggerAppComponent.builder() // .appModule(new AppModule(app)) // .build(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java import com.lucilu.rxdynamicsearch.dagger.component.AppComponent; import android.app.Application; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch; public final class SearchApplication extends Application { @Inject Timber.Tree mTimberTree; @Nullable
private AppComponent mComponent;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/AppComponent.java // @Singleton // @Component(modules = {InstrumentationModule.class, AppModule.class, ProviderModule.class}) // public interface AppComponent { // // void inject(SearchApplication app); // // MainActivityComponent plusMainActivity(ActivityModule activityModule); // // class Initializer { // // private Initializer() { // throw new AssertionError("Do not create an instance!"); // } // // /** // * Creates the top level injection component. // * // * @param app application object // * @return component object // */ // public static AppComponent init(final SearchApplication app) { // return DaggerAppComponent.builder() // .appModule(new AppModule(app)) // .build(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.dagger.component.AppComponent; import android.app.Application; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch; public final class SearchApplication extends Application { @Inject Timber.Tree mTimberTree; @Nullable private AppComponent mComponent; @Override public void onCreate() { super.onCreate(); onInject(); initializeLogging(); } private void onInject() { mComponent = AppComponent.Initializer.init(this); mComponent.inject(this); } private void initializeLogging() { Timber.plant(mTimberTree); } @NonNull public AppComponent getAppComponent() {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/AppComponent.java // @Singleton // @Component(modules = {InstrumentationModule.class, AppModule.class, ProviderModule.class}) // public interface AppComponent { // // void inject(SearchApplication app); // // MainActivityComponent plusMainActivity(ActivityModule activityModule); // // class Initializer { // // private Initializer() { // throw new AssertionError("Do not create an instance!"); // } // // /** // * Creates the top level injection component. // * // * @param app application object // * @return component object // */ // public static AppComponent init(final SearchApplication app) { // return DaggerAppComponent.builder() // .appModule(new AppModule(app)) // .build(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/SearchApplication.java import com.lucilu.rxdynamicsearch.dagger.component.AppComponent; import android.app.Application; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import javax.inject.Inject; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch; public final class SearchApplication extends Application { @Inject Timber.Tree mTimberTree; @Nullable private AppComponent mComponent; @Override public void onCreate() { super.onCreate(); onInject(); initializeLogging(); } private void onInject() { mComponent = AppComponent.Initializer.init(this); mComponent.inject(this); } private void initializeLogging() { Timber.plant(mTimberTree); } @NonNull public AppComponent getAppComponent() {
return get(mComponent);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Ad.java // @AutoValue // public abstract class Ad { // // public abstract String header(); // // public static Ad createAd(@NonNull final String header) { // return new AutoValue_Ad(header); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/ViewUtils.java // public final class ViewUtils { // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final Activity activity, int id) { // checkNotNull(activity, "The activity cannot be null"); // // return (T) get(activity.findViewById(id)); // } // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final View view, int id) { // return (T) get(view.findViewById(id)); // } // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Ad; import com.lucilu.rxdynamicsearch.utils.ViewUtils; import android.support.annotation.NonNull; import android.view.View; import android.widget.TextView;
package com.lucilu.rxdynamicsearch.ui.adapter.viewholder; public class AdViewHolder extends SimpleViewHolder<Ad> { @NonNull private final TextView headerTextView; public AdViewHolder(final View itemView) { super(itemView);
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/data/pojo/Ad.java // @AutoValue // public abstract class Ad { // // public abstract String header(); // // public static Ad createAd(@NonNull final String header) { // return new AutoValue_Ad(header); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/ViewUtils.java // public final class ViewUtils { // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final Activity activity, int id) { // checkNotNull(activity, "The activity cannot be null"); // // return (T) get(activity.findViewById(id)); // } // // @SuppressWarnings("unchecked") // @NonNull // public static <T extends View> T find(@NonNull final View view, int id) { // return (T) get(view.findViewById(id)); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.data.pojo.Ad; import com.lucilu.rxdynamicsearch.utils.ViewUtils; import android.support.annotation.NonNull; import android.view.View; import android.widget.TextView; package com.lucilu.rxdynamicsearch.ui.adapter.viewholder; public class AdViewHolder extends SimpleViewHolder<Ad> { @NonNull private final TextView headerTextView; public AdViewHolder(final View itemView) { super(itemView);
headerTextView = ViewUtils.find(itemView, R.id.item_textView_header);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java // public class AdViewHolder extends SimpleViewHolder<Ad> { // // @NonNull // private final TextView headerTextView; // // public AdViewHolder(final View itemView) { // super(itemView); // // headerTextView = ViewUtils.find(itemView, R.id.item_textView_header); // } // // @Override // public void bind(@NonNull final Ad model) { // headerTextView.setText(model.header()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java // public final class CountryViewHolder extends SimpleViewHolder<Country> { // // @NonNull // private final TextView mCountryName; // // @NonNull // private final TextView mCapital; // // public CountryViewHolder(@NonNull final View itemView) { // super(itemView); // // mCountryName = ViewUtils.find(itemView, R.id.item_textView_country); // mCapital = ViewUtils.find(itemView, R.id.item_textView_capital); // } // // @Override // public void bind(@NonNull final Country model) { // populateWith(model); // } // // private void populateWith(@NonNull final Country country) { // mCountryName.setText(country.getName()); // mCapital.setText(country.getCapital()); // } // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.AdViewHolder; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.CountryViewHolder; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.LayoutInflater; import android.view.ViewGroup; import static com.lucilu.rxdynamicsearch.Constants.ListItem.AD; import static com.lucilu.rxdynamicsearch.Constants.ListItem.COUNTRY;
package com.lucilu.rxdynamicsearch.ui.adapter; public final class CountryListViewHolderFactory implements IViewHolderFactory { @NonNull private final Context mContext; public CountryListViewHolderFactory(@NonNull final Context context) { mContext = context; } @NonNull @Override public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { switch (itemType) { case COUNTRY:
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java // public class AdViewHolder extends SimpleViewHolder<Ad> { // // @NonNull // private final TextView headerTextView; // // public AdViewHolder(final View itemView) { // super(itemView); // // headerTextView = ViewUtils.find(itemView, R.id.item_textView_header); // } // // @Override // public void bind(@NonNull final Ad model) { // headerTextView.setText(model.header()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java // public final class CountryViewHolder extends SimpleViewHolder<Country> { // // @NonNull // private final TextView mCountryName; // // @NonNull // private final TextView mCapital; // // public CountryViewHolder(@NonNull final View itemView) { // super(itemView); // // mCountryName = ViewUtils.find(itemView, R.id.item_textView_country); // mCapital = ViewUtils.find(itemView, R.id.item_textView_capital); // } // // @Override // public void bind(@NonNull final Country model) { // populateWith(model); // } // // private void populateWith(@NonNull final Country country) { // mCountryName.setText(country.getName()); // mCapital.setText(country.getCapital()); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.AdViewHolder; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.CountryViewHolder; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.LayoutInflater; import android.view.ViewGroup; import static com.lucilu.rxdynamicsearch.Constants.ListItem.AD; import static com.lucilu.rxdynamicsearch.Constants.ListItem.COUNTRY; package com.lucilu.rxdynamicsearch.ui.adapter; public final class CountryListViewHolderFactory implements IViewHolderFactory { @NonNull private final Context mContext; public CountryListViewHolderFactory(@NonNull final Context context) { mContext = context; } @NonNull @Override public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { switch (itemType) { case COUNTRY:
return new CountryViewHolder(LayoutInflater.from(mContext)
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java // public class AdViewHolder extends SimpleViewHolder<Ad> { // // @NonNull // private final TextView headerTextView; // // public AdViewHolder(final View itemView) { // super(itemView); // // headerTextView = ViewUtils.find(itemView, R.id.item_textView_header); // } // // @Override // public void bind(@NonNull final Ad model) { // headerTextView.setText(model.header()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java // public final class CountryViewHolder extends SimpleViewHolder<Country> { // // @NonNull // private final TextView mCountryName; // // @NonNull // private final TextView mCapital; // // public CountryViewHolder(@NonNull final View itemView) { // super(itemView); // // mCountryName = ViewUtils.find(itemView, R.id.item_textView_country); // mCapital = ViewUtils.find(itemView, R.id.item_textView_capital); // } // // @Override // public void bind(@NonNull final Country model) { // populateWith(model); // } // // private void populateWith(@NonNull final Country country) { // mCountryName.setText(country.getName()); // mCapital.setText(country.getCapital()); // } // }
import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.AdViewHolder; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.CountryViewHolder; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.LayoutInflater; import android.view.ViewGroup; import static com.lucilu.rxdynamicsearch.Constants.ListItem.AD; import static com.lucilu.rxdynamicsearch.Constants.ListItem.COUNTRY;
package com.lucilu.rxdynamicsearch.ui.adapter; public final class CountryListViewHolderFactory implements IViewHolderFactory { @NonNull private final Context mContext; public CountryListViewHolderFactory(@NonNull final Context context) { mContext = context; } @NonNull @Override public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { switch (itemType) { case COUNTRY: return new CountryViewHolder(LayoutInflater.from(mContext) .inflate(R.layout.item_country, parent, false)); case AD:
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IViewHolderFactory.java // public interface IViewHolderFactory { // // /** // * Creates a {@link ViewHolder} for the passed type // * // * @param parent The ViewGroup into which the new View will be added after it is bound to // * an adapter position. // * @return the newly created {@link ViewHolder} // */ // @NonNull // ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/AdViewHolder.java // public class AdViewHolder extends SimpleViewHolder<Ad> { // // @NonNull // private final TextView headerTextView; // // public AdViewHolder(final View itemView) { // super(itemView); // // headerTextView = ViewUtils.find(itemView, R.id.item_textView_header); // } // // @Override // public void bind(@NonNull final Ad model) { // headerTextView.setText(model.header()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/viewholder/CountryViewHolder.java // public final class CountryViewHolder extends SimpleViewHolder<Country> { // // @NonNull // private final TextView mCountryName; // // @NonNull // private final TextView mCapital; // // public CountryViewHolder(@NonNull final View itemView) { // super(itemView); // // mCountryName = ViewUtils.find(itemView, R.id.item_textView_country); // mCapital = ViewUtils.find(itemView, R.id.item_textView_capital); // } // // @Override // public void bind(@NonNull final Country model) { // populateWith(model); // } // // private void populateWith(@NonNull final Country country) { // mCountryName.setText(country.getName()); // mCapital.setText(country.getCapital()); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/CountryListViewHolderFactory.java import com.lucilu.rxdynamicsearch.R; import com.lucilu.rxdynamicsearch.ui.adapter.base.IViewHolderFactory; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.AdViewHolder; import com.lucilu.rxdynamicsearch.ui.adapter.viewholder.CountryViewHolder; import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.LayoutInflater; import android.view.ViewGroup; import static com.lucilu.rxdynamicsearch.Constants.ListItem.AD; import static com.lucilu.rxdynamicsearch.Constants.ListItem.COUNTRY; package com.lucilu.rxdynamicsearch.ui.adapter; public final class CountryListViewHolderFactory implements IViewHolderFactory { @NonNull private final Context mContext; public CountryListViewHolderFactory(@NonNull final Context context) { mContext = context; } @NonNull @Override public ViewHolder createViewHolder(@NonNull final ViewGroup parent, final int itemType) { switch (itemType) { case COUNTRY: return new CountryViewHolder(LayoutInflater.from(mContext) .inflate(R.layout.item_country, parent, false)); case AD:
return new AdViewHolder(LayoutInflater.from(mContext)
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.dagger.Scopes.ActivityScope; import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides activity object and activity context. */ @Module public final class ActivityModule { @NonNull private final Activity mActivity; public ActivityModule(@NonNull final Activity activity) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ActivityModule.java import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForActivity; import com.lucilu.rxdynamicsearch.dagger.Scopes.ActivityScope; import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides activity object and activity context. */ @Module public final class ActivityModule { @NonNull private final Activity mActivity; public ActivityModule(@NonNull final Activity activity) {
mActivity = get(activity);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/SearchFragmentModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/fragments/CountryListFragment.java // public final class CountryListFragment extends BaseFragment { // // @Nullable // @Inject // CountryListViewModel mViewModel; // // @Nullable // private SearchView mSearchView; // // @Nullable // private RecyclerView mCountryList; // // @Nullable // @Inject // RecyclerViewAdapter mAdapter; // // @Nullable // @Override // public View onCreateView(final LayoutInflater inflater, // @Nullable final ViewGroup container, // @Nullable final Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_country_list, container, false); // } // // @Override // public void onViewCreated(final View view, final Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // mSearchView = ViewUtils.find(view, R.id.searchView_countryName); // mCountryList = ViewUtils.find(view, R.id.list_country); // } // // @Override // public void onActivityCreated(@Nullable final Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // get(mCountryList).setAdapter(mAdapter); // get(mCountryList).setLayoutManager(new LinearLayoutManager(getActivity())); // } // // @Override // protected void onBind(@NonNull final CompositeSubscription s) { // s.add(get(mViewModel).getListItemStream() // .subscribeOn(Schedulers.computation()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(get(mAdapter)::update, // e -> Timber.e(e, "Error updating adapter with model"))); // } // // @NonNull // @Override // protected ViewModel getViewModel() { // return get(mViewModel); // } // // @Override // public void onInject() { // createComponent().inject(this); // } // // private CountryListComponent createComponent() { // MainActivity activity = (MainActivity) getActivity(); // SearchFragmentModule searchFragmentModule = new SearchFragmentModule(getQueryStream()); // // return activity.getComponent().plusSearchFragment(searchFragmentModule); // } // // private Observable<CharSequence> getQueryStream() { // return Observable.never(); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.dagger.Scopes.FragmentScope; import com.lucilu.rxdynamicsearch.fragments.CountryListFragment; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; import rx.Observable; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides {@link CountryListFragment} specific objects. */ @Module public final class SearchFragmentModule { @NonNull private final Observable<CharSequence> mQueryStream; public SearchFragmentModule(@NonNull final Observable<CharSequence> queryStream) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/fragments/CountryListFragment.java // public final class CountryListFragment extends BaseFragment { // // @Nullable // @Inject // CountryListViewModel mViewModel; // // @Nullable // private SearchView mSearchView; // // @Nullable // private RecyclerView mCountryList; // // @Nullable // @Inject // RecyclerViewAdapter mAdapter; // // @Nullable // @Override // public View onCreateView(final LayoutInflater inflater, // @Nullable final ViewGroup container, // @Nullable final Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_country_list, container, false); // } // // @Override // public void onViewCreated(final View view, final Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // mSearchView = ViewUtils.find(view, R.id.searchView_countryName); // mCountryList = ViewUtils.find(view, R.id.list_country); // } // // @Override // public void onActivityCreated(@Nullable final Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // get(mCountryList).setAdapter(mAdapter); // get(mCountryList).setLayoutManager(new LinearLayoutManager(getActivity())); // } // // @Override // protected void onBind(@NonNull final CompositeSubscription s) { // s.add(get(mViewModel).getListItemStream() // .subscribeOn(Schedulers.computation()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(get(mAdapter)::update, // e -> Timber.e(e, "Error updating adapter with model"))); // } // // @NonNull // @Override // protected ViewModel getViewModel() { // return get(mViewModel); // } // // @Override // public void onInject() { // createComponent().inject(this); // } // // private CountryListComponent createComponent() { // MainActivity activity = (MainActivity) getActivity(); // SearchFragmentModule searchFragmentModule = new SearchFragmentModule(getQueryStream()); // // return activity.getComponent().plusSearchFragment(searchFragmentModule); // } // // private Observable<CharSequence> getQueryStream() { // return Observable.never(); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/SearchFragmentModule.java import com.lucilu.rxdynamicsearch.dagger.Scopes.FragmentScope; import com.lucilu.rxdynamicsearch.fragments.CountryListFragment; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; import rx.Observable; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides {@link CountryListFragment} specific objects. */ @Module public final class SearchFragmentModule { @NonNull private final Observable<CharSequence> mQueryStream; public SearchFragmentModule(@NonNull final Observable<CharSequence> queryStream) {
mQueryStream = get(queryStream);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/DiffUtilCallback.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // }
import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.support.annotation.NonNull; import android.support.v7.util.DiffUtil; import java.util.List;
package com.lucilu.rxdynamicsearch.ui.adapter; final class DiffUtilCallback extends DiffUtil.Callback { @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/DiffUtilCallback.java import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.support.annotation.NonNull; import android.support.v7.util.DiffUtil; import java.util.List; package com.lucilu.rxdynamicsearch.ui.adapter; final class DiffUtilCallback extends DiffUtil.Callback { @NonNull
private final List<DisplayableItem> mOldItems;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/DiffUtilCallback.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // }
import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.support.annotation.NonNull; import android.support.v7.util.DiffUtil; import java.util.List;
package com.lucilu.rxdynamicsearch.ui.adapter; final class DiffUtilCallback extends DiffUtil.Callback { @NonNull private final List<DisplayableItem> mOldItems; @NonNull private final List<DisplayableItem> mNewItems; @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/base/IListItemComparator.java // public interface IListItemComparator { // // /** // * Decides whether two {@link DisplayableItem} represent the same Item. // * For example, if your items have unique ids, this method should check their id equality. // * // * @return True if the two items represent the same object or false if they are different. // */ // boolean areItemsTheSame(final DisplayableItem item1, final DisplayableItem item2); // // /** // * Checks whether the visual representation of two {@link DisplayableItem}s is the same. // * // * This method is called only if {@link #areItemsTheSame(DisplayableItem, DisplayableItem)} // * returns {@code true} for these items. For instance, when the item is the same with different // * state, like selected. // * // * @return True if the visual representation for the {@link DisplayableItem}s are the same or // * false if they are different. // */ // boolean areContentsTheSame(final DisplayableItem item1, final DisplayableItem item2); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/viewmodel/pojo/DisplayableItem.java // @AutoValue // public abstract class DisplayableItem<T> { // // public abstract int type(); // // @NonNull // public abstract T model(); // // @SuppressWarnings("NullableProblems") // @AutoValue.Builder // public abstract static class Builder<T> { // // @NonNull // public abstract Builder<T> type(@NonNull int type); // // @NonNull // public abstract Builder<T> model(@NonNull T model); // // @NonNull // public abstract DisplayableItem<T> build(); // } // // @NonNull // public static <T> Builder<T> builder() { // return new AutoValue_DisplayableItem.Builder<>(); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/ui/adapter/DiffUtilCallback.java import com.lucilu.rxdynamicsearch.ui.adapter.base.IListItemComparator; import com.lucilu.rxdynamicsearch.viewmodel.pojo.DisplayableItem; import android.support.annotation.NonNull; import android.support.v7.util.DiffUtil; import java.util.List; package com.lucilu.rxdynamicsearch.ui.adapter; final class DiffUtilCallback extends DiffUtil.Callback { @NonNull private final List<DisplayableItem> mOldItems; @NonNull private final List<DisplayableItem> mNewItems; @NonNull
private final IListItemComparator mComparator;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // }
import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides
IResourceProvider provideResourceProvider(@ForApplication final Context context) {
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // }
import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) {
return new ResourceProvider(context);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // }
import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) { return new ResourceProvider(context); } @Provides
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) { return new ResourceProvider(context); } @Provides
IJsonParserProvider provideJsonParserProvider(@NonNull final Gson gson,
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // }
import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides;
package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) { return new ResourceProvider(context); } @Provides IJsonParserProvider provideJsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java // public final class JsonParserProvider implements IJsonParserProvider { // // @NonNull // private final Gson mGson; // // @NonNull // private final IResourceProvider mResourceProvider; // // public JsonParserProvider(@NonNull final Gson gson, // @NonNull final IResourceProvider resourceProvider) { // mGson = get(gson); // mResourceProvider = get(resourceProvider); // } // // @Override // public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType) { // Preconditions.assertWorkerThread(); // // Type listType = new ListOfJsonType<>(classOfType); // InputStreamReader isr = new InputStreamReader( // mResourceProvider.openRawResource(rawResourceId)); // try { // List<T> list = mGson.fromJson(isr, listType); // return ofObj(list); // } catch (JsonSyntaxException e) { // Timber.e(e, "Error parsing from json %s", listType); // return none(); // } // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/ResourceProvider.java // public final class ResourceProvider implements IResourceProvider { // // @NonNull // private final Context mContext; // // public ResourceProvider(@NonNull final Context context) { // mContext = get(context); // } // // @NonNull // @Override // public InputStream openRawResource(final int id) { // return mContext.getResources().openRawResource(id); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/ProviderModule.java import com.google.gson.Gson; import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import com.lucilu.rxdynamicsearch.provider.JsonParserProvider; import com.lucilu.rxdynamicsearch.provider.ResourceProvider; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import android.content.Context; import android.support.annotation.NonNull; import dagger.Module; import dagger.Provides; package com.lucilu.rxdynamicsearch.dagger.module; @Module(includes = DataModule.class) public final class ProviderModule { @Provides IResourceProvider provideResourceProvider(@ForApplication final Context context) { return new ResourceProvider(context); } @Provides IJsonParserProvider provideJsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) {
return new JsonParserProvider(gson, resourceProvider);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/AppModule.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get;
package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides application object and application context. */ @Module public final class AppModule { @NonNull private final Application mApplication; public AppModule(@NonNull final Application app) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/AppModule.java import com.lucilu.rxdynamicsearch.dagger.Qualifiers.ForApplication; import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; package com.lucilu.rxdynamicsearch.dagger.module; /** * Provides application object and application context. */ @Module public final class AppModule { @NonNull private final Application mApplication; public AppModule(@NonNull final Application app) {
mApplication = get(app);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/CountryListComponent.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java // @Module // public final class CountryListModule { // // @Provides // IViewHolderFactory provideViewHolderFactory(@ForActivity Context context) { // return new CountryListViewHolderFactory(context); // } // // @Provides // IViewHolderBinder<DisplayableItem> provideViewHolderBinder() { // return new CountryListViewHolderBinder(); // } // // @Provides // IListItemComparator provideListItemComparator() { // return new CountryListItemComparator(); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/SearchFragmentModule.java // @Module // public final class SearchFragmentModule { // // @NonNull // private final Observable<CharSequence> mQueryStream; // // public SearchFragmentModule(@NonNull final Observable<CharSequence> queryStream) { // mQueryStream = get(queryStream); // } // // @FragmentScope // @Provides // Observable<CharSequence> providesQueryStream() { // return mQueryStream; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/fragments/CountryListFragment.java // public final class CountryListFragment extends BaseFragment { // // @Nullable // @Inject // CountryListViewModel mViewModel; // // @Nullable // private SearchView mSearchView; // // @Nullable // private RecyclerView mCountryList; // // @Nullable // @Inject // RecyclerViewAdapter mAdapter; // // @Nullable // @Override // public View onCreateView(final LayoutInflater inflater, // @Nullable final ViewGroup container, // @Nullable final Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_country_list, container, false); // } // // @Override // public void onViewCreated(final View view, final Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // mSearchView = ViewUtils.find(view, R.id.searchView_countryName); // mCountryList = ViewUtils.find(view, R.id.list_country); // } // // @Override // public void onActivityCreated(@Nullable final Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // get(mCountryList).setAdapter(mAdapter); // get(mCountryList).setLayoutManager(new LinearLayoutManager(getActivity())); // } // // @Override // protected void onBind(@NonNull final CompositeSubscription s) { // s.add(get(mViewModel).getListItemStream() // .subscribeOn(Schedulers.computation()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(get(mAdapter)::update, // e -> Timber.e(e, "Error updating adapter with model"))); // } // // @NonNull // @Override // protected ViewModel getViewModel() { // return get(mViewModel); // } // // @Override // public void onInject() { // createComponent().inject(this); // } // // private CountryListComponent createComponent() { // MainActivity activity = (MainActivity) getActivity(); // SearchFragmentModule searchFragmentModule = new SearchFragmentModule(getQueryStream()); // // return activity.getComponent().plusSearchFragment(searchFragmentModule); // } // // private Observable<CharSequence> getQueryStream() { // return Observable.never(); // } // }
import com.lucilu.rxdynamicsearch.dagger.Scopes.FragmentScope; import com.lucilu.rxdynamicsearch.dagger.module.CountryListModule; import com.lucilu.rxdynamicsearch.dagger.module.SearchFragmentModule; import com.lucilu.rxdynamicsearch.fragments.CountryListFragment; import dagger.Subcomponent;
package com.lucilu.rxdynamicsearch.dagger.component; /** * {@link CountryListFragment} component. */ @FragmentScope @Subcomponent(modules = {SearchFragmentModule.class, CountryListModule.class}) public interface CountryListComponent {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/CountryListModule.java // @Module // public final class CountryListModule { // // @Provides // IViewHolderFactory provideViewHolderFactory(@ForActivity Context context) { // return new CountryListViewHolderFactory(context); // } // // @Provides // IViewHolderBinder<DisplayableItem> provideViewHolderBinder() { // return new CountryListViewHolderBinder(); // } // // @Provides // IListItemComparator provideListItemComparator() { // return new CountryListItemComparator(); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/module/SearchFragmentModule.java // @Module // public final class SearchFragmentModule { // // @NonNull // private final Observable<CharSequence> mQueryStream; // // public SearchFragmentModule(@NonNull final Observable<CharSequence> queryStream) { // mQueryStream = get(queryStream); // } // // @FragmentScope // @Provides // Observable<CharSequence> providesQueryStream() { // return mQueryStream; // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/fragments/CountryListFragment.java // public final class CountryListFragment extends BaseFragment { // // @Nullable // @Inject // CountryListViewModel mViewModel; // // @Nullable // private SearchView mSearchView; // // @Nullable // private RecyclerView mCountryList; // // @Nullable // @Inject // RecyclerViewAdapter mAdapter; // // @Nullable // @Override // public View onCreateView(final LayoutInflater inflater, // @Nullable final ViewGroup container, // @Nullable final Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_country_list, container, false); // } // // @Override // public void onViewCreated(final View view, final Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // mSearchView = ViewUtils.find(view, R.id.searchView_countryName); // mCountryList = ViewUtils.find(view, R.id.list_country); // } // // @Override // public void onActivityCreated(@Nullable final Bundle savedInstanceState) { // super.onActivityCreated(savedInstanceState); // // get(mCountryList).setAdapter(mAdapter); // get(mCountryList).setLayoutManager(new LinearLayoutManager(getActivity())); // } // // @Override // protected void onBind(@NonNull final CompositeSubscription s) { // s.add(get(mViewModel).getListItemStream() // .subscribeOn(Schedulers.computation()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(get(mAdapter)::update, // e -> Timber.e(e, "Error updating adapter with model"))); // } // // @NonNull // @Override // protected ViewModel getViewModel() { // return get(mViewModel); // } // // @Override // public void onInject() { // createComponent().inject(this); // } // // private CountryListComponent createComponent() { // MainActivity activity = (MainActivity) getActivity(); // SearchFragmentModule searchFragmentModule = new SearchFragmentModule(getQueryStream()); // // return activity.getComponent().plusSearchFragment(searchFragmentModule); // } // // private Observable<CharSequence> getQueryStream() { // return Observable.never(); // } // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/dagger/component/CountryListComponent.java import com.lucilu.rxdynamicsearch.dagger.Scopes.FragmentScope; import com.lucilu.rxdynamicsearch.dagger.module.CountryListModule; import com.lucilu.rxdynamicsearch.dagger.module.SearchFragmentModule; import com.lucilu.rxdynamicsearch.fragments.CountryListFragment; import dagger.Subcomponent; package com.lucilu.rxdynamicsearch.dagger.component; /** * {@link CountryListFragment} component. */ @FragmentScope @Subcomponent(modules = {SearchFragmentModule.class, CountryListModule.class}) public interface CountryListComponent {
void inject(CountryListFragment fragment);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj;
package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj; package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull
private final IResourceProvider mResourceProvider;
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj;
package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull private final IResourceProvider mResourceProvider; public JsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj; package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull private final IResourceProvider mResourceProvider; public JsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) {
mGson = get(gson);
luciapayo/RxDynamicSearch
app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // }
import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj;
package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull private final IResourceProvider mResourceProvider; public JsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) { mGson = get(gson); mResourceProvider = get(resourceProvider); } @Override public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, @NonNull final Class<T> classOfType) {
// Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IJsonParserProvider.java // public interface IJsonParserProvider { // // /** // * Parses from // * // * @param rawResourceId the id to the raw json file in resources // * @param classOfType the class of the type of the objects in the list // * @param <T> the type of the objects in the list // * @return option of the list. Can be {@link Option#NONE} if the parsing fails. // */ // <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, // @NonNull final Class<T> classOfType); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/base/IResourceProvider.java // public interface IResourceProvider { // // /** // * {@link Resources#openRawResource(int)} // */ // @NonNull // InputStream openRawResource(final int id); // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // public final class Preconditions { // // private Preconditions() { // throw new AssertionError("Don't create instances of this object"); // } // // /** // * Checks if the reference is not null. // * // * @param reference an object reference // * @return the non-null reference // * @throws NullPointerException if {@code reference} is null // */ // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // // /** // * Checks if the reference is not null. // * // * @param reference object reference // * @param errorMessage message used if the check fails // * @return non-null reference // * @throws NullPointerException if {@code reference} is null // */ // public static <T> T checkNotNull(final T reference, @NonNull final String errorMessage) { // if (reference == null) { // throw new NullPointerException(get(errorMessage)); // } // return reference; // } // // /** // * Checks the truth of an expression for an argument. // * // * @param expression a boolean expression // * @param errorMessage message used if the check fails // * @throws IllegalArgumentException if {@code expression} is false // */ // public static void checkArgument(boolean expression, @NonNull final String errorMessage) { // if (!expression) { // throw new IllegalArgumentException(get(errorMessage)); // } // } // // /** // * Asserts that the current thread is a worker thread. // */ // public static void assertWorkerThread() { // if (isMainThread()) { // throw new IllegalStateException( // "This task must be run on a worker thread and not on the Main thread."); // } // } // // /** // * Asserts that the current thread is the Main Thread. // */ // public static void assertUiThread() { // if (!isMainThread()) { // throw new IllegalStateException( // "This task must be run on the Main thread and not on a worker thread."); // } // } // // private static boolean isMainThread() { // return Objects.equals(Looper.getMainLooper(), Looper.myLooper()); // } // } // // Path: app/src/main/java/com/lucilu/rxdynamicsearch/utils/Preconditions.java // @NonNull // public static <T> T get(@Nullable final T reference) { // if (reference == null) { // throw new NullPointerException("Assertion for a nonnull object failed."); // } // return reference; // } // Path: app/src/main/java/com/lucilu/rxdynamicsearch/provider/JsonParserProvider.java import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.lucilu.rxdynamicsearch.provider.base.IJsonParserProvider; import com.lucilu.rxdynamicsearch.provider.base.IResourceProvider; import com.lucilu.rxdynamicsearch.utils.Preconditions; import android.support.annotation.NonNull; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import polanski.option.Option; import timber.log.Timber; import static com.lucilu.rxdynamicsearch.utils.Preconditions.get; import static polanski.option.Option.none; import static polanski.option.Option.ofObj; package com.lucilu.rxdynamicsearch.provider; public final class JsonParserProvider implements IJsonParserProvider { @NonNull private final Gson mGson; @NonNull private final IResourceProvider mResourceProvider; public JsonParserProvider(@NonNull final Gson gson, @NonNull final IResourceProvider resourceProvider) { mGson = get(gson); mResourceProvider = get(resourceProvider); } @Override public <T> Option<List<T>> parseListFromRawJsonFile(final int rawResourceId, @NonNull final Class<T> classOfType) {
Preconditions.assertWorkerThread();