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
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import java.io.UnsupportedEncodingException; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java import java.io.UnsupportedEncodingException; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException {
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import java.io.UnsupportedEncodingException; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); } public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { super(entity.getBytes("UTF-8"), listener);
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java import java.io.UnsupportedEncodingException; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); } public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { super(entity.getBytes("UTF-8"), listener);
mType = PacketType.STRING;
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.listener.SendListener; import java.io.ByteArrayInputStream;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); }
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java import net.qiujuer.blink.listener.SendListener; import java.io.ByteArrayInputStream; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); }
public ByteSendPacket(byte[] entity, SendListener listener) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/box/StringSendPacket.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.listener.SendListener; import java.io.UnsupportedEncodingException;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 03/31/2015 * Changed 04/02/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/box/StringSendPacket.java import net.qiujuer.blink.listener.SendListener; import java.io.UnsupportedEncodingException; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 03/31/2015 * Changed 04/02/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException {
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/async/AsyncSendDispatcher.java
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketFormatter.java // public abstract class PacketFormatter extends PacketFilter { // protected SendPacket mPacket; // // public abstract float format(); // // public void setPacket(SendPacket packet) { // mPacket = packet; // } // // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // }
import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.PacketFilter; import net.qiujuer.blink.core.PacketFormatter; import net.qiujuer.blink.core.SendDispatcher; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.Sender; import net.qiujuer.blink.core.delivery.SendDelivery; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/26/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Provides for performing send dispatch from a queue of BinkConn {@link BlinkClient}. */ public class AsyncSendDispatcher extends AsyncDispatcher implements SendDispatcher { // The queue of send entity. private final Queue<SendPacket> mQueue; // The sender interface for processing sender requests.
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketFormatter.java // public abstract class PacketFormatter extends PacketFilter { // protected SendPacket mPacket; // // public abstract float format(); // // public void setPacket(SendPacket packet) { // mPacket = packet; // } // // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // } // Path: Java/Blink/library/src/net/qiujuer/blink/async/AsyncSendDispatcher.java import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.PacketFilter; import net.qiujuer.blink.core.PacketFormatter; import net.qiujuer.blink.core.SendDispatcher; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.Sender; import net.qiujuer.blink.core.delivery.SendDelivery; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/26/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Provides for performing send dispatch from a queue of BinkConn {@link BlinkClient}. */ public class AsyncSendDispatcher extends AsyncDispatcher implements SendDispatcher { // The queue of send entity. private final Queue<SendPacket> mQueue; // The sender interface for processing sender requests.
private Sender mSender;
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/async/AsyncSendDispatcher.java
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketFormatter.java // public abstract class PacketFormatter extends PacketFilter { // protected SendPacket mPacket; // // public abstract float format(); // // public void setPacket(SendPacket packet) { // mPacket = packet; // } // // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // }
import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.PacketFilter; import net.qiujuer.blink.core.PacketFormatter; import net.qiujuer.blink.core.SendDispatcher; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.Sender; import net.qiujuer.blink.core.delivery.SendDelivery; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/26/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Provides for performing send dispatch from a queue of BinkConn {@link BlinkClient}. */ public class AsyncSendDispatcher extends AsyncDispatcher implements SendDispatcher { // The queue of send entity. private final Queue<SendPacket> mQueue; // The sender interface for processing sender requests. private Sender mSender; // Posting send responses. private SendDelivery mDelivery; // Used for telling us to die. private final AtomicBoolean mSending = new AtomicBoolean(false); // Formatter packet to args buffer
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketFormatter.java // public abstract class PacketFormatter extends PacketFilter { // protected SendPacket mPacket; // // public abstract float format(); // // public void setPacket(SendPacket packet) { // mPacket = packet; // } // // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // } // Path: Java/Blink/library/src/net/qiujuer/blink/async/AsyncSendDispatcher.java import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.PacketFilter; import net.qiujuer.blink.core.PacketFormatter; import net.qiujuer.blink.core.SendDispatcher; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.Sender; import net.qiujuer.blink.core.delivery.SendDelivery; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/26/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Provides for performing send dispatch from a queue of BinkConn {@link BlinkClient}. */ public class AsyncSendDispatcher extends AsyncDispatcher implements SendDispatcher { // The queue of send entity. private final Queue<SendPacket> mQueue; // The sender interface for processing sender requests. private Sender mSender; // Posting send responses. private SendDelivery mDelivery; // Used for telling us to die. private final AtomicBoolean mSending = new AtomicBoolean(false); // Formatter packet to args buffer
private PacketFormatter mFormatter;
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/box/BaseSendPacket.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import java.io.InputStream; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.SendListener;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * The Send base class */ public abstract class BaseSendPacket<T> extends SendPacket { protected T mEntity; protected InputStream mStream;
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/BaseSendPacket.java import java.io.InputStream; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.SendListener; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * The Send base class */ public abstract class BaseSendPacket<T> extends SendPacket { protected T mEntity; protected InputStream mStream;
public BaseSendPacket(T entity, byte type, SendListener listener) {
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/box/StringSendPacket.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.listener.SendListener; import java.io.UnsupportedEncodingException;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/StringSendPacket.java import net.qiujuer.blink.listener.SendListener; import java.io.UnsupportedEncodingException; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * String send class */ public class StringSendPacket extends ByteSendPacket { public StringSendPacket(String entity) throws UnsupportedEncodingException { this(entity, null); }
public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException {
qiujuer/Blink
Java/Blink/sample/src/net/qiujuer/sample/blink/Client.java
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.listener.SendListener; import java.io.File; import java.io.IOException;
package net.qiujuer.sample.blink; /** * Blink Client */ public class Client { private static void send(BlinkClient connect) { System.out.println("Client Sending..."); System.out.println("Send Some String."); for (int i = 0; i <= 50; i++) { connect.send("Blink String:" + i); } System.out.println("Send Some Bytes."); connect.send(new byte[]{1, 1, 0, 0}); connect.send(new byte[]{1, 1, 1, 0, 1}); System.out.println("Send A File.(D:/Data.txt)"); connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"),
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/sample/src/net/qiujuer/sample/blink/Client.java import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.listener.SendListener; import java.io.File; import java.io.IOException; package net.qiujuer.sample.blink; /** * Blink Client */ public class Client { private static void send(BlinkClient connect) { System.out.println("Client Sending..."); System.out.println("Send Some String."); for (int i = 0; i <= 50; i++) { connect.send("Blink String:" + i); } System.out.println("Send Some Bytes."); connect.send(new byte[]{1, 1, 0, 0}); connect.send(new byte[]{1, 1, 1, 0, 1}); System.out.println("Send A File.(D:/Data.txt)"); connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"),
new SendListener() {
qiujuer/Blink
Java/Blink/sample/src/net/qiujuer/sample/blink/Client.java
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.listener.SendListener; import java.io.File; import java.io.IOException;
package net.qiujuer.sample.blink; /** * Blink Client */ public class Client { private static void send(BlinkClient connect) { System.out.println("Client Sending..."); System.out.println("Send Some String."); for (int i = 0; i <= 50; i++) { connect.send("Blink String:" + i); } System.out.println("Send Some Bytes."); connect.send(new byte[]{1, 1, 0, 0}); connect.send(new byte[]{1, 1, 1, 0, 1}); System.out.println("Send A File.(D:/Data.txt)"); connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"), new SendListener() { @Override
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java // public class BlinkClient extends BlinkConnect { // private SocketAddress mAddress; // // public BlinkClient() { // setDelivery(new ExecutorDelivery(null)); // } // // public boolean connect(String ip, int port) { // return connect(new InetSocketAddress(ip, port)); // } // // public boolean connect(InetSocketAddress address) { // return connect((SocketAddress) address); // } // // public boolean connect(SocketAddress address) { // mAddress = address; // try { // SocketChannel channel = SocketChannel.open(mAddress); // boolean connected = channel.isConnected(); // if (connected) { // channel.configureBlocking(false); // start(channel); // } // return connected; // } catch (IOException e) { // e.printStackTrace(); // return false; // } // } // // public boolean reconnect() { // if (mAddress == null) // throw new NullPointerException("SocketChannel address is null, you should call connect."); // // dispose(); // // return connect(mAddress); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/sample/src/net/qiujuer/sample/blink/Client.java import net.qiujuer.blink.BlinkClient; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.core.listener.SendListener; import java.io.File; import java.io.IOException; package net.qiujuer.sample.blink; /** * Blink Client */ public class Client { private static void send(BlinkClient connect) { System.out.println("Client Sending..."); System.out.println("Send Some String."); for (int i = 0; i <= 50; i++) { connect.send("Blink String:" + i); } System.out.println("Send Some Bytes."); connect.send(new byte[]{1, 1, 0, 0}); connect.send(new byte[]{1, 1, 1, 0, 1}); System.out.println("Send A File.(D:/Data.txt)"); connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"), new SendListener() { @Override
public void onSendStart(SendPacket packet) {
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/core/Sender.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncEventArgs.java // public class AsyncEventArgs implements Disposable { // // Send an Receive packet head size // public final static int HeadSize = 11; // // Is Disposed // protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // // Notify progress precision // protected final float mProgressPrecision; // // Notify progress // protected float mProgress = 0; // // Send or Receive status // protected boolean mStatus = true; // // private int mCount; // private int mOffset; // private int mBytesTransferred; // private final ByteBuffer mByteBuffer; // // public AsyncEventArgs(int capacity, float progressPrecision) { // mByteBuffer = ByteBuffer.allocate(capacity); // mProgressPrecision = progressPrecision; // } // // public byte[] getBuffer() { // return mByteBuffer.array(); // } // // public void setBuffer(int offset, int count) { // mCount = count; // mOffset = offset; // } // // public int getOffset() { // return mOffset; // } // // public int getCount() { // return mCount; // } // // public int getBytesTransferred() { // return mBytesTransferred; // } // // private void formatBuffer() { // mByteBuffer.clear(); // mByteBuffer.limit(mOffset + mCount); // mByteBuffer.position(mOffset); // } // // void send(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.write(buffer); // onCompleted(this); // } // // void receive(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.read(buffer); // onCompleted(this); // } // // void onCompleted(AsyncEventArgs e) { // // } // // protected boolean isNotifyProgress(float newProgress) { // if (newProgress == 0 || // newProgress == 1 || // (newProgress - mProgress) > mProgressPrecision) { // mProgress = newProgress; // return true; // } else { // return false; // } // } // // @Override // public void dispose() { // mByteBuffer.clear(); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // }
import net.qiujuer.blink.async.AsyncEventArgs; import net.qiujuer.blink.kit.Disposable;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * This socket sender */ public interface Sender extends Disposable { /** * Get socket send buffer size * * @return Buffer Size */ int getSendBufferSize(); /** * Async send same byte * * @param e SocketAsyncEventArgs * @return Status */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncEventArgs.java // public class AsyncEventArgs implements Disposable { // // Send an Receive packet head size // public final static int HeadSize = 11; // // Is Disposed // protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // // Notify progress precision // protected final float mProgressPrecision; // // Notify progress // protected float mProgress = 0; // // Send or Receive status // protected boolean mStatus = true; // // private int mCount; // private int mOffset; // private int mBytesTransferred; // private final ByteBuffer mByteBuffer; // // public AsyncEventArgs(int capacity, float progressPrecision) { // mByteBuffer = ByteBuffer.allocate(capacity); // mProgressPrecision = progressPrecision; // } // // public byte[] getBuffer() { // return mByteBuffer.array(); // } // // public void setBuffer(int offset, int count) { // mCount = count; // mOffset = offset; // } // // public int getOffset() { // return mOffset; // } // // public int getCount() { // return mCount; // } // // public int getBytesTransferred() { // return mBytesTransferred; // } // // private void formatBuffer() { // mByteBuffer.clear(); // mByteBuffer.limit(mOffset + mCount); // mByteBuffer.position(mOffset); // } // // void send(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.write(buffer); // onCompleted(this); // } // // void receive(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.read(buffer); // onCompleted(this); // } // // void onCompleted(AsyncEventArgs e) { // // } // // protected boolean isNotifyProgress(float newProgress) { // if (newProgress == 0 || // newProgress == 1 || // (newProgress - mProgress) > mProgressPrecision) { // mProgress = newProgress; // return true; // } else { // return false; // } // } // // @Override // public void dispose() { // mByteBuffer.clear(); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/Sender.java import net.qiujuer.blink.async.AsyncEventArgs; import net.qiujuer.blink.kit.Disposable; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * This socket sender */ public interface Sender extends Disposable { /** * Get socket send buffer size * * @return Buffer Size */ int getSendBufferSize(); /** * Async send same byte * * @param e SocketAsyncEventArgs * @return Status */
boolean sendAsync(AsyncEventArgs e);
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/core/Receiver.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncEventArgs.java // public class AsyncEventArgs implements Disposable { // // Send an Receive packet head size // public final static int HeadSize = 11; // // Is Disposed // protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // // Notify progress precision // protected final float mProgressPrecision; // // Notify progress // protected float mProgress = 0; // // Send or Receive status // protected boolean mStatus = true; // // private int mCount; // private int mOffset; // private int mBytesTransferred; // private final ByteBuffer mByteBuffer; // // public AsyncEventArgs(int capacity, float progressPrecision) { // mByteBuffer = ByteBuffer.allocate(capacity); // mProgressPrecision = progressPrecision; // } // // public byte[] getBuffer() { // return mByteBuffer.array(); // } // // public void setBuffer(int offset, int count) { // mCount = count; // mOffset = offset; // } // // public int getOffset() { // return mOffset; // } // // public int getCount() { // return mCount; // } // // public int getBytesTransferred() { // return mBytesTransferred; // } // // private void formatBuffer() { // mByteBuffer.clear(); // mByteBuffer.limit(mOffset + mCount); // mByteBuffer.position(mOffset); // } // // void send(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.write(buffer); // onCompleted(this); // } // // void receive(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.read(buffer); // onCompleted(this); // } // // void onCompleted(AsyncEventArgs e) { // // } // // protected boolean isNotifyProgress(float newProgress) { // if (newProgress == 0 || // newProgress == 1 || // (newProgress - mProgress) > mProgressPrecision) { // mProgress = newProgress; // return true; // } else { // return false; // } // } // // @Override // public void dispose() { // mByteBuffer.clear(); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // }
import net.qiujuer.blink.async.AsyncEventArgs; import net.qiujuer.blink.kit.Disposable;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * This socket receiver */ public interface Receiver extends Disposable { /** * Get receive buffer size * * @return Buffer Size */ int getReceiveBufferSize(); /** * Async receive same data to buffer * * @param e SocketAsyncEventArgs * @return Status */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncEventArgs.java // public class AsyncEventArgs implements Disposable { // // Send an Receive packet head size // public final static int HeadSize = 11; // // Is Disposed // protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // // Notify progress precision // protected final float mProgressPrecision; // // Notify progress // protected float mProgress = 0; // // Send or Receive status // protected boolean mStatus = true; // // private int mCount; // private int mOffset; // private int mBytesTransferred; // private final ByteBuffer mByteBuffer; // // public AsyncEventArgs(int capacity, float progressPrecision) { // mByteBuffer = ByteBuffer.allocate(capacity); // mProgressPrecision = progressPrecision; // } // // public byte[] getBuffer() { // return mByteBuffer.array(); // } // // public void setBuffer(int offset, int count) { // mCount = count; // mOffset = offset; // } // // public int getOffset() { // return mOffset; // } // // public int getCount() { // return mCount; // } // // public int getBytesTransferred() { // return mBytesTransferred; // } // // private void formatBuffer() { // mByteBuffer.clear(); // mByteBuffer.limit(mOffset + mCount); // mByteBuffer.position(mOffset); // } // // void send(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.write(buffer); // onCompleted(this); // } // // void receive(SocketChannel channel) throws IOException { // formatBuffer(); // ByteBuffer buffer = mByteBuffer; // mBytesTransferred = 0; // mBytesTransferred = channel.read(buffer); // onCompleted(this); // } // // void onCompleted(AsyncEventArgs e) { // // } // // protected boolean isNotifyProgress(float newProgress) { // if (newProgress == 0 || // newProgress == 1 || // (newProgress - mProgress) > mProgressPrecision) { // mProgress = newProgress; // return true; // } else { // return false; // } // } // // @Override // public void dispose() { // mByteBuffer.clear(); // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/Receiver.java import net.qiujuer.blink.async.AsyncEventArgs; import net.qiujuer.blink.kit.Disposable; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * This socket receiver */ public interface Receiver extends Disposable { /** * Get receive buffer size * * @return Buffer Size */ int getReceiveBufferSize(); /** * Async receive same data to buffer * * @param e SocketAsyncEventArgs * @return Status */
boolean receiveAsync(AsyncEventArgs e);
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/box/ByteSendPacket.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import java.io.ByteArrayInputStream; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); }
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/library/src/net/qiujuer/blink/box/ByteSendPacket.java import java.io.ByteArrayInputStream; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); }
public ByteSendPacket(byte[] entity, SendListener listener) {
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/box/ByteSendPacket.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // }
import java.io.ByteArrayInputStream; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); } public ByteSendPacket(byte[] entity, SendListener listener) {
// Path: Java/Blink/library/src/net/qiujuer/blink/core/PacketType.java // public class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java // public interface SendListener { // // /** // * On start send the packet call // * // * @param packet SendPacket // */ // void onSendStart(SendPacket packet); // // // /** // * On the packet send progress changed call // * // * @param packet SendPacket // * @param progress Progress (0~1) // */ // void onSendProgress(SendPacket packet, float progress); // // /** // * On send completed call // * // * @param packet SendPacket // */ // void onSendCompleted(SendPacket packet); // } // Path: Java/Blink/library/src/net/qiujuer/blink/box/ByteSendPacket.java import java.io.ByteArrayInputStream; import net.qiujuer.blink.core.PacketType; import net.qiujuer.blink.core.listener.SendListener; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * Bytes send class */ public class ByteSendPacket extends BaseSendPacket<byte[]> { public ByteSendPacket(byte[] entity) { this(entity, null); } public ByteSendPacket(byte[] entity, SendListener listener) {
super(entity, PacketType.BYTES, listener);
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue;
* Get file resource * * @return Resource */ public Resource getResource() { return mResource; } /** * Send a Entity to queue * * @param entity SendEntity<T> {@link SendPacket} * @param <T> Extends SendEntity * @return SendEntity<T> */ public <T> SendPacket<T> send(SendPacket<T> entity) { entity.setBlinkConn(this); synchronized (mSendQueue) { mSendQueue.add(entity); } return entity; } /** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue; * Get file resource * * @return Resource */ public Resource getResource() { return mResource; } /** * Send a Entity to queue * * @param entity SendEntity<T> {@link SendPacket} * @param <T> Extends SendEntity * @return SendEntity<T> */ public <T> SendPacket<T> send(SendPacket<T> entity) { entity.setBlinkConn(this); synchronized (mSendQueue) { mSendQueue.add(entity); } return entity; } /** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */
public FileSendPacket send(File file) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue;
* @param entity SendEntity<T> {@link SendPacket} * @param <T> Extends SendEntity * @return SendEntity<T> */ public <T> SendPacket<T> send(SendPacket<T> entity) { entity.setBlinkConn(this); synchronized (mSendQueue) { mSendQueue.add(entity); } return entity; } /** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file) { return send(file, null); } /** * Send file to queue * * @param file File * @param listener Callback listener * @return FileSendEntity {@link FileSendPacket} */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue; * @param entity SendEntity<T> {@link SendPacket} * @param <T> Extends SendEntity * @return SendEntity<T> */ public <T> SendPacket<T> send(SendPacket<T> entity) { entity.setBlinkConn(this); synchronized (mSendQueue) { mSendQueue.add(entity); } return entity; } /** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file) { return send(file, null); } /** * Send file to queue * * @param file File * @param listener Callback listener * @return FileSendEntity {@link FileSendPacket} */
public FileSendPacket send(File file, SendListener listener) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue;
/** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file) { return send(file, null); } /** * Send file to queue * * @param file File * @param listener Callback listener * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file, SendListener listener) { FileSendPacket entity = new FileSendPacket(file, listener); send(entity); return entity; } /** * Send byte array to queue * * @param bytes Byte array * @return ByteSendEntity {@link ByteSendPacket} */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue; /** * Send file to queue * * @param file File * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file) { return send(file, null); } /** * Send file to queue * * @param file File * @param listener Callback listener * @return FileSendEntity {@link FileSendPacket} */ public FileSendPacket send(File file, SendListener listener) { FileSendPacket entity = new FileSendPacket(file, listener); send(entity); return entity; } /** * Send byte array to queue * * @param bytes Byte array * @return ByteSendEntity {@link ByteSendPacket} */
public ByteSendPacket send(byte[] bytes) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue;
/** * Send byte array to queue * * @param bytes Byte array * @return ByteSendEntity {@link ByteSendPacket} */ public ByteSendPacket send(byte[] bytes) { return send(bytes, null); } /** * Send byte array to queue * * @param bytes Byte array * @param listener Callback listener * @return ByteSendEntity {@link ByteSendPacket} */ public ByteSendPacket send(byte[] bytes, SendListener listener) { ByteSendPacket entity = new ByteSendPacket(bytes, listener); send(entity); return entity; } /** * Send string to queue * * @param str String msg * @return StringSendEntity {@link StringSendPacket} */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java // public class ByteSendPacket extends BaseSendPacket<byte[]> { // public ByteSendPacket(byte[] entity) { // this(entity, null); // } // // public ByteSendPacket(byte[] entity, SendListener listener) { // super(entity, PacketType.BYTES, listener); // mLength = mEntity.length; // } // // @Override // public boolean startPacket() { // try { // mStream = new ByteArrayInputStream(mEntity); // return true; // } catch (Exception e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java // public class FileSendPacket extends BaseSendPacket<File> { // // public FileSendPacket(File file) { // this(file, null); // } // // public FileSendPacket(File entity, SendListener listener) { // super(entity, PacketType.FILE, listener); // mLength = mEntity.length(); // } // // @Override // public boolean startPacket() { // try { // mStream = new FileInputStream(mEntity); // return true; // } catch (FileNotFoundException e) { // return false; // } // } // // @Override // public void endPacket() { // closeStream(); // } // // @Override // public short readInfo(byte[] buffer, int index) { // try { // byte[] info = mEntity.getName().getBytes("UTF-8"); // short len = (short) info.length; // System.arraycopy(info, 0, buffer, index, len); // return len; // } catch (Exception e) { // return 0; // } // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java // public class StringSendPacket extends ByteSendPacket { // public StringSendPacket(String entity) throws UnsupportedEncodingException { // this(entity, null); // } // // public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException { // super(entity.getBytes("UTF-8"), listener); // // mType = PacketType.STRING; // } // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java import net.qiujuer.blink.box.ByteSendPacket; import net.qiujuer.blink.box.FileSendPacket; import net.qiujuer.blink.box.StringSendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.concurrent.PriorityBlockingQueue; /** * Send byte array to queue * * @param bytes Byte array * @return ByteSendEntity {@link ByteSendPacket} */ public ByteSendPacket send(byte[] bytes) { return send(bytes, null); } /** * Send byte array to queue * * @param bytes Byte array * @param listener Callback listener * @return ByteSendEntity {@link ByteSendPacket} */ public ByteSendPacket send(byte[] bytes, SendListener listener) { ByteSendPacket entity = new ByteSendPacket(bytes, listener); send(entity); return entity; } /** * Send string to queue * * @param str String msg * @return StringSendEntity {@link StringSendPacket} */
public StringSendPacket send(String str) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/box/FileSendPacket.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // }
import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 03/31/2015 * Changed 04/02/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * File send class */ public class FileSendPacket extends SendPacket<File> { public FileSendPacket(File file) { this(file, null); }
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java // public interface SendListener { // /** // * On sender send the packet call this // * On start progress == 0 // * On end progress ==1 // * // * @param progress Send progress (0~1) // */ // void onSendProgress(float progress); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/box/FileSendPacket.java import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.SendListener; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 03/31/2015 * Changed 04/02/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.box; /** * File send class */ public class FileSendPacket extends SendPacket<File> { public FileSendPacket(File file) { this(file, null); }
public FileSendPacket(File entity, SendListener listener) {
qiujuer/Blink
Android/Blink/old/src/main/java/net/qiujuer/blink/ExecutorDelivery.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/ReceiveDelivery.java // public interface ReceiveDelivery { // /** // * Parses a start response from the receiver. // * // * @param entity ReceivePacket // */ // void postReceiveStart(ReceivePacket entity); // // /** // * Parses a end response from the receiver. // * // * @param entity ReceivePacket // * @param isSuccess isSuccess // */ // void postReceiveEnd(ReceivePacket entity, boolean isSuccess); // // /** // * Parses a progress response from the receiver. // * // * @param entity ReceivePacket // * @param progress Receive progress // */ // void postReceiveProgress(ReceivePacket entity, float progress); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendDelivery.java // public interface SendDelivery extends Disposable { // // /** // * Parses a progress response from the sender. // * // * @param entity SendPacket // * @param progress Send progress // */ // void postSendProgress(SendPacket entity, float progress); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param type Packet Type // * @param id Packet Id // */ // void onReceiveStart(byte type, long id); // // /** // * Receiver receive packet progress // * // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param packet ReceivePacket // */ // void onReceiveEnd(ReceivePacket packet); // }
import android.os.Handler; import net.qiujuer.blink.core.ReceiveDelivery; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.SendDelivery; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.ReceiveListener; import java.util.concurrent.Executor;
@Override public void execute(Runnable command) { handler.post(command); } }; } public ExecutorDelivery(Executor executor, ReceiveListener listener) { super(listener); mPoster = executor; } @Override public void postSendStart(SendPacket entity) { mPoster.execute(new SendDeliveryRunnable(entity, null, false)); } @Override public void postSendEnd(SendPacket entity, boolean isSuccess) { entity.setSuccess(isSuccess); mPoster.execute(new SendDeliveryRunnable(entity, null, true)); } @Override public void postSendProgress(SendPacket entity, int total, int cur) { ProgressStatus status = new ProgressStatus(total, cur); mPoster.execute(new SendDeliveryRunnable(entity, status, false)); } @Override
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/ReceiveDelivery.java // public interface ReceiveDelivery { // /** // * Parses a start response from the receiver. // * // * @param entity ReceivePacket // */ // void postReceiveStart(ReceivePacket entity); // // /** // * Parses a end response from the receiver. // * // * @param entity ReceivePacket // * @param isSuccess isSuccess // */ // void postReceiveEnd(ReceivePacket entity, boolean isSuccess); // // /** // * Parses a progress response from the receiver. // * // * @param entity ReceivePacket // * @param progress Receive progress // */ // void postReceiveProgress(ReceivePacket entity, float progress); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendDelivery.java // public interface SendDelivery extends Disposable { // // /** // * Parses a progress response from the sender. // * // * @param entity SendPacket // * @param progress Send progress // */ // void postSendProgress(SendPacket entity, float progress); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java // public abstract class SendPacket extends BlinkPacket { // private final SendListener mListener; // private boolean mCanceled; // private BlinkConn mBlinkConn; // // // public SendPacket(byte type, SendListener listener) { // super(type); // mListener = listener; // } // // public SendListener getListener() { // return mListener; // } // // /** // * Cancel the packet to send // * If the packet on sending you can't cancel it // * But you can cancel sending notify callback // */ // public void cancel() { // mCanceled = true; // if (mBlinkConn != null) { // mBlinkConn.cancel(this); // mBlinkConn = null; // } // } // // /** // * Get the packet iscanceled // * // * @return Is Canceled // */ // public boolean isCanceled() { // return mCanceled; // } // // /** // * Set The BlinkConn to Cancel from queue // * // * @param blinkConn BlinkConn // * @return SendPacket // */ // SendPacket setBlinkConn(BlinkConn blinkConn) { // mBlinkConn = blinkConn; // return this; // } // // /** // * On Sender send the packet call this to send packet info // * The bytes in 0~32767 size // * // * @param buffer Send buffer // * @param index Buffer start index // * @return Read to buffer count // */ // public short readInfo(byte[] buffer, int index) { // return 0; // } // // /** // * Sender read same data to send // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer count // * @return Read to buffer count // */ // public abstract int read(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param type Packet Type // * @param id Packet Id // */ // void onReceiveStart(byte type, long id); // // /** // * Receiver receive packet progress // * // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param packet ReceivePacket // */ // void onReceiveEnd(ReceivePacket packet); // } // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/ExecutorDelivery.java import android.os.Handler; import net.qiujuer.blink.core.ReceiveDelivery; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.SendDelivery; import net.qiujuer.blink.core.SendPacket; import net.qiujuer.blink.listener.ReceiveListener; import java.util.concurrent.Executor; @Override public void execute(Runnable command) { handler.post(command); } }; } public ExecutorDelivery(Executor executor, ReceiveListener listener) { super(listener); mPoster = executor; } @Override public void postSendStart(SendPacket entity) { mPoster.execute(new SendDeliveryRunnable(entity, null, false)); } @Override public void postSendEnd(SendPacket entity, boolean isSuccess) { entity.setSuccess(isSuccess); mPoster.execute(new SendDeliveryRunnable(entity, null, true)); } @Override public void postSendProgress(SendPacket entity, int total, int cur) { ProgressStatus status = new ProgressStatus(total, cur); mPoster.execute(new SendDeliveryRunnable(entity, status, false)); } @Override
public void postReceiveStart(ReceivePacket entity) {
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/core/Connector.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ConnectListener.java // public interface ConnectListener { // // /** // * On Receive or Sender socket error call this // * // * @param connector Connector // */ // void onConnectClosed(Connector connector); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveStart(Connector connector, ReceivePacket packet); // // /** // * Receiver receive packet progress // * // * @param connector Connector // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(Connector connector, ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveCompleted(Connector connector, ReceivePacket packet); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // }
import net.qiujuer.blink.async.SelectorFactory; import net.qiujuer.blink.core.delivery.ConnectDelivery; import net.qiujuer.blink.core.delivery.ReceiveDelivery; import net.qiujuer.blink.core.delivery.SendDelivery; import net.qiujuer.blink.core.listener.ConnectListener; import net.qiujuer.blink.core.listener.ReceiveListener; import net.qiujuer.blink.kit.Disposable; import java.util.UUID;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/25/2015 * Changed 04/25/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * Connector */ public abstract class Connector implements Disposable { // Default buffer size public static final int DEFAULT_BUFFER_SIZE = 4096; // Default progress precision public static final float DEFAULT_PROGRESS_PRECISION = 0.001F; private String mId = UUID.randomUUID().toString(); private int mBufferSize = DEFAULT_BUFFER_SIZE; private float mProgressPrecision = DEFAULT_PROGRESS_PRECISION; protected boolean isClosed = true; protected Sender mSender; protected Receiver mReceiver;
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ConnectListener.java // public interface ConnectListener { // // /** // * On Receive or Sender socket error call this // * // * @param connector Connector // */ // void onConnectClosed(Connector connector); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveStart(Connector connector, ReceivePacket packet); // // /** // * Receiver receive packet progress // * // * @param connector Connector // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(Connector connector, ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveCompleted(Connector connector, ReceivePacket packet); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // } // Path: Java/Blink/library/src/net/qiujuer/blink/core/Connector.java import net.qiujuer.blink.async.SelectorFactory; import net.qiujuer.blink.core.delivery.ConnectDelivery; import net.qiujuer.blink.core.delivery.ReceiveDelivery; import net.qiujuer.blink.core.delivery.SendDelivery; import net.qiujuer.blink.core.listener.ConnectListener; import net.qiujuer.blink.core.listener.ReceiveListener; import net.qiujuer.blink.kit.Disposable; import java.util.UUID; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/25/2015 * Changed 04/25/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * Connector */ public abstract class Connector implements Disposable { // Default buffer size public static final int DEFAULT_BUFFER_SIZE = 4096; // Default progress precision public static final float DEFAULT_PROGRESS_PRECISION = 0.001F; private String mId = UUID.randomUUID().toString(); private int mBufferSize = DEFAULT_BUFFER_SIZE; private float mProgressPrecision = DEFAULT_PROGRESS_PRECISION; protected boolean isClosed = true; protected Sender mSender; protected Receiver mReceiver;
protected ConnectListener mConnectListener;
qiujuer/Blink
Java/Blink/library/src/net/qiujuer/blink/core/Connector.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ConnectListener.java // public interface ConnectListener { // // /** // * On Receive or Sender socket error call this // * // * @param connector Connector // */ // void onConnectClosed(Connector connector); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveStart(Connector connector, ReceivePacket packet); // // /** // * Receiver receive packet progress // * // * @param connector Connector // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(Connector connector, ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveCompleted(Connector connector, ReceivePacket packet); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // }
import net.qiujuer.blink.async.SelectorFactory; import net.qiujuer.blink.core.delivery.ConnectDelivery; import net.qiujuer.blink.core.delivery.ReceiveDelivery; import net.qiujuer.blink.core.delivery.SendDelivery; import net.qiujuer.blink.core.listener.ConnectListener; import net.qiujuer.blink.core.listener.ReceiveListener; import net.qiujuer.blink.kit.Disposable; import java.util.UUID;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/25/2015 * Changed 04/25/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * Connector */ public abstract class Connector implements Disposable { // Default buffer size public static final int DEFAULT_BUFFER_SIZE = 4096; // Default progress precision public static final float DEFAULT_PROGRESS_PRECISION = 0.001F; private String mId = UUID.randomUUID().toString(); private int mBufferSize = DEFAULT_BUFFER_SIZE; private float mProgressPrecision = DEFAULT_PROGRESS_PRECISION; protected boolean isClosed = true; protected Sender mSender; protected Receiver mReceiver; protected ConnectListener mConnectListener;
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ConnectListener.java // public interface ConnectListener { // // /** // * On Receive or Sender socket error call this // * // * @param connector Connector // */ // void onConnectClosed(Connector connector); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/ReceiveListener.java // public interface ReceiveListener { // /** // * On Receiver receive new packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveStart(Connector connector, ReceivePacket packet); // // /** // * Receiver receive packet progress // * // * @param connector Connector // * @param packet ReceivePacket // * @param progress Receive Progress // */ // void onReceiveProgress(Connector connector, ReceivePacket packet, float progress); // // /** // * On Receiver end receive packet call this // * // * @param connector Connector // * @param packet ReceivePacket // */ // void onReceiveCompleted(Connector connector, ReceivePacket packet); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/kit/Disposable.java // public interface Disposable { // /** // * Perform related to release or reset unmanaged resources application defined tasks. // */ // void dispose(); // } // Path: Java/Blink/library/src/net/qiujuer/blink/core/Connector.java import net.qiujuer.blink.async.SelectorFactory; import net.qiujuer.blink.core.delivery.ConnectDelivery; import net.qiujuer.blink.core.delivery.ReceiveDelivery; import net.qiujuer.blink.core.delivery.SendDelivery; import net.qiujuer.blink.core.listener.ConnectListener; import net.qiujuer.blink.core.listener.ReceiveListener; import net.qiujuer.blink.kit.Disposable; import java.util.UUID; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/25/2015 * Changed 04/25/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.core; /** * Connector */ public abstract class Connector implements Disposable { // Default buffer size public static final int DEFAULT_BUFFER_SIZE = 4096; // Default progress precision public static final float DEFAULT_PROGRESS_PRECISION = 0.001F; private String mId = UUID.randomUUID().toString(); private int mBufferSize = DEFAULT_BUFFER_SIZE; private float mProgressPrecision = DEFAULT_PROGRESS_PRECISION; protected boolean isClosed = true; protected Sender mSender; protected Receiver mReceiver; protected ConnectListener mConnectListener;
protected ReceiveListener mReceiveListener;
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncSocketAdapter.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkDelivery.java // public interface BlinkDelivery extends Disposable { // /** // * On Socket Disconnect Post CallBack // */ // void postBlinkDisconnect(); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Receiver.java // public interface Receiver extends Disposable { // /** // * Get receive buffer size // * // * @return Buffer Size // */ // int getReceiveBufferSize(); // // /** // * Async receive same data to buffer // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean receiveAsync(IoEventArgs e); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // }
import net.qiujuer.blink.core.BlinkDelivery; import net.qiujuer.blink.core.Receiver; import net.qiujuer.blink.core.Sender; import java.io.IOException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.concurrent.atomic.AtomicBoolean;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Async socket adapter to send and receive byte */ public class AsyncSocketAdapter implements Sender, Receiver, HandleSelector.HandleCallback { private int mBufferSize; private AsyncEventArgs mSendArgs; private AsyncEventArgs mReceiveArgs; private SocketChannel mChannel; // Is Disposed protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // Posting responses.
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkDelivery.java // public interface BlinkDelivery extends Disposable { // /** // * On Socket Disconnect Post CallBack // */ // void postBlinkDisconnect(); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Receiver.java // public interface Receiver extends Disposable { // /** // * Get receive buffer size // * // * @return Buffer Size // */ // int getReceiveBufferSize(); // // /** // * Async receive same data to buffer // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean receiveAsync(IoEventArgs e); // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/Sender.java // public interface Sender extends Disposable { // /** // * Get socket send buffer size // * // * @return Buffer Size // */ // int getSendBufferSize(); // // /** // * Async send same byte // * // * @param e SocketAsyncEventArgs // * @return Status // */ // boolean sendAsync(IoEventArgs e); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/async/AsyncSocketAdapter.java import net.qiujuer.blink.core.BlinkDelivery; import net.qiujuer.blink.core.Receiver; import net.qiujuer.blink.core.Sender; import java.io.IOException; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.concurrent.atomic.AtomicBoolean; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.async; /** * Async socket adapter to send and receive byte */ public class AsyncSocketAdapter implements Sender, Receiver, HandleSelector.HandleCallback { private int mBufferSize; private AsyncEventArgs mSendArgs; private AsyncEventArgs mReceiveArgs; private SocketChannel mChannel; // Is Disposed protected final AtomicBoolean mDisposed = new AtomicBoolean(false); // Posting responses.
private BlinkDelivery mBlinkDelivery;
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // }
import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0;
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0;
protected Resource mResource;
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // }
import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0; protected Resource mResource; public BlinkParserImpl(Resource resource) { mResource = resource; } @Override
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0; protected Resource mResource; public BlinkParserImpl(Resource resource) { mResource = resource; } @Override
public ReceivePacket parseReceive(byte type, long len) {
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // }
import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0; protected Resource mResource; public BlinkParserImpl(Resource resource) { mResource = resource; } @Override public ReceivePacket parseReceive(byte type, long len) { long id = ++mId; ReceivePacket packet = null; switch (type) {
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/BlinkPacket.java // public abstract class BlinkPacket implements Packet { // private boolean mSucceed; // protected byte mType; // protected long mLength; // // public BlinkPacket(byte type) { // mType = type; // } // // // @Override // public byte getPacketType() { // return mType; // } // // @Override // public long getLength() { // return mLength; // } // // @Override // public void setSuccess(boolean isSuccess) { // mSucceed = isSuccess; // } // // @Override // public boolean isSucceed() { // return mSucceed; // } // // /** // * On Send or Receive start call this // * // * @return Init status // */ // public abstract boolean startPacket(); // // /** // * On Send or Receive end call this // */ // public abstract void endPacket(); // // /** // * Blink Packet Type // */ // public static class PacketType { // public final static byte STRING = 1; // public final static byte BYTES = 2; // public final static byte FILE = 3; // } // } // // Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // // Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/Resource.java // public interface Resource<T> { // /** // * Create a file from resource. // * // * @return New file // */ // File create(long id); // // /** // * Change a file name // * // * @param file File // * @param newName New name // * @return Status // */ // boolean rename(File file, String newName); // // // /** // * Cut a file to new path // * // * @param oldFile File // * @param newPath New path // * @return New File // */ // File cut(File oldFile, String newPath); // // /** // * Cut a file to new path // * // * @param oldFile Old file // * @param newFile New file // * @return New file // */ // File cut(File oldFile, File newFile); // // // /** // * Removes a file from the resource. // * // * @param name File name // */ // void remove(String name); // // /** // * Removes a file from the resource. // * // * @param file File // */ // void remove(File file); // // /** // * Empties the resource by oneself // */ // void clear(); // // /** // * Empties the resource by the path // */ // void clearAll(); // // /** // * Get the Mark // * // * @return T // */ // T getMark(); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/kit/BlinkParserImpl.java import net.qiujuer.blink.box.ByteReceivePacket; import net.qiujuer.blink.box.FileReceivePacket; import net.qiujuer.blink.box.StringReceivePacket; import net.qiujuer.blink.core.BlinkPacket; import net.qiujuer.blink.core.BlinkParser; import net.qiujuer.blink.core.ReceivePacket; import net.qiujuer.blink.core.Resource; import java.io.File; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.kit; public class BlinkParserImpl implements BlinkParser { private long mId = 0; protected Resource mResource; public BlinkParserImpl(Resource resource) { mResource = resource; } @Override public ReceivePacket parseReceive(byte type, long len) { long id = ++mId; ReceivePacket packet = null; switch (type) {
case BlinkPacket.PacketType.STRING:
qiujuer/Blink
Android/Blink/library/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java
// Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // }
import net.qiujuer.blink.core.ReceivePacket;
/* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.listener; /** * Receive notify listener */ public interface ReceiveListener { /** * On Receiver receive new packet call this * * @param type Packet Type * @param id Packet Id */ void onReceiveStart(byte type, long id); /** * Receiver receive packet progress * * @param packet ReceivePacket * @param progress Receive Progress */
// Path: Java/Blink/library/src/net/qiujuer/blink/core/ReceivePacket.java // public abstract class ReceivePacket extends Packet { // private final long mId; // private String mHash; // // public ReceivePacket(long id, byte type, long len) { // super(type); // mId = id; // mLength = len; // } // // public long getId() { // return mId; // } // // /** // * Set Packet Hash Code // * // * @param hashCode HashCode // */ // public void setHash(String hashCode) { // mHash = hashCode; // } // // /** // * Get Packet Hash Code // * // * @return HashCode // */ // public String getHash() { // return mHash; // } // // /** // * On Receiver receive same info buffer call this // * // * @param bytes Info data // */ // public void setInfo(byte[] bytes) { // } // // /** // * Receiver write buffer // * // * @param buffer Buffer // * @param offset Buffer offset // * @param count Buffer Count // */ // public abstract void write(byte[] buffer, int offset, int count); // } // Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/ReceiveListener.java import net.qiujuer.blink.core.ReceivePacket; /* * Copyright (C) 2014 Qiujuer <qiujuer@live.cn> * WebSite http://www.qiujuer.net * Created 04/16/2015 * Changed 04/19/2015 * Version 1.0.0 * * 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 net.qiujuer.blink.listener; /** * Receive notify listener */ public interface ReceiveListener { /** * On Receiver receive new packet call this * * @param type Packet Type * @param id Packet Id */ void onReceiveStart(byte type, long id); /** * Receiver receive packet progress * * @param packet ReceivePacket * @param progress Receive Progress */
void onReceiveProgress(ReceivePacket packet, float progress);
cammace/iGuide
app/src/main/java/team6/iguide/Graphhopper.java
// Path: app/src/main/java/team6/iguide/GraphhopperModel/GraphhopperModel.java // public class GraphhopperModel implements Serializable { // // @Expose // private Hints hints; // @Expose // private List<Path> paths = new ArrayList<Path>(); // @Expose // private Info info; // // public Hints getHints() { // return hints; // } // // public void setHints(Hints hints) { // this.hints = hints; // } // // public List<Path> getPaths() { // return paths; // } // // public void setPaths(List<Path> paths) { // this.paths = paths; // } // // public Info getInfo() { // return info; // } // // public void setInfo(Info info) { // this.info = info; // } // // }
import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import org.json.JSONObject; import team6.iguide.GraphhopperModel.GraphhopperModel; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Graphhopper{ // Graphhopper is used for our routing/navigation. Its soon to be removed in favor for Mapzen's routing private RequestQueue mRequestQueue; //MapView mv;
// Path: app/src/main/java/team6/iguide/GraphhopperModel/GraphhopperModel.java // public class GraphhopperModel implements Serializable { // // @Expose // private Hints hints; // @Expose // private List<Path> paths = new ArrayList<Path>(); // @Expose // private Info info; // // public Hints getHints() { // return hints; // } // // public void setHints(Hints hints) { // this.hints = hints; // } // // public List<Path> getPaths() { // return paths; // } // // public void setPaths(List<Path> paths) { // this.paths = paths; // } // // public Info getInfo() { // return info; // } // // public void setInfo(Info info) { // this.info = info; // } // // } // Path: app/src/main/java/team6/iguide/Graphhopper.java import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import org.json.JSONObject; import team6.iguide.GraphhopperModel.GraphhopperModel; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Graphhopper{ // Graphhopper is used for our routing/navigation. Its soon to be removed in favor for Mapzen's routing private RequestQueue mRequestQueue; //MapView mv;
GraphhopperModel routeInfo;
cammace/iGuide
app/src/main/java/team6/iguide/GetParkingLots.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class GetParkingLots { MapView mv; private RequestQueue mRequestQueue;
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/GetParkingLots.java import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class GetParkingLots { MapView mv; private RequestQueue mRequestQueue;
OverpassModel results;
cammace/iGuide
app/src/main/java/team6/iguide/GetParkingLots.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
addToList(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("GetParkingLots.Volley", "onErrorResponse ", error); if(requestAttempt < 3){ requestAttempt++; fetchJsonResponse(URI); } else Snackbar.make(MainActivity.mapContainer, "Can't get Parking information", Snackbar.LENGTH_LONG).show(); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } private void addToList(){
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/GetParkingLots.java import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; addToList(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("GetParkingLots.Volley", "onErrorResponse ", error); if(requestAttempt < 3){ requestAttempt++; fetchJsonResponse(URI); } else Snackbar.make(MainActivity.mapContainer, "Can't get Parking information", Snackbar.LENGTH_LONG).show(); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } private void addToList(){
List<OverpassElement> q = results.getElements();
cammace/iGuide
app/src/main/java/team6/iguide/CampusIssueInfoWindow.java
// Path: app/src/main/java/team6/iguide/IssueDataModel/IssueMarker.java // public class IssueMarker { // // @SerializedName("pid") // @Expose // private int pid; // @SerializedName("type") // @Expose // private String type; // @SerializedName("status") // @Expose // private String status; // @SerializedName("room") // @Expose // private String room; // @SerializedName("title") // @Expose // private String title; // @SerializedName("description") // @Expose // private String description; // @SerializedName("markerLat") // @Expose // private Double markerLat; // @SerializedName("markerLon") // @Expose // private Double markerLon; // @SerializedName("createdAt") // @Expose // private String createdAt; // @SerializedName("updatedAt") // @Expose // private String updatedAt; // // // public int getPid() { // return pid; // } // // public void setPid(int pid) { // this.pid = pid; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getRoom() { // return room; // } // // public void setRoom(String room) { // this.room = room; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Double getMarkerLat() { // return markerLat; // } // // public void setMarkerLat(Double markerLat) { // this.markerLat = markerLat; // } // // public Double getMarkerLon() { // return markerLon; // } // // public void setMarkerLon(Double markerLon) { // this.markerLon = markerLon; // } // // public String getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(String createdAt) { // this.createdAt = createdAt; // } // // public String getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(String updatedAt) { // this.updatedAt = updatedAt; // } // // }
import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.android.volley.DefaultRetryPolicy; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.InfoWindow; import com.mapbox.mapboxsdk.views.MapView; import java.util.List; import team6.iguide.IssueDataModel.IssueMarker;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class CampusIssueInfoWindow extends InfoWindow { // This class is used to handle what happens when an issue marker is clicked. private Context mContext; String title; String ref; String shortTitle; String shortRef;
// Path: app/src/main/java/team6/iguide/IssueDataModel/IssueMarker.java // public class IssueMarker { // // @SerializedName("pid") // @Expose // private int pid; // @SerializedName("type") // @Expose // private String type; // @SerializedName("status") // @Expose // private String status; // @SerializedName("room") // @Expose // private String room; // @SerializedName("title") // @Expose // private String title; // @SerializedName("description") // @Expose // private String description; // @SerializedName("markerLat") // @Expose // private Double markerLat; // @SerializedName("markerLon") // @Expose // private Double markerLon; // @SerializedName("createdAt") // @Expose // private String createdAt; // @SerializedName("updatedAt") // @Expose // private String updatedAt; // // // public int getPid() { // return pid; // } // // public void setPid(int pid) { // this.pid = pid; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public String getRoom() { // return room; // } // // public void setRoom(String room) { // this.room = room; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public Double getMarkerLat() { // return markerLat; // } // // public void setMarkerLat(Double markerLat) { // this.markerLat = markerLat; // } // // public Double getMarkerLon() { // return markerLon; // } // // public void setMarkerLon(Double markerLon) { // this.markerLon = markerLon; // } // // public String getCreatedAt() { // return createdAt; // } // // public void setCreatedAt(String createdAt) { // this.createdAt = createdAt; // } // // public String getUpdatedAt() { // return updatedAt; // } // // public void setUpdatedAt(String updatedAt) { // this.updatedAt = updatedAt; // } // // } // Path: app/src/main/java/team6/iguide/CampusIssueInfoWindow.java import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.android.volley.DefaultRetryPolicy; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.InfoWindow; import com.mapbox.mapboxsdk.views.MapView; import java.util.List; import team6.iguide.IssueDataModel.IssueMarker; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class CampusIssueInfoWindow extends InfoWindow { // This class is used to handle what happens when an issue marker is clicked. private Context mContext; String title; String ref; String shortTitle; String shortRef;
public CampusIssueInfoWindow(final Context context, final Activity activity, final MapView mv, final List<IssueMarker> issueInfo, final int position) {
cammace/iGuide
app/src/main/java/team6/iguide/Search.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Search { // When user searches for something, executeSearch is called. MapView mv; private RequestQueue mRequestQueue;
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/Search.java import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Search { // When user searches for something, executeSearch is called. MapView mv; private RequestQueue mRequestQueue;
OverpassModel results;
cammace/iGuide
app/src/main/java/team6/iguide/Search.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
@Override public void onErrorResponse(VolleyError error) { Log.e("Search.Volley", "onErrorResponse ", error); if(requestAttempt < 3){ Snackbar.make(MainActivity.mapContainer, "Search taking longer then unusual", Snackbar.LENGTH_SHORT).show(); requestAttempt++; fetchJsonResponse(URI); } else { Snackbar.make(MainActivity.mapContainer,"Search Timed out, Check your internet", Snackbar.LENGTH_LONG).show(); progressBar.setVisibility(View.INVISIBLE); } } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } public void showSearchResults() { // This is the method used to show results on the map and move the camera. This methods // honestly really messy coding due to the fact that there's so many different possibilities // the JSON can give us, you've been warned!
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/Search.java import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; @Override public void onErrorResponse(VolleyError error) { Log.e("Search.Volley", "onErrorResponse ", error); if(requestAttempt < 3){ Snackbar.make(MainActivity.mapContainer, "Search taking longer then unusual", Snackbar.LENGTH_SHORT).show(); requestAttempt++; fetchJsonResponse(URI); } else { Snackbar.make(MainActivity.mapContainer,"Search Timed out, Check your internet", Snackbar.LENGTH_LONG).show(); progressBar.setVisibility(View.INVISIBLE); } } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } public void showSearchResults() { // This is the method used to show results on the map and move the camera. This methods // honestly really messy coding due to the fact that there's so many different possibilities // the JSON can give us, you've been warned!
List<OverpassElement> q = results.getElements();
cammace/iGuide
app/src/main/java/team6/iguide/PointOfInterest.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
package team6.iguide; /** * iGuide * Copyright (C) 2015 Cameron Mace * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class PointOfInterest { MapView mv; private RequestQueue mRequestQueue;
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/PointOfInterest.java import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; package team6.iguide; /** * iGuide * Copyright (C) 2015 Cameron Mace * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class PointOfInterest { MapView mv; private RequestQueue mRequestQueue;
OverpassModel results;
cammace/iGuide
app/src/main/java/team6/iguide/PointOfInterest.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
@Override public void onResponse(JSONObject response) { Gson gson = new Gson(); String overpassData = response.toString(); results = gson.fromJson(overpassData, OverpassModel.class); showSearchResults(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("PointOfInterest", error.toString()); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); }// End fetchJsonResponse public void showSearchResults() {
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/PointOfInterest.java import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; @Override public void onResponse(JSONObject response) { Gson gson = new Gson(); String overpassData = response.toString(); results = gson.fromJson(overpassData, OverpassModel.class); showSearchResults(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("PointOfInterest", error.toString()); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); }// End fetchJsonResponse public void showSearchResults() {
List<OverpassElement> parsedList = results.getElements();
cammace/iGuide
app/src/main/java/team6/iguide/GetBusStops.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class GetBusStops { // This class is used to get the bus stops on OpenStreetMap. MapView mv; MainActivity mainActivity = new MainActivity(); String boundingBox = "(29.709354854765827,-95.35668790340424,29.731896194504913,-95.31928449869156);"; private RequestQueue mRequestQueue;
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/GetBusStops.java import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class GetBusStops { // This class is used to get the bus stops on OpenStreetMap. MapView mv; MainActivity mainActivity = new MainActivity(); String boundingBox = "(29.709354854765827,-95.35668790340424,29.731896194504913,-95.31928449869156);"; private RequestQueue mRequestQueue;
OverpassModel results;
cammace/iGuide
app/src/main/java/team6/iguide/GetBusStops.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel;
Gson gson = new Gson(); String overpassData = response.toString(); results = gson.fromJson(overpassData, OverpassModel.class); showSearchResults(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("GetBusStops.Volley", "onErrorResponse ", error); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } public void showSearchResults() {
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // // Path: app/src/main/java/team6/iguide/OverpassModel/OverpassModel.java // public class OverpassModel implements Serializable{ // // @Expose // private String version; // @Expose // private String generator; // @Expose // private OverpassOsm3s osm3s; // @Expose // private List<OverpassElement> elements = new ArrayList<>(); // // // public String getVersion() { // return version; // } // // public void setVersion(String version) { // this.version = version; // } // // public String getGenerator() { // return generator; // } // // public void setGenerator(String generator) { // this.generator = generator; // } // // public OverpassOsm3s getOsm3s() { // return osm3s; // } // // public void setOsm3s(OverpassOsm3s osm3s) { // this.osm3s = osm3s; // } // // public List<OverpassElement> getElements() { // return elements; // } // // public void setElements(List<OverpassElement> elements) { // this.elements = elements; // } // // } // Path: app/src/main/java/team6/iguide/GetBusStops.java import android.content.Context; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import team6.iguide.OverpassModel.OverpassModel; Gson gson = new Gson(); String overpassData = response.toString(); results = gson.fromJson(overpassData, OverpassModel.class); showSearchResults(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("GetBusStops.Volley", "onErrorResponse ", error); } }); mRequestQueue.add(req); // This allows volley to retry request if for some reason it times out the first time // More info can be found in this question: // http://stackoverflow.com/questions/17094718/android-volley-timeout req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } public void showSearchResults() {
List<OverpassElement> parsedList = results.getElements();
cammace/iGuide
app/src/main/java/team6/iguide/CustomInfoWindow.java
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // }
import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.InfoWindow; import com.mapbox.mapboxsdk.views.MapView; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.mapbox.mapboxsdk.geometry.BoundingBox;
package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class CustomInfoWindow extends InfoWindow { // This is where we define what happens when the user clicks on a marker. private Context mContext; private String title; private String ref; private String address; private String country; private Double desLat; private Double desLon; private BoundingBox scrollLimit = new BoundingBox(29.731896194504913, -95.31928449869156, 29.709354854765827, -95.35668790340424);
// Path: app/src/main/java/team6/iguide/OverpassModel/OverpassElement.java // public class OverpassElement implements Serializable{ // // @Expose // private String type; // @Expose // private Long id; // @Expose // private OverpassCenter center; // @Expose // private List<Long> nodes = new ArrayList<Long>(); // @Expose // private OverpassTags tags; // @Expose // private Double lat; // @Expose // private Double lon; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public OverpassCenter getCenter() { // return center; // } // // public void setCenter(OverpassCenter center) { // this.center = center; // } // // public List<Long> getNodes() { // return nodes; // } // // public void setNodes(List<Long> nodes) { // this.nodes = nodes; // } // // public OverpassTags getTags() { // return tags; // } // // public void setTags(OverpassTags tags) { // this.tags = tags; // } // // public Double getLat() { // return lat; // } // // public void setLat(Double lat) { // this.lat = lat; // } // // public Double getLon() { // return lon; // } // // public void setLon(Double lon) { // this.lon = lon; // } // // } // Path: app/src/main/java/team6/iguide/CustomInfoWindow.java import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.views.InfoWindow; import com.mapbox.mapboxsdk.views.MapView; import java.util.List; import team6.iguide.OverpassModel.OverpassElement; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import com.mapbox.mapboxsdk.geometry.BoundingBox; package team6.iguide; /*** iGuide Copyright (C) 2015 Cameron Mace This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class CustomInfoWindow extends InfoWindow { // This is where we define what happens when the user clicks on a marker. private Context mContext; private String title; private String ref; private String address; private String country; private Double desLat; private Double desLon; private BoundingBox scrollLimit = new BoundingBox(29.731896194504913, -95.31928449869156, 29.709354854765827, -95.35668790340424);
public CustomInfoWindow(Context context, final MapView mv, final List<OverpassElement> searchResults, final int listPosition) {
cammace/iGuide
app/src/main/java/team6/iguide/MainActivity.java
// Path: app/src/main/java/team6/iguide/BusLocation/BusLocation.java // public class BusLocation { // // @SerializedName("get_vehicles") // @Expose // private List<GetVehicle> getVehicles = new ArrayList<GetVehicle>(); // // /** // * // * @return // * The getVehicles // */ // public List<GetVehicle> getGetVehicles() { // return getVehicles; // } // // /** // * // * @param getVehicles // * The get_vehicles // */ // public void setGetVehicles(List<GetVehicle> getVehicles) { // this.getVehicles = getVehicles; // } // // } // // Path: app/src/main/java/team6/iguide/IssueDataModel/IssueDataModel.java // public class IssueDataModel { // // @SerializedName("markers") // @Expose // private List<IssueMarker> markers = new ArrayList<IssueMarker>(); // // public List<IssueMarker> getMarkers() { // return markers; // } // // public void setMarkers(List<IssueMarker> markers) { // this.markers = markers; // } // // }
import android.app.ActionBar; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.provider.SearchRecentSuggestions; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ExpandableListView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.api.ILatLng; import com.mapbox.mapboxsdk.events.DelayedMapListener; import com.mapbox.mapboxsdk.events.MapListener; import com.mapbox.mapboxsdk.events.RotateEvent; import com.mapbox.mapboxsdk.events.ScrollEvent; import com.mapbox.mapboxsdk.events.ZoomEvent; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.MapEventsOverlay; import com.mapbox.mapboxsdk.overlay.MapEventsReceiver; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.overlay.TilesOverlay; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBase; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBasic; import com.mapbox.mapboxsdk.tileprovider.tilesource.MapboxTileLayer; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import team6.iguide.BusLocation.BusLocation; import team6.iguide.IssueDataModel.IssueDataModel;
// Handle click } }); if(!userReportedIssue) campusIssueSnack.show(); else{ userReportedIssue = false; Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { campusIssueSnack.show(); } }, 5000); } campusIssueMarkersVisable = true; // Create volley queue mRequestQueue = Volley.newRequestQueue(getApplicationContext()); String URI = "http://iguide.heliohost.org/get_all_markers.php"; // we begin by fetching the json data using volley JsonObjectRequest req = new JsonObjectRequest(URI, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // Parse the JSON response Gson gson = new Gson(); String issueData = response.toString();
// Path: app/src/main/java/team6/iguide/BusLocation/BusLocation.java // public class BusLocation { // // @SerializedName("get_vehicles") // @Expose // private List<GetVehicle> getVehicles = new ArrayList<GetVehicle>(); // // /** // * // * @return // * The getVehicles // */ // public List<GetVehicle> getGetVehicles() { // return getVehicles; // } // // /** // * // * @param getVehicles // * The get_vehicles // */ // public void setGetVehicles(List<GetVehicle> getVehicles) { // this.getVehicles = getVehicles; // } // // } // // Path: app/src/main/java/team6/iguide/IssueDataModel/IssueDataModel.java // public class IssueDataModel { // // @SerializedName("markers") // @Expose // private List<IssueMarker> markers = new ArrayList<IssueMarker>(); // // public List<IssueMarker> getMarkers() { // return markers; // } // // public void setMarkers(List<IssueMarker> markers) { // this.markers = markers; // } // // } // Path: app/src/main/java/team6/iguide/MainActivity.java import android.app.ActionBar; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.provider.SearchRecentSuggestions; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ExpandableListView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.api.ILatLng; import com.mapbox.mapboxsdk.events.DelayedMapListener; import com.mapbox.mapboxsdk.events.MapListener; import com.mapbox.mapboxsdk.events.RotateEvent; import com.mapbox.mapboxsdk.events.ScrollEvent; import com.mapbox.mapboxsdk.events.ZoomEvent; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.MapEventsOverlay; import com.mapbox.mapboxsdk.overlay.MapEventsReceiver; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.overlay.TilesOverlay; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBase; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBasic; import com.mapbox.mapboxsdk.tileprovider.tilesource.MapboxTileLayer; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import team6.iguide.BusLocation.BusLocation; import team6.iguide.IssueDataModel.IssueDataModel; // Handle click } }); if(!userReportedIssue) campusIssueSnack.show(); else{ userReportedIssue = false; Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { campusIssueSnack.show(); } }, 5000); } campusIssueMarkersVisable = true; // Create volley queue mRequestQueue = Volley.newRequestQueue(getApplicationContext()); String URI = "http://iguide.heliohost.org/get_all_markers.php"; // we begin by fetching the json data using volley JsonObjectRequest req = new JsonObjectRequest(URI, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // Parse the JSON response Gson gson = new Gson(); String issueData = response.toString();
IssueDataModel issueDataModel = gson.fromJson(issueData, IssueDataModel.class);
cammace/iGuide
app/src/main/java/team6/iguide/MainActivity.java
// Path: app/src/main/java/team6/iguide/BusLocation/BusLocation.java // public class BusLocation { // // @SerializedName("get_vehicles") // @Expose // private List<GetVehicle> getVehicles = new ArrayList<GetVehicle>(); // // /** // * // * @return // * The getVehicles // */ // public List<GetVehicle> getGetVehicles() { // return getVehicles; // } // // /** // * // * @param getVehicles // * The get_vehicles // */ // public void setGetVehicles(List<GetVehicle> getVehicles) { // this.getVehicles = getVehicles; // } // // } // // Path: app/src/main/java/team6/iguide/IssueDataModel/IssueDataModel.java // public class IssueDataModel { // // @SerializedName("markers") // @Expose // private List<IssueMarker> markers = new ArrayList<IssueMarker>(); // // public List<IssueMarker> getMarkers() { // return markers; // } // // public void setMarkers(List<IssueMarker> markers) { // this.markers = markers; // } // // }
import android.app.ActionBar; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.provider.SearchRecentSuggestions; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ExpandableListView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.api.ILatLng; import com.mapbox.mapboxsdk.events.DelayedMapListener; import com.mapbox.mapboxsdk.events.MapListener; import com.mapbox.mapboxsdk.events.RotateEvent; import com.mapbox.mapboxsdk.events.ScrollEvent; import com.mapbox.mapboxsdk.events.ZoomEvent; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.MapEventsOverlay; import com.mapbox.mapboxsdk.overlay.MapEventsReceiver; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.overlay.TilesOverlay; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBase; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBasic; import com.mapbox.mapboxsdk.tileprovider.tilesource.MapboxTileLayer; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import team6.iguide.BusLocation.BusLocation; import team6.iguide.IssueDataModel.IssueDataModel;
), true, true); break; case 4: mv.getOverlays().add(0, erpExpressTiles); padding = 0.005; mv.zoomToBoundingBox(new BoundingBox( 29.72886830436441 + padding, // North -95.32023668289185 + padding, // East 29.716345843815365 - padding,// South -95.34223079681395 - padding // West ), true, true); break; } // Refresh map so it shows the overlay mv.invalidate(); } @SuppressWarnings("unchecked") private void updateCurrentBusLocation(String URI, final int busRoute) { // This method is used to fetch json, parse it, and then update/create the list that tells // where to move the bus markers next. // we begin by fetching the json data using volley JsonObjectRequest req = new JsonObjectRequest(URI, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // Parse the JSON response Gson gson = new Gson(); String busData = response.toString();
// Path: app/src/main/java/team6/iguide/BusLocation/BusLocation.java // public class BusLocation { // // @SerializedName("get_vehicles") // @Expose // private List<GetVehicle> getVehicles = new ArrayList<GetVehicle>(); // // /** // * // * @return // * The getVehicles // */ // public List<GetVehicle> getGetVehicles() { // return getVehicles; // } // // /** // * // * @param getVehicles // * The get_vehicles // */ // public void setGetVehicles(List<GetVehicle> getVehicles) { // this.getVehicles = getVehicles; // } // // } // // Path: app/src/main/java/team6/iguide/IssueDataModel/IssueDataModel.java // public class IssueDataModel { // // @SerializedName("markers") // @Expose // private List<IssueMarker> markers = new ArrayList<IssueMarker>(); // // public List<IssueMarker> getMarkers() { // return markers; // } // // public void setMarkers(List<IssueMarker> markers) { // this.markers = markers; // } // // } // Path: app/src/main/java/team6/iguide/MainActivity.java import android.app.ActionBar; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.provider.SearchRecentSuggestions; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.ExpandableListView; import android.widget.LinearLayout; import android.widget.PopupMenu; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.google.gson.Gson; import com.mapbox.mapboxsdk.api.ILatLng; import com.mapbox.mapboxsdk.events.DelayedMapListener; import com.mapbox.mapboxsdk.events.MapListener; import com.mapbox.mapboxsdk.events.RotateEvent; import com.mapbox.mapboxsdk.events.ScrollEvent; import com.mapbox.mapboxsdk.events.ZoomEvent; import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.overlay.MapEventsOverlay; import com.mapbox.mapboxsdk.overlay.MapEventsReceiver; import com.mapbox.mapboxsdk.overlay.Marker; import com.mapbox.mapboxsdk.overlay.TilesOverlay; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBase; import com.mapbox.mapboxsdk.tileprovider.MapTileLayerBasic; import com.mapbox.mapboxsdk.tileprovider.tilesource.MapboxTileLayer; import com.mapbox.mapboxsdk.views.MapView; import org.json.JSONObject; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import team6.iguide.BusLocation.BusLocation; import team6.iguide.IssueDataModel.IssueDataModel; ), true, true); break; case 4: mv.getOverlays().add(0, erpExpressTiles); padding = 0.005; mv.zoomToBoundingBox(new BoundingBox( 29.72886830436441 + padding, // North -95.32023668289185 + padding, // East 29.716345843815365 - padding,// South -95.34223079681395 - padding // West ), true, true); break; } // Refresh map so it shows the overlay mv.invalidate(); } @SuppressWarnings("unchecked") private void updateCurrentBusLocation(String URI, final int busRoute) { // This method is used to fetch json, parse it, and then update/create the list that tells // where to move the bus markers next. // we begin by fetching the json data using volley JsonObjectRequest req = new JsonObjectRequest(URI, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // Parse the JSON response Gson gson = new Gson(); String busData = response.toString();
BusLocation busInfo = gson.fromJson(busData, BusLocation.class);
DukeNLIDB/NLIDB
src/main/java/com/dukenlidb/nlidb/service/DBConnectionService.java
// Path: src/main/java/com/dukenlidb/nlidb/model/DBConnectionConfig.java // @Builder // @Value // public class DBConnectionConfig { // // String host; // String port; // String database; // String username; // String password; // // @JsonIgnore // public String getUrl() { // return "jdbc:postgresql://" // + host + ":" + port // + "/" + database; // } // // @JsonIgnore // public Properties getProperties() { // Properties props = new Properties(); // props.setProperty("user", username); // props.setProperty("password", password); // return props; // } // // }
import org.springframework.stereotype.Service; import com.dukenlidb.nlidb.model.DBConnectionConfig; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
package com.dukenlidb.nlidb.service; @Service public class DBConnectionService {
// Path: src/main/java/com/dukenlidb/nlidb/model/DBConnectionConfig.java // @Builder // @Value // public class DBConnectionConfig { // // String host; // String port; // String database; // String username; // String password; // // @JsonIgnore // public String getUrl() { // return "jdbc:postgresql://" // + host + ":" + port // + "/" + database; // } // // @JsonIgnore // public Properties getProperties() { // Properties props = new Properties(); // props.setProperty("user", username); // props.setProperty("password", password); // return props; // } // // } // Path: src/main/java/com/dukenlidb/nlidb/service/DBConnectionService.java import org.springframework.stereotype.Service; import com.dukenlidb.nlidb.model.DBConnectionConfig; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; package com.dukenlidb.nlidb.service; @Service public class DBConnectionService {
public Connection getConnection(DBConnectionConfig config) throws SQLException {
DukeNLIDB/NLIDB
src/main/java/com/dukenlidb/nlidb/service/RedisService.java
// Path: src/main/java/com/dukenlidb/nlidb/model/UserSession.java // @Data // @AllArgsConstructor // public class UserSession { // // @JsonUnwrapped // private DBConnectionConfig dbConnectionConfig; // // public String serialize() throws JsonProcessingException { // return new ObjectMapper().writeValueAsString(this); // } // // public static UserSession deserialize(String str) throws IOException { // return new ObjectMapper().readValue(str, UserSession.class); // } // // }
import com.fasterxml.jackson.core.JsonProcessingException; import com.dukenlidb.nlidb.model.UserSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import redis.clients.jedis.Jedis; import java.io.IOException;
package com.dukenlidb.nlidb.service; @Service public class RedisService { private Jedis jedis; @Autowired public RedisService( @Value("${redis.host}") String host, @Value("${redis.port}") int port ) { jedis = new Jedis(host, port); } public boolean hasUser(String userId) { return jedis.exists(userId); } public void removeUser(String userId) { jedis.del(userId); } public void refreshUser(String userId) { jedis.expire(userId, 3600 * 24); }
// Path: src/main/java/com/dukenlidb/nlidb/model/UserSession.java // @Data // @AllArgsConstructor // public class UserSession { // // @JsonUnwrapped // private DBConnectionConfig dbConnectionConfig; // // public String serialize() throws JsonProcessingException { // return new ObjectMapper().writeValueAsString(this); // } // // public static UserSession deserialize(String str) throws IOException { // return new ObjectMapper().readValue(str, UserSession.class); // } // // } // Path: src/main/java/com/dukenlidb/nlidb/service/RedisService.java import com.fasterxml.jackson.core.JsonProcessingException; import com.dukenlidb.nlidb.model.UserSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import redis.clients.jedis.Jedis; import java.io.IOException; package com.dukenlidb.nlidb.service; @Service public class RedisService { private Jedis jedis; @Autowired public RedisService( @Value("${redis.host}") String host, @Value("${redis.port}") int port ) { jedis = new Jedis(host, port); } public boolean hasUser(String userId) { return jedis.exists(userId); } public void removeUser(String userId) { jedis.del(userId); } public void refreshUser(String userId) { jedis.expire(userId, 3600 * 24); }
public UserSession getUserSession(String userId)
DukeNLIDB/NLIDB
src/main/java/com/dukenlidb/nlidb/service/SQLExecutionService.java
// Path: src/main/java/com/dukenlidb/nlidb/model/DBConnectionConfig.java // @Builder // @Value // public class DBConnectionConfig { // // String host; // String port; // String database; // String username; // String password; // // @JsonIgnore // public String getUrl() { // return "jdbc:postgresql://" // + host + ":" + port // + "/" + database; // } // // @JsonIgnore // public Properties getProperties() { // Properties props = new Properties(); // props.setProperty("user", username); // props.setProperty("password", password); // return props; // } // // }
import com.dukenlidb.nlidb.model.DBConnectionConfig; import org.postgresql.util.PSQLException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.sql.*;
package com.dukenlidb.nlidb.service; @Service public class SQLExecutionService { private DBConnectionService dbConnectionService; @Autowired public SQLExecutionService(DBConnectionService dbConnectionService) { this.dbConnectionService = dbConnectionService; }
// Path: src/main/java/com/dukenlidb/nlidb/model/DBConnectionConfig.java // @Builder // @Value // public class DBConnectionConfig { // // String host; // String port; // String database; // String username; // String password; // // @JsonIgnore // public String getUrl() { // return "jdbc:postgresql://" // + host + ":" + port // + "/" + database; // } // // @JsonIgnore // public Properties getProperties() { // Properties props = new Properties(); // props.setProperty("user", username); // props.setProperty("password", password); // return props; // } // // } // Path: src/main/java/com/dukenlidb/nlidb/service/SQLExecutionService.java import com.dukenlidb.nlidb.model.DBConnectionConfig; import org.postgresql.util.PSQLException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.sql.*; package com.dukenlidb.nlidb.service; @Service public class SQLExecutionService { private DBConnectionService dbConnectionService; @Autowired public SQLExecutionService(DBConnectionService dbConnectionService) { this.dbConnectionService = dbConnectionService; }
public String executeSQL(DBConnectionConfig config, String query)
ArtificerRepo/artificer
repository/hibernate/src/main/java/org/artificer/repository/hibernate/audit/HibernateAuditor.java
// Path: common/src/main/java/org/artificer/common/audit/AuditItemTypes.java // public final class AuditItemTypes { // // public static final String PROPERTY_ADDED = "property:added"; // public static final String PROPERTY_CHANGED = "property:changed"; // public static final String PROPERTY_REMOVED = "property:removed"; // public static final String CLASSIFIERS_ADDED = "classifier:added"; // public static final String CLASSIFIERS_REMOVED = "classifier:removed"; // // } // // Path: repository/src/main/java/org/artificer/repository/audit/ArtifactDiff.java // public class ArtifactDiff { // // private Map<String, String> addedProperties = new HashMap<String, String>(); // private Map<String, String> updatedProperties = new HashMap<String, String>(); // private Set<String> deletedProperties = new HashSet<String>(); // private Set<String> addedClassifiers = new HashSet<String>(); // private Set<String> deletedClassifiers = new HashSet<String>(); // // /** // * Constructor. // */ // public ArtifactDiff() { // } // // /** // * @return the addedProperties // */ // public Map<String, String> getAddedProperties() { // return addedProperties; // } // // /** // * @return the updatedProperties // */ // public Map<String, String> getUpdatedProperties() { // return updatedProperties; // } // // /** // * @return the deletedProperties // */ // public Set<String> getDeletedProperties() { // return deletedProperties; // } // // /** // * @return the addedClassifiers // */ // public Set<String> getAddedClassifiers() { // return addedClassifiers; // } // // /** // * @return the deletedClassifiers // */ // public Set<String> getDeletedClassifiers() { // return deletedClassifiers; // } // // /** // * @param addedProperties the addedProperties to set // */ // public void setAddedProperties(Map<String, String> addedProperties) { // this.addedProperties = addedProperties; // } // // /** // * @param updatedProperties the updatedProperties to set // */ // public void setUpdatedProperties(Map<String, String> updatedProperties) { // this.updatedProperties = updatedProperties; // } // // /** // * @param deletedProperties the deletedProperties to set // */ // public void setDeletedProperties(Set<String> deletedProperties) { // this.deletedProperties = deletedProperties; // } // // /** // * @param addedClassifiers the addedClassifiers to set // */ // public void setAddedClassifiers(Set<String> addedClassifiers) { // this.addedClassifiers = addedClassifiers; // } // // /** // * @param deletedClassifiers the deletedClassifiers to set // */ // public void setDeletedClassifiers(Set<String> deletedClassifiers) { // this.deletedClassifiers = deletedClassifiers; // } // // }
import org.artificer.common.audit.AuditEntryTypes; import org.artificer.common.audit.AuditItemTypes; import org.artificer.repository.audit.ArtifactDiff; import org.artificer.repository.hibernate.HibernateEntityFactory; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.jboss.downloads.artificer._2013.auditing.AuditEntry; import org.jboss.downloads.artificer._2013.auditing.AuditItemType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID;
/* * Copyright 2014 JBoss Inc * * 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 org.artificer.repository.hibernate.audit; /** * A class that is able to compare an artifact and output * the differences in properties, relationships, and classifiers. This class * is used by the auditing code to record changes made to a node. * * @author Brett Meyer. */ public class HibernateAuditor { private final Map<String, String> oldProperties = new HashMap<>(); private final List<String> oldClassifiers = new ArrayList<>(); /** * Constructor. Creates an initial snapshot of information found in the * included artifact. The information will be used for a later comparison. */ public HibernateAuditor(ArtificerArtifact oldArtifact) { // Note: Do not directly use the ArtificerArtifact collections, as they are going to change before #diff is called! oldProperties.putAll(oldArtifact.snapshotProperties()); oldClassifiers.addAll(oldArtifact.getClassifiers()); } /** * Called to compare the initial snapshot information with the current state * of the artifact node. * * @param newArtifact */ public ArtificerAuditEntry diff(ArtificerArtifact newArtifact) {
// Path: common/src/main/java/org/artificer/common/audit/AuditItemTypes.java // public final class AuditItemTypes { // // public static final String PROPERTY_ADDED = "property:added"; // public static final String PROPERTY_CHANGED = "property:changed"; // public static final String PROPERTY_REMOVED = "property:removed"; // public static final String CLASSIFIERS_ADDED = "classifier:added"; // public static final String CLASSIFIERS_REMOVED = "classifier:removed"; // // } // // Path: repository/src/main/java/org/artificer/repository/audit/ArtifactDiff.java // public class ArtifactDiff { // // private Map<String, String> addedProperties = new HashMap<String, String>(); // private Map<String, String> updatedProperties = new HashMap<String, String>(); // private Set<String> deletedProperties = new HashSet<String>(); // private Set<String> addedClassifiers = new HashSet<String>(); // private Set<String> deletedClassifiers = new HashSet<String>(); // // /** // * Constructor. // */ // public ArtifactDiff() { // } // // /** // * @return the addedProperties // */ // public Map<String, String> getAddedProperties() { // return addedProperties; // } // // /** // * @return the updatedProperties // */ // public Map<String, String> getUpdatedProperties() { // return updatedProperties; // } // // /** // * @return the deletedProperties // */ // public Set<String> getDeletedProperties() { // return deletedProperties; // } // // /** // * @return the addedClassifiers // */ // public Set<String> getAddedClassifiers() { // return addedClassifiers; // } // // /** // * @return the deletedClassifiers // */ // public Set<String> getDeletedClassifiers() { // return deletedClassifiers; // } // // /** // * @param addedProperties the addedProperties to set // */ // public void setAddedProperties(Map<String, String> addedProperties) { // this.addedProperties = addedProperties; // } // // /** // * @param updatedProperties the updatedProperties to set // */ // public void setUpdatedProperties(Map<String, String> updatedProperties) { // this.updatedProperties = updatedProperties; // } // // /** // * @param deletedProperties the deletedProperties to set // */ // public void setDeletedProperties(Set<String> deletedProperties) { // this.deletedProperties = deletedProperties; // } // // /** // * @param addedClassifiers the addedClassifiers to set // */ // public void setAddedClassifiers(Set<String> addedClassifiers) { // this.addedClassifiers = addedClassifiers; // } // // /** // * @param deletedClassifiers the deletedClassifiers to set // */ // public void setDeletedClassifiers(Set<String> deletedClassifiers) { // this.deletedClassifiers = deletedClassifiers; // } // // } // Path: repository/hibernate/src/main/java/org/artificer/repository/hibernate/audit/HibernateAuditor.java import org.artificer.common.audit.AuditEntryTypes; import org.artificer.common.audit.AuditItemTypes; import org.artificer.repository.audit.ArtifactDiff; import org.artificer.repository.hibernate.HibernateEntityFactory; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.jboss.downloads.artificer._2013.auditing.AuditEntry; import org.jboss.downloads.artificer._2013.auditing.AuditItemType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; /* * Copyright 2014 JBoss Inc * * 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 org.artificer.repository.hibernate.audit; /** * A class that is able to compare an artifact and output * the differences in properties, relationships, and classifiers. This class * is used by the auditing code to record changes made to a node. * * @author Brett Meyer. */ public class HibernateAuditor { private final Map<String, String> oldProperties = new HashMap<>(); private final List<String> oldClassifiers = new ArrayList<>(); /** * Constructor. Creates an initial snapshot of information found in the * included artifact. The information will be used for a later comparison. */ public HibernateAuditor(ArtificerArtifact oldArtifact) { // Note: Do not directly use the ArtificerArtifact collections, as they are going to change before #diff is called! oldProperties.putAll(oldArtifact.snapshotProperties()); oldClassifiers.addAll(oldArtifact.getClassifiers()); } /** * Called to compare the initial snapshot information with the current state * of the artifact node. * * @param newArtifact */ public ArtificerAuditEntry diff(ArtificerArtifact newArtifact) {
ArtifactDiff diff = new ArtifactDiff();
ArtificerRepo/artificer
repository/hibernate/src/main/java/org/artificer/repository/hibernate/audit/HibernateAuditor.java
// Path: common/src/main/java/org/artificer/common/audit/AuditItemTypes.java // public final class AuditItemTypes { // // public static final String PROPERTY_ADDED = "property:added"; // public static final String PROPERTY_CHANGED = "property:changed"; // public static final String PROPERTY_REMOVED = "property:removed"; // public static final String CLASSIFIERS_ADDED = "classifier:added"; // public static final String CLASSIFIERS_REMOVED = "classifier:removed"; // // } // // Path: repository/src/main/java/org/artificer/repository/audit/ArtifactDiff.java // public class ArtifactDiff { // // private Map<String, String> addedProperties = new HashMap<String, String>(); // private Map<String, String> updatedProperties = new HashMap<String, String>(); // private Set<String> deletedProperties = new HashSet<String>(); // private Set<String> addedClassifiers = new HashSet<String>(); // private Set<String> deletedClassifiers = new HashSet<String>(); // // /** // * Constructor. // */ // public ArtifactDiff() { // } // // /** // * @return the addedProperties // */ // public Map<String, String> getAddedProperties() { // return addedProperties; // } // // /** // * @return the updatedProperties // */ // public Map<String, String> getUpdatedProperties() { // return updatedProperties; // } // // /** // * @return the deletedProperties // */ // public Set<String> getDeletedProperties() { // return deletedProperties; // } // // /** // * @return the addedClassifiers // */ // public Set<String> getAddedClassifiers() { // return addedClassifiers; // } // // /** // * @return the deletedClassifiers // */ // public Set<String> getDeletedClassifiers() { // return deletedClassifiers; // } // // /** // * @param addedProperties the addedProperties to set // */ // public void setAddedProperties(Map<String, String> addedProperties) { // this.addedProperties = addedProperties; // } // // /** // * @param updatedProperties the updatedProperties to set // */ // public void setUpdatedProperties(Map<String, String> updatedProperties) { // this.updatedProperties = updatedProperties; // } // // /** // * @param deletedProperties the deletedProperties to set // */ // public void setDeletedProperties(Set<String> deletedProperties) { // this.deletedProperties = deletedProperties; // } // // /** // * @param addedClassifiers the addedClassifiers to set // */ // public void setAddedClassifiers(Set<String> addedClassifiers) { // this.addedClassifiers = addedClassifiers; // } // // /** // * @param deletedClassifiers the deletedClassifiers to set // */ // public void setDeletedClassifiers(Set<String> deletedClassifiers) { // this.deletedClassifiers = deletedClassifiers; // } // // }
import org.artificer.common.audit.AuditEntryTypes; import org.artificer.common.audit.AuditItemTypes; import org.artificer.repository.audit.ArtifactDiff; import org.artificer.repository.hibernate.HibernateEntityFactory; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.jboss.downloads.artificer._2013.auditing.AuditEntry; import org.jboss.downloads.artificer._2013.auditing.AuditItemType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID;
} else { diff.getAddedProperties().put(name, newValue); } } for (String newClassifier : newClassifiers) { if (!oldClassifiers.contains(newClassifier)) { diff.getAddedClassifiers().add(newClassifier); } // Remove it so that, at the end of this, the classifier set contains only // classifiers that were removed. oldClassifiers.remove(newClassifier); } // Process property deletes for (Map.Entry<String, String> entry : oldProperties.entrySet()) { String name = entry.getKey(); diff.getDeletedProperties().add(name); } // Process classifier deletes for (String classifier : oldClassifiers) { diff.getDeletedClassifiers().add(classifier); } ArtificerAuditEntry artificerAuditEntry = new ArtificerAuditEntry(); artificerAuditEntry.setUuid(UUID.randomUUID().toString()); artificerAuditEntry.setModifiedBy(HibernateEntityFactory.user()); artificerAuditEntry.setType(AuditEntryTypes.ARTIFACT_UPDATE);
// Path: common/src/main/java/org/artificer/common/audit/AuditItemTypes.java // public final class AuditItemTypes { // // public static final String PROPERTY_ADDED = "property:added"; // public static final String PROPERTY_CHANGED = "property:changed"; // public static final String PROPERTY_REMOVED = "property:removed"; // public static final String CLASSIFIERS_ADDED = "classifier:added"; // public static final String CLASSIFIERS_REMOVED = "classifier:removed"; // // } // // Path: repository/src/main/java/org/artificer/repository/audit/ArtifactDiff.java // public class ArtifactDiff { // // private Map<String, String> addedProperties = new HashMap<String, String>(); // private Map<String, String> updatedProperties = new HashMap<String, String>(); // private Set<String> deletedProperties = new HashSet<String>(); // private Set<String> addedClassifiers = new HashSet<String>(); // private Set<String> deletedClassifiers = new HashSet<String>(); // // /** // * Constructor. // */ // public ArtifactDiff() { // } // // /** // * @return the addedProperties // */ // public Map<String, String> getAddedProperties() { // return addedProperties; // } // // /** // * @return the updatedProperties // */ // public Map<String, String> getUpdatedProperties() { // return updatedProperties; // } // // /** // * @return the deletedProperties // */ // public Set<String> getDeletedProperties() { // return deletedProperties; // } // // /** // * @return the addedClassifiers // */ // public Set<String> getAddedClassifiers() { // return addedClassifiers; // } // // /** // * @return the deletedClassifiers // */ // public Set<String> getDeletedClassifiers() { // return deletedClassifiers; // } // // /** // * @param addedProperties the addedProperties to set // */ // public void setAddedProperties(Map<String, String> addedProperties) { // this.addedProperties = addedProperties; // } // // /** // * @param updatedProperties the updatedProperties to set // */ // public void setUpdatedProperties(Map<String, String> updatedProperties) { // this.updatedProperties = updatedProperties; // } // // /** // * @param deletedProperties the deletedProperties to set // */ // public void setDeletedProperties(Set<String> deletedProperties) { // this.deletedProperties = deletedProperties; // } // // /** // * @param addedClassifiers the addedClassifiers to set // */ // public void setAddedClassifiers(Set<String> addedClassifiers) { // this.addedClassifiers = addedClassifiers; // } // // /** // * @param deletedClassifiers the deletedClassifiers to set // */ // public void setDeletedClassifiers(Set<String> deletedClassifiers) { // this.deletedClassifiers = deletedClassifiers; // } // // } // Path: repository/hibernate/src/main/java/org/artificer/repository/hibernate/audit/HibernateAuditor.java import org.artificer.common.audit.AuditEntryTypes; import org.artificer.common.audit.AuditItemTypes; import org.artificer.repository.audit.ArtifactDiff; import org.artificer.repository.hibernate.HibernateEntityFactory; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.jboss.downloads.artificer._2013.auditing.AuditEntry; import org.jboss.downloads.artificer._2013.auditing.AuditItemType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; } else { diff.getAddedProperties().put(name, newValue); } } for (String newClassifier : newClassifiers) { if (!oldClassifiers.contains(newClassifier)) { diff.getAddedClassifiers().add(newClassifier); } // Remove it so that, at the end of this, the classifier set contains only // classifiers that were removed. oldClassifiers.remove(newClassifier); } // Process property deletes for (Map.Entry<String, String> entry : oldProperties.entrySet()) { String name = entry.getKey(); diff.getDeletedProperties().add(name); } // Process classifier deletes for (String classifier : oldClassifiers) { diff.getDeletedClassifiers().add(classifier); } ArtificerAuditEntry artificerAuditEntry = new ArtificerAuditEntry(); artificerAuditEntry.setUuid(UUID.randomUUID().toString()); artificerAuditEntry.setModifiedBy(HibernateEntityFactory.user()); artificerAuditEntry.setType(AuditEntryTypes.ARTIFACT_UPDATE);
createAuditItem(artificerAuditEntry, AuditItemTypes.PROPERTY_ADDED, diff.getAddedProperties());
ArtificerRepo/artificer
repository/test/src/test/java/org/artificer/repository/test/hibernate/HibernateRepositoryTestProvider.java
// Path: repository/hibernate/src/main/java/org/artificer/repository/hibernate/entity/ArtificerProperty.java // @Entity // @Indexed // @Analyzer(impl = StandardAnalyzer.class) // @Table(name = "Property") // public class ArtificerProperty implements Serializable { // // private long id; // // private String key; // // private String value; // // private boolean isCustom; // // private ArtificerArtifact owner; // // @Id // @GeneratedValue // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // @Column(name = "propertyKey") // @Field // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // @Column(name = "propertyValue") // @Field // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public boolean isCustom() { // return isCustom; // } // // public void setCustom(boolean isCustom) { // this.isCustom = isCustom; // } // // @ContainedIn // @ManyToOne(optional = false) // public ArtificerArtifact getOwner() { // return owner; // } // // public void setOwner(ArtificerArtifact owner) { // this.owner = owner; // } // } // // Path: repository/test/src/test/java/org/artificer/repository/test/RepositoryTestProvider.java // public interface RepositoryTestProvider { // // public void before() throws Exception; // // public void after() throws Exception; // }
import org.artificer.repository.filter.ServletCredentialsFilter; import org.artificer.repository.hibernate.HibernateUtil; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.artificer.repository.hibernate.entity.ArtificerProperty; import org.artificer.repository.hibernate.file.FileManagerFactory; import org.artificer.repository.test.RepositoryTestProvider; import org.hibernate.Session; import org.hibernate.search.jpa.FullTextEntityManager; import javax.persistence.EntityManager; import java.util.List; import java.util.Map;
} FileManagerFactory.reset(); ServletCredentialsFilter.setUsername("junituser"); } @Override public void after() throws Exception { new HibernateUtil.HibernateTask<Void>() { @Override protected Void doExecute(EntityManager entityManager) throws Exception { // H2 specific entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate(); entityManager.createNativeQuery("SET LOCK_MODE 0").executeUpdate(); List<Object[]> tables = entityManager.createNativeQuery("SHOW TABLES").getResultList(); for (Object[] table : tables) { entityManager.createNativeQuery("TRUNCATE TABLE " + table[0]).executeUpdate(); } entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY true").executeUpdate(); entityManager.createNativeQuery("SET LOCK_MODE 3").executeUpdate(); // purge caches entityManager.unwrap(Session.class).getSessionFactory().getCache().evictCollectionRegions(); entityManager.unwrap(Session.class).getSessionFactory().getCache().evictEntityRegions(); entityManager.unwrap(Session.class).getSessionFactory().getCache().evictQueryRegions(); // purge Hibernate Search FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(entityManager);
// Path: repository/hibernate/src/main/java/org/artificer/repository/hibernate/entity/ArtificerProperty.java // @Entity // @Indexed // @Analyzer(impl = StandardAnalyzer.class) // @Table(name = "Property") // public class ArtificerProperty implements Serializable { // // private long id; // // private String key; // // private String value; // // private boolean isCustom; // // private ArtificerArtifact owner; // // @Id // @GeneratedValue // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // @Column(name = "propertyKey") // @Field // public String getKey() { // return key; // } // // public void setKey(String key) { // this.key = key; // } // // @Column(name = "propertyValue") // @Field // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // // public boolean isCustom() { // return isCustom; // } // // public void setCustom(boolean isCustom) { // this.isCustom = isCustom; // } // // @ContainedIn // @ManyToOne(optional = false) // public ArtificerArtifact getOwner() { // return owner; // } // // public void setOwner(ArtificerArtifact owner) { // this.owner = owner; // } // } // // Path: repository/test/src/test/java/org/artificer/repository/test/RepositoryTestProvider.java // public interface RepositoryTestProvider { // // public void before() throws Exception; // // public void after() throws Exception; // } // Path: repository/test/src/test/java/org/artificer/repository/test/hibernate/HibernateRepositoryTestProvider.java import org.artificer.repository.filter.ServletCredentialsFilter; import org.artificer.repository.hibernate.HibernateUtil; import org.artificer.repository.hibernate.entity.ArtificerArtifact; import org.artificer.repository.hibernate.entity.ArtificerProperty; import org.artificer.repository.hibernate.file.FileManagerFactory; import org.artificer.repository.test.RepositoryTestProvider; import org.hibernate.Session; import org.hibernate.search.jpa.FullTextEntityManager; import javax.persistence.EntityManager; import java.util.List; import java.util.Map; } FileManagerFactory.reset(); ServletCredentialsFilter.setUsername("junituser"); } @Override public void after() throws Exception { new HibernateUtil.HibernateTask<Void>() { @Override protected Void doExecute(EntityManager entityManager) throws Exception { // H2 specific entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate(); entityManager.createNativeQuery("SET LOCK_MODE 0").executeUpdate(); List<Object[]> tables = entityManager.createNativeQuery("SHOW TABLES").getResultList(); for (Object[] table : tables) { entityManager.createNativeQuery("TRUNCATE TABLE " + table[0]).executeUpdate(); } entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY true").executeUpdate(); entityManager.createNativeQuery("SET LOCK_MODE 3").executeUpdate(); // purge caches entityManager.unwrap(Session.class).getSessionFactory().getCache().evictCollectionRegions(); entityManager.unwrap(Session.class).getSessionFactory().getCache().evictEntityRegions(); entityManager.unwrap(Session.class).getSessionFactory().getCache().evictQueryRegions(); // purge Hibernate Search FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.purgeAll(ArtificerProperty.class);
ArtificerRepo/artificer
shell/src/main/java/org/artificer/shell/archive/OpenArchiveCommand.java
// Path: shell/src/main/java/org/artificer/shell/util/FileNameCompleterDelegate.java // public class FileNameCompleterDelegate { // // /** // * Complete. // * // * @param completerInvocation // */ // public static void complete(CompleterInvocation completerInvocation) { // AeshContext context = completerInvocation.getAeshContext(); // String currentValue = completerInvocation.getGivenCompleteValue(); // // CompleteOperation completeOperation = new CompleteOperation(context, currentValue, 0); // if (StringUtils.isBlank(currentValue)) // new FileLister("", context.getCurrentWorkingDirectory()). // findMatchingDirectories(completeOperation); // else // new FileLister(currentValue, // context.getCurrentWorkingDirectory()).findMatchingDirectories(completeOperation); // // if (completeOperation.getCompletionCandidates().size() > 1) { // completeOperation.removeEscapedSpacesFromCompletionCandidates(); // } // // completerInvocation.setCompleterValuesTerminalString(completeOperation.getCompletionCandidates()); // if (currentValue != null && completerInvocation.getCompleterValues().size() == 1) { // completerInvocation.setAppendSpace(completeOperation.hasAppendSeparator()); // } // } // // }
import org.apache.commons.collections.CollectionUtils; import org.artificer.atom.archive.ArtificerArchive; import org.artificer.shell.i18n.Messages; import org.artificer.shell.util.FileNameCompleterDelegate; import org.jboss.aesh.cl.Arguments; import org.jboss.aesh.cl.CommandDefinition; import org.jboss.aesh.cl.completer.OptionCompleter; import org.jboss.aesh.console.command.CommandResult; import org.jboss.aesh.console.command.completer.CompleterInvocation; import org.jboss.aesh.console.command.invocation.CommandInvocation; import java.io.File; import java.util.List;
/* * Copyright 2012 JBoss Inc * * 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 org.artificer.shell.archive; /** * Opens an existing S-RAMP batch archive. * * @author Brett Meyer * @author eric.wittmann@redhat.com */ @CommandDefinition(name = "open", description = "The \"open\" operation opens an existing Artificer batch archive file. Once open, the contents of the archive can be modified or just listed.\n") public class OpenArchiveCommand extends AbstractArchiveCommand { @Arguments(description = "<path to archive>", completer = Completer.class) private List<String> arguments; @Override protected String getName() { return "archive open"; } @Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { if (CollectionUtils.isEmpty(arguments)) { return doHelp(commandInvocation); } String pathToArchive = requiredArgument(commandInvocation, arguments, 0); File archiveFile = new File(pathToArchive); ArtificerArchive archive = new ArtificerArchive(archiveFile); context(commandInvocation).setCurrentArchive(archive); commandInvocation.getShell().out().println(Messages.i18n.format("OpenArchive.Opened", archiveFile.getCanonicalPath())); return CommandResult.SUCCESS; } private static class Completer implements OptionCompleter<CompleterInvocation> { @Override public void complete(CompleterInvocation completerInvocation) { OpenArchiveCommand command = (OpenArchiveCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) {
// Path: shell/src/main/java/org/artificer/shell/util/FileNameCompleterDelegate.java // public class FileNameCompleterDelegate { // // /** // * Complete. // * // * @param completerInvocation // */ // public static void complete(CompleterInvocation completerInvocation) { // AeshContext context = completerInvocation.getAeshContext(); // String currentValue = completerInvocation.getGivenCompleteValue(); // // CompleteOperation completeOperation = new CompleteOperation(context, currentValue, 0); // if (StringUtils.isBlank(currentValue)) // new FileLister("", context.getCurrentWorkingDirectory()). // findMatchingDirectories(completeOperation); // else // new FileLister(currentValue, // context.getCurrentWorkingDirectory()).findMatchingDirectories(completeOperation); // // if (completeOperation.getCompletionCandidates().size() > 1) { // completeOperation.removeEscapedSpacesFromCompletionCandidates(); // } // // completerInvocation.setCompleterValuesTerminalString(completeOperation.getCompletionCandidates()); // if (currentValue != null && completerInvocation.getCompleterValues().size() == 1) { // completerInvocation.setAppendSpace(completeOperation.hasAppendSeparator()); // } // } // // } // Path: shell/src/main/java/org/artificer/shell/archive/OpenArchiveCommand.java import org.apache.commons.collections.CollectionUtils; import org.artificer.atom.archive.ArtificerArchive; import org.artificer.shell.i18n.Messages; import org.artificer.shell.util.FileNameCompleterDelegate; import org.jboss.aesh.cl.Arguments; import org.jboss.aesh.cl.CommandDefinition; import org.jboss.aesh.cl.completer.OptionCompleter; import org.jboss.aesh.console.command.CommandResult; import org.jboss.aesh.console.command.completer.CompleterInvocation; import org.jboss.aesh.console.command.invocation.CommandInvocation; import java.io.File; import java.util.List; /* * Copyright 2012 JBoss Inc * * 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 org.artificer.shell.archive; /** * Opens an existing S-RAMP batch archive. * * @author Brett Meyer * @author eric.wittmann@redhat.com */ @CommandDefinition(name = "open", description = "The \"open\" operation opens an existing Artificer batch archive file. Once open, the contents of the archive can be modified or just listed.\n") public class OpenArchiveCommand extends AbstractArchiveCommand { @Arguments(description = "<path to archive>", completer = Completer.class) private List<String> arguments; @Override protected String getName() { return "archive open"; } @Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { if (CollectionUtils.isEmpty(arguments)) { return doHelp(commandInvocation); } String pathToArchive = requiredArgument(commandInvocation, arguments, 0); File archiveFile = new File(pathToArchive); ArtificerArchive archive = new ArtificerArchive(archiveFile); context(commandInvocation).setCurrentArchive(archive); commandInvocation.getShell().out().println(Messages.i18n.format("OpenArchive.Opened", archiveFile.getCanonicalPath())); return CommandResult.SUCCESS; } private static class Completer implements OptionCompleter<CompleterInvocation> { @Override public void complete(CompleterInvocation completerInvocation) { OpenArchiveCommand command = (OpenArchiveCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) {
FileNameCompleterDelegate.complete(completerInvocation);
ArtificerRepo/artificer
ui/src/main/java/org/artificer/ui/client/local/services/ArtifactSearchServiceCaller.java
// Path: ui/src/main/java/org/artificer/ui/client/shared/beans/ArtifactTypeBean.java // @Portable // public class ArtifactTypeBean { // // public ArtifactTypeBean(String type) { // super(); // this.type = type; // } // // public ArtifactTypeBean() { // super(); // } // // String type; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // }
import org.jboss.errai.common.client.api.ErrorCallback; import org.jboss.errai.common.client.api.RemoteCallback; import java.util.List; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import org.artificer.ui.client.local.services.callback.DelegatingErrorCallback; import org.artificer.ui.client.local.services.callback.DelegatingRemoteCallback; import org.artificer.ui.client.local.services.callback.IServiceInvocationHandler; import org.artificer.ui.client.shared.beans.ArtifactFilterBean; import org.artificer.ui.client.shared.beans.ArtifactResultSetBean; import org.artificer.ui.client.shared.beans.ArtifactSearchBean; import org.artificer.ui.client.shared.beans.ArtifactTypeBean; import org.artificer.ui.client.shared.exceptions.ArtificerUiException; import org.artificer.ui.client.shared.services.IArtifactSearchService; import org.jboss.errai.common.client.api.Caller;
/* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.local.services; /** * Client-side service for making Caller calls to the remote search service. * * @author eric.wittmann@redhat.com */ @ApplicationScoped public class ArtifactSearchServiceCaller { @Inject private Caller<IArtifactSearchService> remoteSearchService; /** * Constructor. */ public ArtifactSearchServiceCaller() { } /** * Performs the search using the remote service. Hides the details from * the caller. * * @param searchBean */ public void search(ArtifactSearchBean searchBean, final IServiceInvocationHandler<ArtifactResultSetBean> handler) { // TODO only allow one search at a time. If another search comes in before the previous one // finished, cancel the previous one. In other words, only return the results of the *last* // search performed. RemoteCallback<ArtifactResultSetBean> successCallback = new DelegatingRemoteCallback<ArtifactResultSetBean>(handler); ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler); try { remoteSearchService.call(successCallback, errorCallback).search(searchBean); } catch (ArtificerUiException e) { errorCallback.error(null, e); } } public void query(ArtifactFilterBean filterBean, final IServiceInvocationHandler<String> handler) { RemoteCallback<String> successCallback = new DelegatingRemoteCallback<String>(handler); ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler); try { remoteSearchService.call(successCallback, errorCallback).query(filterBean); } catch (ArtificerUiException e) { errorCallback.error(null, e); } }
// Path: ui/src/main/java/org/artificer/ui/client/shared/beans/ArtifactTypeBean.java // @Portable // public class ArtifactTypeBean { // // public ArtifactTypeBean(String type) { // super(); // this.type = type; // } // // public ArtifactTypeBean() { // super(); // } // // String type; // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // } // Path: ui/src/main/java/org/artificer/ui/client/local/services/ArtifactSearchServiceCaller.java import org.jboss.errai.common.client.api.ErrorCallback; import org.jboss.errai.common.client.api.RemoteCallback; import java.util.List; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import org.artificer.ui.client.local.services.callback.DelegatingErrorCallback; import org.artificer.ui.client.local.services.callback.DelegatingRemoteCallback; import org.artificer.ui.client.local.services.callback.IServiceInvocationHandler; import org.artificer.ui.client.shared.beans.ArtifactFilterBean; import org.artificer.ui.client.shared.beans.ArtifactResultSetBean; import org.artificer.ui.client.shared.beans.ArtifactSearchBean; import org.artificer.ui.client.shared.beans.ArtifactTypeBean; import org.artificer.ui.client.shared.exceptions.ArtificerUiException; import org.artificer.ui.client.shared.services.IArtifactSearchService; import org.jboss.errai.common.client.api.Caller; /* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.local.services; /** * Client-side service for making Caller calls to the remote search service. * * @author eric.wittmann@redhat.com */ @ApplicationScoped public class ArtifactSearchServiceCaller { @Inject private Caller<IArtifactSearchService> remoteSearchService; /** * Constructor. */ public ArtifactSearchServiceCaller() { } /** * Performs the search using the remote service. Hides the details from * the caller. * * @param searchBean */ public void search(ArtifactSearchBean searchBean, final IServiceInvocationHandler<ArtifactResultSetBean> handler) { // TODO only allow one search at a time. If another search comes in before the previous one // finished, cancel the previous one. In other words, only return the results of the *last* // search performed. RemoteCallback<ArtifactResultSetBean> successCallback = new DelegatingRemoteCallback<ArtifactResultSetBean>(handler); ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler); try { remoteSearchService.call(successCallback, errorCallback).search(searchBean); } catch (ArtificerUiException e) { errorCallback.error(null, e); } } public void query(ArtifactFilterBean filterBean, final IServiceInvocationHandler<String> handler) { RemoteCallback<String> successCallback = new DelegatingRemoteCallback<String>(handler); ErrorCallback<?> errorCallback = new DelegatingErrorCallback(handler); try { remoteSearchService.call(successCallback, errorCallback).query(filterBean); } catch (ArtificerUiException e) { errorCallback.error(null, e); } }
public void types(final IServiceInvocationHandler<List<ArtifactTypeBean>> handler) {
ArtificerRepo/artificer
ui/src/main/java/org/artificer/ui/client/local/widgets/common/EditableInlineLabelPopover.java
// Path: ui/src/main/java/org/artificer/ui/client/local/util/IMouseInOutWidget.java // public interface IMouseInOutWidget { // // /** // * @return the widget's element // */ // public Element getElement(); // // /** // * Adds an attach handler to the widget. // * @param handler // */ // public HandlerRegistration addAttachHandler(Handler handler); // // /** // * Called when the mouse enters the widget. // */ // public void onMouseIn(); // // /** // * Called when the mouse leaves the widget. // */ // public void onMouseOut(); // // }
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.RootPanel; import javax.annotation.PostConstruct; import javax.enterprise.context.Dependent; import javax.inject.Inject; import org.jboss.errai.ui.shared.api.annotations.DataField; import org.jboss.errai.ui.shared.api.annotations.Templated; import org.artificer.ui.client.local.util.IMouseInOutWidget; import org.artificer.ui.client.local.util.WidgetUtil; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.ScrollEvent; import com.google.gwt.user.client.Window.ScrollHandler; import com.google.gwt.user.client.ui.Anchor;
/* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.local.widgets.common; /** * An overlay/popover shown to the user when they mouse-over an editable * field in the Artifact Details page. * * @author eric.wittmann@redhat.com */ @Templated("/org/artificer/ui/client/local/site/dialogs/propval-editor-popover.html#propval-editor-popover") @Dependent
// Path: ui/src/main/java/org/artificer/ui/client/local/util/IMouseInOutWidget.java // public interface IMouseInOutWidget { // // /** // * @return the widget's element // */ // public Element getElement(); // // /** // * Adds an attach handler to the widget. // * @param handler // */ // public HandlerRegistration addAttachHandler(Handler handler); // // /** // * Called when the mouse enters the widget. // */ // public void onMouseIn(); // // /** // * Called when the mouse leaves the widget. // */ // public void onMouseOut(); // // } // Path: ui/src/main/java/org/artificer/ui/client/local/widgets/common/EditableInlineLabelPopover.java import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.RootPanel; import javax.annotation.PostConstruct; import javax.enterprise.context.Dependent; import javax.inject.Inject; import org.jboss.errai.ui.shared.api.annotations.DataField; import org.jboss.errai.ui.shared.api.annotations.Templated; import org.artificer.ui.client.local.util.IMouseInOutWidget; import org.artificer.ui.client.local.util.WidgetUtil; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.ScrollEvent; import com.google.gwt.user.client.Window.ScrollHandler; import com.google.gwt.user.client.ui.Anchor; /* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.local.widgets.common; /** * An overlay/popover shown to the user when they mouse-over an editable * field in the Artifact Details page. * * @author eric.wittmann@redhat.com */ @Templated("/org/artificer/ui/client/local/site/dialogs/propval-editor-popover.html#propval-editor-popover") @Dependent
public class EditableInlineLabelPopover extends Composite implements IMouseInOutWidget {
ArtificerRepo/artificer
ui/src/main/java/org/artificer/ui/client/shared/services/IArtifactService.java
// Path: ui/src/main/java/org/artificer/ui/client/shared/beans/ArtifactCommentBean.java // @Portable // @Bindable // public class ArtifactCommentBean implements Serializable { // // private static final long serialVersionUID = ArtifactCommentBean.class.hashCode(); // // private String createdBy; // // private Date createdOn; // // private String text; // // public String getCreatedBy() { // return createdBy; // } // // public void setCreatedBy(String createdBy) { // this.createdBy = createdBy; // } // // public Date getCreatedOn() { // return createdOn; // } // // public void setCreatedOn(Date createdOn) { // this.createdOn = createdOn; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // @Override // public String toString() { // DateTimeFormat df = DateTimeFormat.getFormat("yyyy-MM-dd"); // StringBuilder sb = new StringBuilder(); // sb.append("<strong>").append(createdBy).append(" (").append(df.format(createdOn)).append(")</strong><br/>"); // sb.append(text); // return sb.toString(); // } // }
import org.artificer.ui.client.shared.beans.ArtifactBean; import org.artificer.ui.client.shared.beans.ArtifactCommentBean; import org.artificer.ui.client.shared.beans.ArtifactRelationshipsBean; import org.artificer.ui.client.shared.beans.ArtifactRelationshipsIndexBean; import org.artificer.ui.client.shared.exceptions.ArtificerUiException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType;
/* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.shared.services; /** * Provides a way to get and set Artifact meta data. * * @author eric.wittmann@redhat.com */ @Path("artifacts") public interface IArtifactService { /** * Gets the full meta data for an artifact (by UUID). * @param uuid * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Path("{uuid}") @Produces(MediaType.APPLICATION_JSON) public ArtifactBean get(@PathParam("uuid") String uuid) throws ArtificerUiException; /** * Gets the full document content for an artifact (by UUID). * @param uuid * @param artifactType * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Path("content/{uuid}/{artifactType}") @Produces(MediaType.APPLICATION_JSON) public String getDocumentContent(@PathParam("uuid") String uuid, @PathParam("artifactType") String artifactType) throws ArtificerUiException; /** * Gets all of the relationships (resolved) for an artifact. * @param uuid * @param artifactType * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("relationships/{uuid}/{artifactType}") public ArtifactRelationshipsIndexBean getRelationships(@PathParam("uuid") String uuid, @PathParam("artifactType") String artifactType) throws ArtificerUiException; /** * Called to update the given artifact bean. * @param artifact * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @PUT @Consumes(MediaType.APPLICATION_JSON) public void update(ArtifactBean artifact) throws ArtificerUiException; @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("comment/{uuid}/{artifactType}")
// Path: ui/src/main/java/org/artificer/ui/client/shared/beans/ArtifactCommentBean.java // @Portable // @Bindable // public class ArtifactCommentBean implements Serializable { // // private static final long serialVersionUID = ArtifactCommentBean.class.hashCode(); // // private String createdBy; // // private Date createdOn; // // private String text; // // public String getCreatedBy() { // return createdBy; // } // // public void setCreatedBy(String createdBy) { // this.createdBy = createdBy; // } // // public Date getCreatedOn() { // return createdOn; // } // // public void setCreatedOn(Date createdOn) { // this.createdOn = createdOn; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // @Override // public String toString() { // DateTimeFormat df = DateTimeFormat.getFormat("yyyy-MM-dd"); // StringBuilder sb = new StringBuilder(); // sb.append("<strong>").append(createdBy).append(" (").append(df.format(createdOn)).append(")</strong><br/>"); // sb.append(text); // return sb.toString(); // } // } // Path: ui/src/main/java/org/artificer/ui/client/shared/services/IArtifactService.java import org.artificer.ui.client.shared.beans.ArtifactBean; import org.artificer.ui.client.shared.beans.ArtifactCommentBean; import org.artificer.ui.client.shared.beans.ArtifactRelationshipsBean; import org.artificer.ui.client.shared.beans.ArtifactRelationshipsIndexBean; import org.artificer.ui.client.shared.exceptions.ArtificerUiException; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; /* * Copyright 2013 JBoss Inc * * 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 org.artificer.ui.client.shared.services; /** * Provides a way to get and set Artifact meta data. * * @author eric.wittmann@redhat.com */ @Path("artifacts") public interface IArtifactService { /** * Gets the full meta data for an artifact (by UUID). * @param uuid * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Path("{uuid}") @Produces(MediaType.APPLICATION_JSON) public ArtifactBean get(@PathParam("uuid") String uuid) throws ArtificerUiException; /** * Gets the full document content for an artifact (by UUID). * @param uuid * @param artifactType * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Path("content/{uuid}/{artifactType}") @Produces(MediaType.APPLICATION_JSON) public String getDocumentContent(@PathParam("uuid") String uuid, @PathParam("artifactType") String artifactType) throws ArtificerUiException; /** * Gets all of the relationships (resolved) for an artifact. * @param uuid * @param artifactType * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("relationships/{uuid}/{artifactType}") public ArtifactRelationshipsIndexBean getRelationships(@PathParam("uuid") String uuid, @PathParam("artifactType") String artifactType) throws ArtificerUiException; /** * Called to update the given artifact bean. * @param artifact * @throws org.artificer.ui.client.shared.exceptions.ArtificerUiException */ @PUT @Consumes(MediaType.APPLICATION_JSON) public void update(ArtifactBean artifact) throws ArtificerUiException; @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("comment/{uuid}/{artifactType}")
public ArtifactCommentBean addComment(@PathParam("uuid") String uuid,
ArtificerRepo/artificer
shell/src/main/java/org/artificer/shell/archive/AddEntryArchiveCommand.java
// Path: shell/src/main/java/org/artificer/shell/util/FileNameCompleterDelegate.java // public class FileNameCompleterDelegate { // // /** // * Complete. // * // * @param completerInvocation // */ // public static void complete(CompleterInvocation completerInvocation) { // AeshContext context = completerInvocation.getAeshContext(); // String currentValue = completerInvocation.getGivenCompleteValue(); // // CompleteOperation completeOperation = new CompleteOperation(context, currentValue, 0); // if (StringUtils.isBlank(currentValue)) // new FileLister("", context.getCurrentWorkingDirectory()). // findMatchingDirectories(completeOperation); // else // new FileLister(currentValue, // context.getCurrentWorkingDirectory()).findMatchingDirectories(completeOperation); // // if (completeOperation.getCompletionCandidates().size() > 1) { // completeOperation.removeEscapedSpacesFromCompletionCandidates(); // } // // completerInvocation.setCompleterValuesTerminalString(completeOperation.getCompletionCandidates()); // if (currentValue != null && completerInvocation.getCompleterValues().size() == 1) { // completerInvocation.setAppendSpace(completeOperation.hasAppendSeparator()); // } // } // // }
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.artificer.atom.archive.ArtificerArchiveException; import org.artificer.common.ArtifactType; import org.artificer.shell.i18n.Messages; import org.artificer.shell.util.ArtifactTypeCompleter; import org.artificer.shell.util.FileNameCompleterDelegate; import org.jboss.aesh.cl.Arguments; import org.jboss.aesh.cl.CommandDefinition; import org.jboss.aesh.cl.Option; import org.jboss.aesh.cl.completer.OptionCompleter; import org.jboss.aesh.console.command.CommandResult; import org.jboss.aesh.console.command.completer.CompleterInvocation; import org.jboss.aesh.console.command.invocation.CommandInvocation; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import java.io.File; import java.io.InputStream; import java.util.List;
} String pathToContent = optionalArgument(arguments, 0); InputStream contentStream = null; try { ArtifactType artifactType = ArtifactType.valueOf(type); String name = new File(type).getName(); if (pathToContent != null) { File contentFile = new File(pathToContent); contentStream = FileUtils.openInputStream(contentFile); } BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); currentArchive(commandInvocation).addEntry(entryPath, artifact, contentStream); commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.Added", entryPath)); } catch (ArtificerArchiveException e) { commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.ArtificerArchiveException", e.getLocalizedMessage())); } finally { IOUtils.closeQuietly(contentStream); } return CommandResult.SUCCESS; } private static class Completer implements OptionCompleter<CompleterInvocation> { @Override public void complete(CompleterInvocation completerInvocation) { AddEntryArchiveCommand command = (AddEntryArchiveCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) {
// Path: shell/src/main/java/org/artificer/shell/util/FileNameCompleterDelegate.java // public class FileNameCompleterDelegate { // // /** // * Complete. // * // * @param completerInvocation // */ // public static void complete(CompleterInvocation completerInvocation) { // AeshContext context = completerInvocation.getAeshContext(); // String currentValue = completerInvocation.getGivenCompleteValue(); // // CompleteOperation completeOperation = new CompleteOperation(context, currentValue, 0); // if (StringUtils.isBlank(currentValue)) // new FileLister("", context.getCurrentWorkingDirectory()). // findMatchingDirectories(completeOperation); // else // new FileLister(currentValue, // context.getCurrentWorkingDirectory()).findMatchingDirectories(completeOperation); // // if (completeOperation.getCompletionCandidates().size() > 1) { // completeOperation.removeEscapedSpacesFromCompletionCandidates(); // } // // completerInvocation.setCompleterValuesTerminalString(completeOperation.getCompletionCandidates()); // if (currentValue != null && completerInvocation.getCompleterValues().size() == 1) { // completerInvocation.setAppendSpace(completeOperation.hasAppendSeparator()); // } // } // // } // Path: shell/src/main/java/org/artificer/shell/archive/AddEntryArchiveCommand.java import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.artificer.atom.archive.ArtificerArchiveException; import org.artificer.common.ArtifactType; import org.artificer.shell.i18n.Messages; import org.artificer.shell.util.ArtifactTypeCompleter; import org.artificer.shell.util.FileNameCompleterDelegate; import org.jboss.aesh.cl.Arguments; import org.jboss.aesh.cl.CommandDefinition; import org.jboss.aesh.cl.Option; import org.jboss.aesh.cl.completer.OptionCompleter; import org.jboss.aesh.console.command.CommandResult; import org.jboss.aesh.console.command.completer.CompleterInvocation; import org.jboss.aesh.console.command.invocation.CommandInvocation; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import java.io.File; import java.io.InputStream; import java.util.List; } String pathToContent = optionalArgument(arguments, 0); InputStream contentStream = null; try { ArtifactType artifactType = ArtifactType.valueOf(type); String name = new File(type).getName(); if (pathToContent != null) { File contentFile = new File(pathToContent); contentStream = FileUtils.openInputStream(contentFile); } BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); currentArchive(commandInvocation).addEntry(entryPath, artifact, contentStream); commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.Added", entryPath)); } catch (ArtificerArchiveException e) { commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.ArtificerArchiveException", e.getLocalizedMessage())); } finally { IOUtils.closeQuietly(contentStream); } return CommandResult.SUCCESS; } private static class Completer implements OptionCompleter<CompleterInvocation> { @Override public void complete(CompleterInvocation completerInvocation) { AddEntryArchiveCommand command = (AddEntryArchiveCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) {
FileNameCompleterDelegate.complete(completerInvocation);
ArtificerRepo/artificer
repository/test/src/test/java/org/artificer/repository/test/ConstraintTest.java
// Path: common/src/main/java/org/artificer/common/error/ArtificerConflictException.java // public class ArtificerConflictException extends ArtificerUserException { // // private static final long serialVersionUID = 8618489938635309807L; // // public ArtificerConflictException() { // super(); // } // // public ArtificerConflictException(String message) { // super(message); // } // // public ArtificerConflictException(String msg, String stackTrace) { // super(msg, stackTrace); // } // // public static ArtificerConflictException artifactConflict(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("ARTIFACT_ALREADY_EXISTS", uuid)); // } // // public static ArtificerConflictException derivedRelationshipCreation(String relationshipType) { // return new ArtificerConflictException(Messages.i18n.format("DERIVED_RELATIONSHIP_CREATION", relationshipType)); // } // // public static ArtificerConflictException relationshipConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("RELATIONSHIP_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException reservedName(String name) { // return new ArtificerConflictException(Messages.i18n.format("RESERVED_WORD", name)); // } // // public static ArtificerConflictException customPropertyConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("CUSTOM_PROPERTY_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException classifierConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("CLASSIFIER_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException ontologyConflict(String ontologyUuid) { // return new ArtificerConflictException(Messages.i18n.format("ONTOLOGY_ALREADY_EXISTS", ontologyUuid)); // } // // public static ArtificerConflictException storedQueryConflict() { // return new ArtificerConflictException(Messages.i18n.format("STOREDQUERY_NAME_REQUIRED")); // } // // public static ArtificerConflictException storedQueryConflict(String queryName) { // return new ArtificerConflictException(Messages.i18n.format("STOREDQUERY_ALREADY_EXISTS", queryName)); // } // // public static ArtificerConflictException duplicateName(String name) { // return new ArtificerConflictException(Messages.i18n.format("DUPLICATE_NAME", name)); // } // } // // Path: api/src/main/java/org/oasis_open/docs/s_ramp/ns/s_ramp_v1/TaskEnum.java // @XmlType(name = "taskEnum") // @XmlEnum(BaseArtifactEnum.class) // public enum TaskEnum { // // @XmlEnumValue("Task") // TASK(BaseArtifactEnum.TASK); // private final BaseArtifactEnum value; // // TaskEnum(BaseArtifactEnum v) { // value = v; // } // // public BaseArtifactEnum value() { // return value; // } // // public static TaskEnum fromValue(BaseArtifactEnum v) { // for (TaskEnum c: TaskEnum.values()) { // if (c.value.equals(v)) { // return c; // } // } // throw new IllegalArgumentException(v.toString()); // } // // }
import java.io.InputStream; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.artificer.common.ArtifactContent; import org.artificer.common.ArtifactType; import org.artificer.common.ArtificerModelUtils; import org.artificer.common.error.ArtificerConflictException; import org.artificer.common.query.ArtifactSummary; import org.artificer.repository.query.PagedResult; import org.junit.Test; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Actor; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Task; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.TaskEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.TaskTarget; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.WsdlDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XsdDocument;
/* * Copyright 2014 JBoss Inc * * 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 org.artificer.repository.test; /** * @author Brett Meyer. */ public class ConstraintTest extends AbstractNoAuditingPersistenceTest { @Test public void testDelete() throws Exception { // Add an artifact Task task = new Task(); task.setArtifactType(BaseArtifactEnum.TASK); task = (Task) persistenceManager.persistArtifact(task, null); // Create another artifact with a generic relationship targeting the original. Actor actor = new Actor(); actor.setArtifactType(BaseArtifactEnum.ACTOR); ArtificerModelUtils.addGenericRelationship(actor, "fooRelationship", task.getUuid()); actor = (Actor) persistenceManager.persistArtifact(actor, null); // Verify deleting the original fails boolean caught = false; try { persistenceManager.deleteArtifact(task.getUuid(), ArtifactType.valueOf(task), false);
// Path: common/src/main/java/org/artificer/common/error/ArtificerConflictException.java // public class ArtificerConflictException extends ArtificerUserException { // // private static final long serialVersionUID = 8618489938635309807L; // // public ArtificerConflictException() { // super(); // } // // public ArtificerConflictException(String message) { // super(message); // } // // public ArtificerConflictException(String msg, String stackTrace) { // super(msg, stackTrace); // } // // public static ArtificerConflictException artifactConflict(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("ARTIFACT_ALREADY_EXISTS", uuid)); // } // // public static ArtificerConflictException derivedRelationshipCreation(String relationshipType) { // return new ArtificerConflictException(Messages.i18n.format("DERIVED_RELATIONSHIP_CREATION", relationshipType)); // } // // public static ArtificerConflictException relationshipConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("RELATIONSHIP_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException reservedName(String name) { // return new ArtificerConflictException(Messages.i18n.format("RESERVED_WORD", name)); // } // // public static ArtificerConflictException customPropertyConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("CUSTOM_PROPERTY_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException classifierConstraint(String uuid) { // return new ArtificerConflictException(Messages.i18n.format("CLASSIFIER_CONSTRAINT", uuid)); // } // // public static ArtificerConflictException ontologyConflict(String ontologyUuid) { // return new ArtificerConflictException(Messages.i18n.format("ONTOLOGY_ALREADY_EXISTS", ontologyUuid)); // } // // public static ArtificerConflictException storedQueryConflict() { // return new ArtificerConflictException(Messages.i18n.format("STOREDQUERY_NAME_REQUIRED")); // } // // public static ArtificerConflictException storedQueryConflict(String queryName) { // return new ArtificerConflictException(Messages.i18n.format("STOREDQUERY_ALREADY_EXISTS", queryName)); // } // // public static ArtificerConflictException duplicateName(String name) { // return new ArtificerConflictException(Messages.i18n.format("DUPLICATE_NAME", name)); // } // } // // Path: api/src/main/java/org/oasis_open/docs/s_ramp/ns/s_ramp_v1/TaskEnum.java // @XmlType(name = "taskEnum") // @XmlEnum(BaseArtifactEnum.class) // public enum TaskEnum { // // @XmlEnumValue("Task") // TASK(BaseArtifactEnum.TASK); // private final BaseArtifactEnum value; // // TaskEnum(BaseArtifactEnum v) { // value = v; // } // // public BaseArtifactEnum value() { // return value; // } // // public static TaskEnum fromValue(BaseArtifactEnum v) { // for (TaskEnum c: TaskEnum.values()) { // if (c.value.equals(v)) { // return c; // } // } // throw new IllegalArgumentException(v.toString()); // } // // } // Path: repository/test/src/test/java/org/artificer/repository/test/ConstraintTest.java import java.io.InputStream; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.artificer.common.ArtifactContent; import org.artificer.common.ArtifactType; import org.artificer.common.ArtificerModelUtils; import org.artificer.common.error.ArtificerConflictException; import org.artificer.common.query.ArtifactSummary; import org.artificer.repository.query.PagedResult; import org.junit.Test; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Actor; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.Task; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.TaskEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.TaskTarget; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.WsdlDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XsdDocument; /* * Copyright 2014 JBoss Inc * * 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 org.artificer.repository.test; /** * @author Brett Meyer. */ public class ConstraintTest extends AbstractNoAuditingPersistenceTest { @Test public void testDelete() throws Exception { // Add an artifact Task task = new Task(); task.setArtifactType(BaseArtifactEnum.TASK); task = (Task) persistenceManager.persistArtifact(task, null); // Create another artifact with a generic relationship targeting the original. Actor actor = new Actor(); actor.setArtifactType(BaseArtifactEnum.ACTOR); ArtificerModelUtils.addGenericRelationship(actor, "fooRelationship", task.getUuid()); actor = (Actor) persistenceManager.persistArtifact(actor, null); // Verify deleting the original fails boolean caught = false; try { persistenceManager.deleteArtifact(task.getUuid(), ArtifactType.valueOf(task), false);
} catch (ArtificerConflictException e) {
ArtificerRepo/artificer
test/src/test/java/org/artificer/test/client/ArtificerAtomApiClientTest.java
// Path: api/src/main/java/org/oasis_open/docs/s_ramp/ns/s_ramp_v1/ExtendedArtifactType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "ExtendedArtifactType") // public class ExtendedArtifactType // extends BaseArtifactType // implements Serializable // { // // private static final long serialVersionUID = -206412977040808162L; // @XmlAttribute(name = "extendedType") // protected String extendedType; // // /** // * Gets the value of the extendedType property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getExtendedType() { // return extendedType; // } // // /** // * Sets the value of the extendedType property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setExtendedType(String value) { // this.extendedType = value; // } // // }
import org.apache.commons.io.IOUtils; import org.artificer.atom.archive.ArtificerArchive; import org.artificer.atom.mappers.RdfToOntologyMapper; import org.artificer.client.ArtificerAtomApiClient; import org.artificer.client.ontology.OntologySummary; import org.artificer.common.query.ArtifactSummary; import org.artificer.client.query.QueryResultSet; import org.artificer.common.ArtifactType; import org.artificer.common.ArtificerModelUtils; import org.artificer.common.error.ArtificerServerException; import org.artificer.common.ontology.ArtificerOntology; import org.junit.Assert; import org.junit.Test; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XmlDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XsdDocument; import org.w3._1999._02._22_rdf_syntax_ns_.RDF; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import static org.junit.Assert.fail;
/* * Copyright 2012 JBoss Inc * * 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 org.artificer.test.client; /** * Unit test for the bulk of the s-ramp client features. * * @author eric.wittmann@redhat.com * @author Brett Meyer */ public class ArtificerAtomApiClientTest extends AbstractClientTest { /** * Test method for {@link org.artificer.client.ArtificerAtomApiClient#uploadArtifact(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)}. */ @Test public void testUploadArtifact() throws Exception { String artifactFileName = "PO.xsd"; InputStream is = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); try { ArtificerAtomApiClient client = client(); BaseArtifactType artifact = client.uploadArtifact(ArtifactType.XsdDocument(), is, artifactFileName); Assert.assertNotNull(artifact); Assert.assertEquals(artifactFileName, artifact.getName()); } finally { IOUtils.closeQuietly(is); } } /** * Test method for {@link org.artificer.client.ArtificerAtomApiClient#createArtifact(BaseArtifactType)}. */ @Test public void testCreateArtifact() throws Exception {
// Path: api/src/main/java/org/oasis_open/docs/s_ramp/ns/s_ramp_v1/ExtendedArtifactType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "ExtendedArtifactType") // public class ExtendedArtifactType // extends BaseArtifactType // implements Serializable // { // // private static final long serialVersionUID = -206412977040808162L; // @XmlAttribute(name = "extendedType") // protected String extendedType; // // /** // * Gets the value of the extendedType property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getExtendedType() { // return extendedType; // } // // /** // * Sets the value of the extendedType property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setExtendedType(String value) { // this.extendedType = value; // } // // } // Path: test/src/test/java/org/artificer/test/client/ArtificerAtomApiClientTest.java import org.apache.commons.io.IOUtils; import org.artificer.atom.archive.ArtificerArchive; import org.artificer.atom.mappers.RdfToOntologyMapper; import org.artificer.client.ArtificerAtomApiClient; import org.artificer.client.ontology.OntologySummary; import org.artificer.common.query.ArtifactSummary; import org.artificer.client.query.QueryResultSet; import org.artificer.common.ArtifactType; import org.artificer.common.ArtificerModelUtils; import org.artificer.common.error.ArtificerServerException; import org.artificer.common.ontology.ArtificerOntology; import org.junit.Assert; import org.junit.Test; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactEnum; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedArtifactType; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.ExtendedDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XmlDocument; import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.XsdDocument; import org.w3._1999._02._22_rdf_syntax_ns_.RDF; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import static org.junit.Assert.fail; /* * Copyright 2012 JBoss Inc * * 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 org.artificer.test.client; /** * Unit test for the bulk of the s-ramp client features. * * @author eric.wittmann@redhat.com * @author Brett Meyer */ public class ArtificerAtomApiClientTest extends AbstractClientTest { /** * Test method for {@link org.artificer.client.ArtificerAtomApiClient#uploadArtifact(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)}. */ @Test public void testUploadArtifact() throws Exception { String artifactFileName = "PO.xsd"; InputStream is = this.getClass().getResourceAsStream("/sample-files/xsd/" + artifactFileName); try { ArtificerAtomApiClient client = client(); BaseArtifactType artifact = client.uploadArtifact(ArtifactType.XsdDocument(), is, artifactFileName); Assert.assertNotNull(artifact); Assert.assertEquals(artifactFileName, artifact.getName()); } finally { IOUtils.closeQuietly(is); } } /** * Test method for {@link org.artificer.client.ArtificerAtomApiClient#createArtifact(BaseArtifactType)}. */ @Test public void testCreateArtifact() throws Exception {
ExtendedArtifactType artifact = new ExtendedArtifactType();
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/service/recommendation/RecommendationContentProvider.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.support.annotation.NonNull; import android.util.Log; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLDecoder; import javax.inject.Inject; import eu.se_bastiaan.tvnl.TVNLApplication; import okhttp3.OkHttpClient;
package eu.se_bastiaan.tvnl.service.recommendation; public class RecommendationContentProvider extends ContentProvider { public static String AUTHORITY = "eu.se_basitaan.tvnl.RecommendationContentProvider"; public static String CONTENT_URI = "content://" + AUTHORITY + "/"; @Inject OkHttpClient okHttpClient; @Override public boolean onCreate() {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/service/recommendation/RecommendationContentProvider.java import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; import android.support.annotation.NonNull; import android.util.Log; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLDecoder; import javax.inject.Inject; import eu.se_bastiaan.tvnl.TVNLApplication; import okhttp3.OkHttpClient; package eu.se_bastiaan.tvnl.service.recommendation; public class RecommendationContentProvider extends ContentProvider { public static String AUTHORITY = "eu.se_basitaan.tvnl.RecommendationContentProvider"; public static String CONTENT_URI = "content://" + AUTHORITY + "/"; @Inject OkHttpClient okHttpClient; @Override public boolean onCreate() {
TVNLApplication.get().appComponent().inject(this);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // }
import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder;
/* * Copyright (C) 2016 Brian Wernick * * 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 eu.se_bastiaan.tvnl.exomedia; /** * This is a support VideoView that will use the standard VideoView on devices below * JellyBean. On devices with JellyBean and up we will use the ExoPlayer in order to * better support HLS streaming and full 1080p video resolutions which the VideoView * struggles with, and in some cases crashes. * <p> * To an external user this view should have the same APIs used with the standard VideoView * to help with quick implementations. */ @SuppressWarnings("UnusedDeclaration") public class TVNLVideoView extends EMVideoView { public TVNLVideoView(Context context) { super(context); } public TVNLVideoView(Context context, AttributeSet attrs) { super(context, attrs); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS:
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder; /* * Copyright (C) 2016 Brian Wernick * * 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 eu.se_bastiaan.tvnl.exomedia; /** * This is a support VideoView that will use the standard VideoView on devices below * JellyBean. On devices with JellyBean and up we will use the ExoPlayer in order to * better support HLS streaming and full 1080p video resolutions which the VideoView * struggles with, and in some cases crashes. * <p> * To an external user this view should have the same APIs used with the standard VideoView * to help with quick implementations. */ @SuppressWarnings("UnusedDeclaration") public class TVNLVideoView extends EMVideoView { public TVNLVideoView(Context context) { super(context); } public TVNLVideoView(Context context, AttributeSet attrs) { super(context, attrs); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS:
return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // }
import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder;
super(context, attrs); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS: return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case DASH:
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder; super(context, attrs); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS: return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case DASH:
return new DashRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // }
import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder;
public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS: return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case DASH: return new DashRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case SMOOTH_STREAM:
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java // public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder { // // public DashRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public DashRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder { // // public HlsRenderBuilder(Context context, String userAgent, String url) { // super(context, userAgent, url); // } // // public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) // public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder { // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url) { // this(context, userAgent, url, AudioManager.STREAM_MUSIC); // } // // public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) { // super(context, userAgent, url, streamType); // } // // @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders // protected UriDataSource createManifestDataSource(Context context, String userAgent) { // return new OkUriDataSource(context, userAgent); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.util.AttributeSet; import com.devbrackets.android.exomedia.core.builder.RenderBuilder; import com.devbrackets.android.exomedia.core.video.ExoVideoView; import com.devbrackets.android.exomedia.type.MediaSourceType; import com.devbrackets.android.exomedia.ui.widget.EMVideoView; import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder; import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder; public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setVideoURI(Uri uri) { RenderBuilder builder = null; if(uri != null) { builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri); } setVideoURI(uri, builder); } protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) { String userAgent = ""; if (videoViewImpl instanceof ExoVideoView) { userAgent = ((ExoVideoView) videoViewImpl).getUserAgent(); } switch (renderType) { case HLS: return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case DASH: return new DashRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString()); case SMOOTH_STREAM:
return new SmoothStreamRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/model/EncryptedStreamData.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/KeyProvider.java // public class KeyProvider { // // private static final byte[] data = {-19, -97, -77, -13, -91, -100, -69, -18, -117, -110, -18, -103, -96, -18, -90, -106, -18, -74, -89, -17, -124, -113, -17, -110, -67, -17, -95, -119, -17, -80, -87, -17, -66, -89, -51, -112, -35, -93, -32, -85, -122, -32, -71, -71, -31, -122, -114, -31, -105, -82, -31, -92, -105, -31, -78, -78, -30, -127, -117, -30, -112, -92, -30, -97, -106, -30, -83, -85, -30, -69, -118, -29, -118, -85, -29, -104, -121, -29, -89, -106, -29, -73, -89, -28, -124, -112, -28, -110, -92, -28, -95, -102}; // // static String decode(byte[] paramArrayOfByte) { // try { // char[] arrayOfChar = new String(paramArrayOfByte, "UTF-8").toCharArray(); // int i = 8574923; // for (int j = 0; j < arrayOfChar.length; j++) { // arrayOfChar[j] = ((char) (i ^ arrayOfChar[j])); // i += 930; // } // return String.valueOf(arrayOfChar); // } catch (UnsupportedEncodingException localUnsupportedEncodingException) { // } // return null; // } // // public static String data() { // return decode(data); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/util/SecurityUtil.java // public class SecurityUtil { // // public static String decrypt(String key, String iv, String data) { // try { // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); // Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); // cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv.substring(0, 16).getBytes("UTF-8"))); // return new String(cipher.doFinal(Base64.decode(data, Base64.NO_PADDING)), "UTF-8"); // } catch (Exception e) { // e.printStackTrace(); // return null; // } // } // // }
import eu.se_bastiaan.tvnl.content.KeyProvider; import eu.se_bastiaan.tvnl.util.SecurityUtil;
package eu.se_bastiaan.tvnl.model; public class EncryptedStreamData { private String data; private String iv; private Boolean tt888; public String getData() { return data; } public String getIv() { return iv; } public String getUrl() {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/KeyProvider.java // public class KeyProvider { // // private static final byte[] data = {-19, -97, -77, -13, -91, -100, -69, -18, -117, -110, -18, -103, -96, -18, -90, -106, -18, -74, -89, -17, -124, -113, -17, -110, -67, -17, -95, -119, -17, -80, -87, -17, -66, -89, -51, -112, -35, -93, -32, -85, -122, -32, -71, -71, -31, -122, -114, -31, -105, -82, -31, -92, -105, -31, -78, -78, -30, -127, -117, -30, -112, -92, -30, -97, -106, -30, -83, -85, -30, -69, -118, -29, -118, -85, -29, -104, -121, -29, -89, -106, -29, -73, -89, -28, -124, -112, -28, -110, -92, -28, -95, -102}; // // static String decode(byte[] paramArrayOfByte) { // try { // char[] arrayOfChar = new String(paramArrayOfByte, "UTF-8").toCharArray(); // int i = 8574923; // for (int j = 0; j < arrayOfChar.length; j++) { // arrayOfChar[j] = ((char) (i ^ arrayOfChar[j])); // i += 930; // } // return String.valueOf(arrayOfChar); // } catch (UnsupportedEncodingException localUnsupportedEncodingException) { // } // return null; // } // // public static String data() { // return decode(data); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/util/SecurityUtil.java // public class SecurityUtil { // // public static String decrypt(String key, String iv, String data) { // try { // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); // Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); // cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv.substring(0, 16).getBytes("UTF-8"))); // return new String(cipher.doFinal(Base64.decode(data, Base64.NO_PADDING)), "UTF-8"); // } catch (Exception e) { // e.printStackTrace(); // return null; // } // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/EncryptedStreamData.java import eu.se_bastiaan.tvnl.content.KeyProvider; import eu.se_bastiaan.tvnl.util.SecurityUtil; package eu.se_bastiaan.tvnl.model; public class EncryptedStreamData { private String data; private String iv; private Boolean tt888; public String getData() { return data; } public String getIv() { return iv; } public String getUrl() {
return SecurityUtil.decrypt(KeyProvider.data(), getIv(), getData());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/model/EncryptedStreamData.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/KeyProvider.java // public class KeyProvider { // // private static final byte[] data = {-19, -97, -77, -13, -91, -100, -69, -18, -117, -110, -18, -103, -96, -18, -90, -106, -18, -74, -89, -17, -124, -113, -17, -110, -67, -17, -95, -119, -17, -80, -87, -17, -66, -89, -51, -112, -35, -93, -32, -85, -122, -32, -71, -71, -31, -122, -114, -31, -105, -82, -31, -92, -105, -31, -78, -78, -30, -127, -117, -30, -112, -92, -30, -97, -106, -30, -83, -85, -30, -69, -118, -29, -118, -85, -29, -104, -121, -29, -89, -106, -29, -73, -89, -28, -124, -112, -28, -110, -92, -28, -95, -102}; // // static String decode(byte[] paramArrayOfByte) { // try { // char[] arrayOfChar = new String(paramArrayOfByte, "UTF-8").toCharArray(); // int i = 8574923; // for (int j = 0; j < arrayOfChar.length; j++) { // arrayOfChar[j] = ((char) (i ^ arrayOfChar[j])); // i += 930; // } // return String.valueOf(arrayOfChar); // } catch (UnsupportedEncodingException localUnsupportedEncodingException) { // } // return null; // } // // public static String data() { // return decode(data); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/util/SecurityUtil.java // public class SecurityUtil { // // public static String decrypt(String key, String iv, String data) { // try { // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); // Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); // cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv.substring(0, 16).getBytes("UTF-8"))); // return new String(cipher.doFinal(Base64.decode(data, Base64.NO_PADDING)), "UTF-8"); // } catch (Exception e) { // e.printStackTrace(); // return null; // } // } // // }
import eu.se_bastiaan.tvnl.content.KeyProvider; import eu.se_bastiaan.tvnl.util.SecurityUtil;
package eu.se_bastiaan.tvnl.model; public class EncryptedStreamData { private String data; private String iv; private Boolean tt888; public String getData() { return data; } public String getIv() { return iv; } public String getUrl() {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/KeyProvider.java // public class KeyProvider { // // private static final byte[] data = {-19, -97, -77, -13, -91, -100, -69, -18, -117, -110, -18, -103, -96, -18, -90, -106, -18, -74, -89, -17, -124, -113, -17, -110, -67, -17, -95, -119, -17, -80, -87, -17, -66, -89, -51, -112, -35, -93, -32, -85, -122, -32, -71, -71, -31, -122, -114, -31, -105, -82, -31, -92, -105, -31, -78, -78, -30, -127, -117, -30, -112, -92, -30, -97, -106, -30, -83, -85, -30, -69, -118, -29, -118, -85, -29, -104, -121, -29, -89, -106, -29, -73, -89, -28, -124, -112, -28, -110, -92, -28, -95, -102}; // // static String decode(byte[] paramArrayOfByte) { // try { // char[] arrayOfChar = new String(paramArrayOfByte, "UTF-8").toCharArray(); // int i = 8574923; // for (int j = 0; j < arrayOfChar.length; j++) { // arrayOfChar[j] = ((char) (i ^ arrayOfChar[j])); // i += 930; // } // return String.valueOf(arrayOfChar); // } catch (UnsupportedEncodingException localUnsupportedEncodingException) { // } // return null; // } // // public static String data() { // return decode(data); // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/util/SecurityUtil.java // public class SecurityUtil { // // public static String decrypt(String key, String iv, String data) { // try { // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); // Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); // cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv.substring(0, 16).getBytes("UTF-8"))); // return new String(cipher.doFinal(Base64.decode(data, Base64.NO_PADDING)), "UTF-8"); // } catch (Exception e) { // e.printStackTrace(); // return null; // } // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/EncryptedStreamData.java import eu.se_bastiaan.tvnl.content.KeyProvider; import eu.se_bastiaan.tvnl.util.SecurityUtil; package eu.se_bastiaan.tvnl.model; public class EncryptedStreamData { private String data; private String iv; private Boolean tt888; public String getData() { return data; } public String getIv() { return iv; } public String getUrl() {
return SecurityUtil.decrypt(KeyProvider.data(), getIv(), getData());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/MainActivity.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/event/UpdateBackgroundEvent.java // public class UpdateBackgroundEvent { // // private Drawable drawable; // private String url; // @DrawableRes // private Integer res = -1; // // public UpdateBackgroundEvent() { // drawable = null; // url = null; // } // // public UpdateBackgroundEvent(Drawable drawable) { // this.drawable = drawable; // } // // public UpdateBackgroundEvent(String url) { // this.url = url; // } // // public UpdateBackgroundEvent(@DrawableRes Integer res) { // this.res = res; // } // // public Drawable getDrawable() { // return drawable; // } // // public String getUrl() { // return url; // } // // public Integer getResource() { // return res; // } // // public Boolean isDrawable() { // return drawable != null; // } // // public Boolean isUrl() { // return url != null; // } // // public Boolean isResource() { // return res != -1; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/base/BaseActivity.java // public abstract class BaseActivity extends FragmentActivity { // // private static final int PERMISSIONS_REQUEST = 1; // // @Inject // protected EventBus eventBus; // // BackgroundUpdater backgroundManager; // // public void onCreate(Bundle savedInstanceState, @LayoutRes int layoutRes) { // super.onCreate(savedInstanceState); // setContentView(layoutRes); // ButterKnife.bind(this); // // injectComponent(TVNLApplication.get().appComponent()); // // backgroundManager = BackgroundUpdater.init(this, R.drawable.default_background); // } // // @Override // protected void attachBaseContext(Context newBase) { // super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); // } // // @Override // public boolean onSearchRequested() { // if(ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) { // SearchActivity.startActivity(this); // } else { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST); // } // return true; // } // // @Override // protected void onDestroy() { // super.onDestroy(); // backgroundManager.destroy(); // } // // @Subscribe // public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { // if(updateBackgroundEvent.isDrawable()) { // Drawable drawable = updateBackgroundEvent.getDrawable(); // backgroundManager.updateBackground(drawable); // } else if(updateBackgroundEvent.isResource()) { // backgroundManager.updateBackground(updateBackgroundEvent.getResource()); // } else if(updateBackgroundEvent.isUrl()){ // backgroundManager.updateBackgroundAsync(updateBackgroundEvent.getUrl()); // } else { // backgroundManager.clearBackground(); // } // } // // protected abstract void injectComponent(AppInjectionComponent component); // // @Override // public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { // super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if(PERMISSIONS_REQUEST == requestCode) { // boolean success = true; // for (int result : grantResults) { // if (result == PackageManager.PERMISSION_DENIED) { // success = false; // break; // } // } // // if (success) // SearchActivity.startActivity(this); // } // } // }
import android.annotation.SuppressLint; import android.os.Bundle; import com.squareup.otto.Subscribe; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.event.UpdateBackgroundEvent; import eu.se_bastiaan.tvnl.ui.activity.base.BaseActivity;
package eu.se_bastiaan.tvnl.ui.activity; public class MainActivity extends BaseActivity { @SuppressLint("MissingSuperCall") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_main); } @Override protected void onResume() { super.onResume(); eventBus.register(this); } @Override protected void onPause() { super.onPause(); eventBus.unregister(this); } @Subscribe @Override
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/event/UpdateBackgroundEvent.java // public class UpdateBackgroundEvent { // // private Drawable drawable; // private String url; // @DrawableRes // private Integer res = -1; // // public UpdateBackgroundEvent() { // drawable = null; // url = null; // } // // public UpdateBackgroundEvent(Drawable drawable) { // this.drawable = drawable; // } // // public UpdateBackgroundEvent(String url) { // this.url = url; // } // // public UpdateBackgroundEvent(@DrawableRes Integer res) { // this.res = res; // } // // public Drawable getDrawable() { // return drawable; // } // // public String getUrl() { // return url; // } // // public Integer getResource() { // return res; // } // // public Boolean isDrawable() { // return drawable != null; // } // // public Boolean isUrl() { // return url != null; // } // // public Boolean isResource() { // return res != -1; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/base/BaseActivity.java // public abstract class BaseActivity extends FragmentActivity { // // private static final int PERMISSIONS_REQUEST = 1; // // @Inject // protected EventBus eventBus; // // BackgroundUpdater backgroundManager; // // public void onCreate(Bundle savedInstanceState, @LayoutRes int layoutRes) { // super.onCreate(savedInstanceState); // setContentView(layoutRes); // ButterKnife.bind(this); // // injectComponent(TVNLApplication.get().appComponent()); // // backgroundManager = BackgroundUpdater.init(this, R.drawable.default_background); // } // // @Override // protected void attachBaseContext(Context newBase) { // super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); // } // // @Override // public boolean onSearchRequested() { // if(ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) { // SearchActivity.startActivity(this); // } else { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST); // } // return true; // } // // @Override // protected void onDestroy() { // super.onDestroy(); // backgroundManager.destroy(); // } // // @Subscribe // public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { // if(updateBackgroundEvent.isDrawable()) { // Drawable drawable = updateBackgroundEvent.getDrawable(); // backgroundManager.updateBackground(drawable); // } else if(updateBackgroundEvent.isResource()) { // backgroundManager.updateBackground(updateBackgroundEvent.getResource()); // } else if(updateBackgroundEvent.isUrl()){ // backgroundManager.updateBackgroundAsync(updateBackgroundEvent.getUrl()); // } else { // backgroundManager.clearBackground(); // } // } // // protected abstract void injectComponent(AppInjectionComponent component); // // @Override // public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { // super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if(PERMISSIONS_REQUEST == requestCode) { // boolean success = true; // for (int result : grantResults) { // if (result == PackageManager.PERMISSION_DENIED) { // success = false; // break; // } // } // // if (success) // SearchActivity.startActivity(this); // } // } // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/MainActivity.java import android.annotation.SuppressLint; import android.os.Bundle; import com.squareup.otto.Subscribe; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.event.UpdateBackgroundEvent; import eu.se_bastiaan.tvnl.ui.activity.base.BaseActivity; package eu.se_bastiaan.tvnl.ui.activity; public class MainActivity extends BaseActivity { @SuppressLint("MissingSuperCall") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_main); } @Override protected void onResume() { super.onResume(); eventBus.register(this); } @Override protected void onPause() { super.onPause(); eventBus.unregister(this); } @Subscribe @Override
public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) {
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/MainActivity.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/event/UpdateBackgroundEvent.java // public class UpdateBackgroundEvent { // // private Drawable drawable; // private String url; // @DrawableRes // private Integer res = -1; // // public UpdateBackgroundEvent() { // drawable = null; // url = null; // } // // public UpdateBackgroundEvent(Drawable drawable) { // this.drawable = drawable; // } // // public UpdateBackgroundEvent(String url) { // this.url = url; // } // // public UpdateBackgroundEvent(@DrawableRes Integer res) { // this.res = res; // } // // public Drawable getDrawable() { // return drawable; // } // // public String getUrl() { // return url; // } // // public Integer getResource() { // return res; // } // // public Boolean isDrawable() { // return drawable != null; // } // // public Boolean isUrl() { // return url != null; // } // // public Boolean isResource() { // return res != -1; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/base/BaseActivity.java // public abstract class BaseActivity extends FragmentActivity { // // private static final int PERMISSIONS_REQUEST = 1; // // @Inject // protected EventBus eventBus; // // BackgroundUpdater backgroundManager; // // public void onCreate(Bundle savedInstanceState, @LayoutRes int layoutRes) { // super.onCreate(savedInstanceState); // setContentView(layoutRes); // ButterKnife.bind(this); // // injectComponent(TVNLApplication.get().appComponent()); // // backgroundManager = BackgroundUpdater.init(this, R.drawable.default_background); // } // // @Override // protected void attachBaseContext(Context newBase) { // super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); // } // // @Override // public boolean onSearchRequested() { // if(ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) { // SearchActivity.startActivity(this); // } else { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST); // } // return true; // } // // @Override // protected void onDestroy() { // super.onDestroy(); // backgroundManager.destroy(); // } // // @Subscribe // public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { // if(updateBackgroundEvent.isDrawable()) { // Drawable drawable = updateBackgroundEvent.getDrawable(); // backgroundManager.updateBackground(drawable); // } else if(updateBackgroundEvent.isResource()) { // backgroundManager.updateBackground(updateBackgroundEvent.getResource()); // } else if(updateBackgroundEvent.isUrl()){ // backgroundManager.updateBackgroundAsync(updateBackgroundEvent.getUrl()); // } else { // backgroundManager.clearBackground(); // } // } // // protected abstract void injectComponent(AppInjectionComponent component); // // @Override // public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { // super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if(PERMISSIONS_REQUEST == requestCode) { // boolean success = true; // for (int result : grantResults) { // if (result == PackageManager.PERMISSION_DENIED) { // success = false; // break; // } // } // // if (success) // SearchActivity.startActivity(this); // } // } // }
import android.annotation.SuppressLint; import android.os.Bundle; import com.squareup.otto.Subscribe; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.event.UpdateBackgroundEvent; import eu.se_bastiaan.tvnl.ui.activity.base.BaseActivity;
package eu.se_bastiaan.tvnl.ui.activity; public class MainActivity extends BaseActivity { @SuppressLint("MissingSuperCall") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_main); } @Override protected void onResume() { super.onResume(); eventBus.register(this); } @Override protected void onPause() { super.onPause(); eventBus.unregister(this); } @Subscribe @Override public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { super.updateBackground(updateBackgroundEvent); } @Override
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/event/UpdateBackgroundEvent.java // public class UpdateBackgroundEvent { // // private Drawable drawable; // private String url; // @DrawableRes // private Integer res = -1; // // public UpdateBackgroundEvent() { // drawable = null; // url = null; // } // // public UpdateBackgroundEvent(Drawable drawable) { // this.drawable = drawable; // } // // public UpdateBackgroundEvent(String url) { // this.url = url; // } // // public UpdateBackgroundEvent(@DrawableRes Integer res) { // this.res = res; // } // // public Drawable getDrawable() { // return drawable; // } // // public String getUrl() { // return url; // } // // public Integer getResource() { // return res; // } // // public Boolean isDrawable() { // return drawable != null; // } // // public Boolean isUrl() { // return url != null; // } // // public Boolean isResource() { // return res != -1; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/base/BaseActivity.java // public abstract class BaseActivity extends FragmentActivity { // // private static final int PERMISSIONS_REQUEST = 1; // // @Inject // protected EventBus eventBus; // // BackgroundUpdater backgroundManager; // // public void onCreate(Bundle savedInstanceState, @LayoutRes int layoutRes) { // super.onCreate(savedInstanceState); // setContentView(layoutRes); // ButterKnife.bind(this); // // injectComponent(TVNLApplication.get().appComponent()); // // backgroundManager = BackgroundUpdater.init(this, R.drawable.default_background); // } // // @Override // protected void attachBaseContext(Context newBase) { // super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); // } // // @Override // public boolean onSearchRequested() { // if(ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) { // SearchActivity.startActivity(this); // } else { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST); // } // return true; // } // // @Override // protected void onDestroy() { // super.onDestroy(); // backgroundManager.destroy(); // } // // @Subscribe // public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { // if(updateBackgroundEvent.isDrawable()) { // Drawable drawable = updateBackgroundEvent.getDrawable(); // backgroundManager.updateBackground(drawable); // } else if(updateBackgroundEvent.isResource()) { // backgroundManager.updateBackground(updateBackgroundEvent.getResource()); // } else if(updateBackgroundEvent.isUrl()){ // backgroundManager.updateBackgroundAsync(updateBackgroundEvent.getUrl()); // } else { // backgroundManager.clearBackground(); // } // } // // protected abstract void injectComponent(AppInjectionComponent component); // // @Override // public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { // super.onRequestPermissionsResult(requestCode, permissions, grantResults); // if(PERMISSIONS_REQUEST == requestCode) { // boolean success = true; // for (int result : grantResults) { // if (result == PackageManager.PERMISSION_DENIED) { // success = false; // break; // } // } // // if (success) // SearchActivity.startActivity(this); // } // } // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/activity/MainActivity.java import android.annotation.SuppressLint; import android.os.Bundle; import com.squareup.otto.Subscribe; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.event.UpdateBackgroundEvent; import eu.se_bastiaan.tvnl.ui.activity.base.BaseActivity; package eu.se_bastiaan.tvnl.ui.activity; public class MainActivity extends BaseActivity { @SuppressLint("MissingSuperCall") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState, R.layout.activity_main); } @Override protected void onResume() { super.onResume(); eventBus.register(this); } @Override protected void onPause() { super.onPause(); eventBus.unregister(this); } @Subscribe @Override public void updateBackground(UpdateBackgroundEvent updateBackgroundEvent) { super.updateBackground(updateBackgroundEvent); } @Override
protected void injectComponent(AppInjectionComponent component) {
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/glide/OkHttpGlideModule.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.content.Context; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.module.GlideModule; import java.io.InputStream; import javax.inject.Inject; import eu.se_bastiaan.tvnl.TVNLApplication; import okhttp3.OkHttpClient;
package eu.se_bastiaan.tvnl.network.glide; /** * A {@link com.bumptech.glide.module.GlideModule} implementation to replace Glide's default * {@link java.net.HttpURLConnection} based {@link com.bumptech.glide.load.model.ModelLoader} * with an OkHttp based {@link com.bumptech.glide.load.model.ModelLoader}. * <p/> * <p> If you're using gradle, you can include this module simply by depending on the aar, the * module will be merged in by manifest merger. For other build systems or for more more * information, see {@link com.bumptech.glide.module.GlideModule}. </p> */ public class OkHttpGlideModule implements GlideModule { @Inject OkHttpClient okHttpClient; @Override public void applyOptions(Context context, GlideBuilder builder) { // Do nothing. } @Override public void registerComponents(Context context, Glide glide) {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/glide/OkHttpGlideModule.java import android.content.Context; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.module.GlideModule; import java.io.InputStream; import javax.inject.Inject; import eu.se_bastiaan.tvnl.TVNLApplication; import okhttp3.OkHttpClient; package eu.se_bastiaan.tvnl.network.glide; /** * A {@link com.bumptech.glide.module.GlideModule} implementation to replace Glide's default * {@link java.net.HttpURLConnection} based {@link com.bumptech.glide.load.model.ModelLoader} * with an OkHttp based {@link com.bumptech.glide.load.model.ModelLoader}. * <p/> * <p> If you're using gradle, you can include this module simply by depending on the aar, the * module will be merged in by manifest merger. For other build systems or for more more * information, see {@link com.bumptech.glide.module.GlideModule}. </p> */ public class OkHttpGlideModule implements GlideModule { @Inject OkHttpClient okHttpClient; @Override public void applyOptions(Context context, GlideBuilder builder) { // Do nothing. } @Override public void registerComponents(Context context, Glide glide) {
TVNLApplication.get().appComponent().inject(this);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // }
import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json")
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json")
Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // }
import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json")
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json")
Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // }
import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json")
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json")
Single<RadioboxSearch<RadioboxTrack>> trackSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // }
import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json") Single<RadioboxSearch<RadioboxTrack>> trackSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("videostream/search.json")
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json") Single<RadioboxSearch<RadioboxTrack>> trackSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("videostream/search.json")
Single<RadioboxSearch<RadioboxVideostream>> videostreamSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // }
import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json") Single<RadioboxSearch<RadioboxTrack>> trackSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("videostream/search.json") Single<RadioboxSearch<RadioboxVideostream>> videostreamSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("audiofragment/search.json")
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxAudiofragment.java // public class RadioboxAudiofragment { // // private Long id; // private String url; // private String description; // @SerializedName("startdatetime") // private Date startDate; // @SerializedName("stopdatetime") // private Date stopDate; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getDescription() { // return description; // } // // public Date getStartDate() { // return startDate; // } // // public Date getStopDate() { // return stopDate; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxBroadcast.java // public class RadioboxBroadcast { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String name; // private String subname; // private String description; // @SerializedName("PRID") // private String prId; // private RadioboxImage image; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getName() { // return name; // } // // public String getSubname() { // return subname; // } // // public String getDescription() { // return description; // } // // public String getPrId() { // return prId; // } // // public RadioboxImage getImage() { // return image; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxChannel.java // public class RadioboxChannel { // // private Long id; // private String name; // private List<RadioboxVideostream> videostream; // // public Long getId() { // return id; // } // // public String getName() { // return name; // } // // public List<RadioboxVideostream> getVideostream() { // return videostream; // } // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxSearch.java // public class RadioboxSearch<T> { // // @SerializedName("page-index") // private Integer pageIndex; // @SerializedName("max-results") // private Integer maxResults; // @SerializedName("total-pages") // private Integer totalPages; // @SerializedName("total-results") // private Integer totalResults; // private List<T> results; // // public Integer getPageIndex() { // return pageIndex; // } // // public Integer getMaxResults() { // return maxResults; // } // // public Integer getTotalPages() { // return totalPages; // } // // public Integer getTotalResults() { // return totalResults; // } // // public List<T> getResults() { // return results; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxTrack.java // public class RadioboxTrack { // // private Long id; // @SerializedName("startdatetime") // private Date startTime; // @SerializedName("stopdatetime") // private Date stopTime; // private String date; // private RadioboxSongfile songfile; // private Integer channel; // // public Long getId() { // return id; // } // // public Date getStartTime() { // return startTime; // } // // public Date getStopTime() { // return stopTime; // } // // public String getDate() { // return date; // } // // public RadioboxSongfile getSongfile() { // return songfile; // } // // public Integer getChannel() { // return channel; // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/RadioboxVideostream.java // public class RadioboxVideostream { // // private Long id; // private String url; // private String name; // // public Long getId() { // return id; // } // // public String getUrl() { // return url; // } // // public String getName() { // return name; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/RadioboxApiService.java import eu.se_bastiaan.tvnl.model.RadioboxAudiofragment; import eu.se_bastiaan.tvnl.model.RadioboxBroadcast; import eu.se_bastiaan.tvnl.model.RadioboxChannel; import eu.se_bastiaan.tvnl.model.RadioboxSearch; import eu.se_bastiaan.tvnl.model.RadioboxTrack; import eu.se_bastiaan.tvnl.model.RadioboxVideostream; import retrofit2.http.GET; import retrofit2.http.Path; import retrofit2.http.Query; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface RadioboxApiService { @GET("broadcast/search.json") Single<RadioboxSearch<RadioboxBroadcast>> broadcastSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("track/search.json") Single<RadioboxSearch<RadioboxTrack>> trackSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("videostream/search.json") Single<RadioboxSearch<RadioboxVideostream>> videostreamSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order); @GET("audiofragment/search.json")
Single<RadioboxSearch<RadioboxAudiofragment>> audiofragmentSearch(@Query("q") String query, @Query("max-results") Integer limit, @Query("order") String order);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/model/VideoFragment.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/util/DurationUtil.java // public class DurationUtil { // // public static String convert(Long seconds) { // if(seconds < 57) { // return String.format(Locale.getDefault(), "%d sec", seconds); // } // int minutes = (int) Math.ceil(Math.ceil(seconds) / 60); // return String.format(Locale.getDefault(), "%d min", minutes); // } // // }
import android.os.Parcel; import android.os.Parcelable; import com.google.gson.annotations.SerializedName; import java.util.List; import java.util.Locale; import eu.se_bastiaan.tvnl.util.DurationUtil;
public String getName() { return name; } public String getDescription() { return description; } public Long getStartsAt() { return startsAt; } public Long getEndsAt() { return endsAt; } public Long getDuration() { return duration; } public Episode getEpisode() { return episode; } public List<Still> getStills() { return stills; } public OverviewGridItem<VideoFragment> toOverviewGridItem() {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/util/DurationUtil.java // public class DurationUtil { // // public static String convert(Long seconds) { // if(seconds < 57) { // return String.format(Locale.getDefault(), "%d sec", seconds); // } // int minutes = (int) Math.ceil(Math.ceil(seconds) / 60); // return String.format(Locale.getDefault(), "%d min", minutes); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/model/VideoFragment.java import android.os.Parcel; import android.os.Parcelable; import com.google.gson.annotations.SerializedName; import java.util.List; import java.util.Locale; import eu.se_bastiaan.tvnl.util.DurationUtil; public String getName() { return name; } public String getDescription() { return description; } public Long getStartsAt() { return startsAt; } public Long getEndsAt() { return endsAt; } public Long getDuration() { return duration; } public Episode getEpisode() { return episode; } public List<Still> getStills() { return stills; } public OverviewGridItem<VideoFragment> toOverviewGridItem() {
String subtitle = String.format(Locale.getDefault(), "%s • Uit: %s", DurationUtil.convert(duration), episode.getSeries().getName());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/network/service/OdiApiService.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/OdiData.java // public class OdiData { // // private Integer errorcode; // private String family; // private String path; // private String protocol; // private String server; // private Integer wait; // private String url; // // public Integer getErrorcode() { // return errorcode; // } // // public String getFamily() { // return family; // } // // public String getPath() { // return path; // } // // public String getProtocol() { // return protocol; // } // // public String getServer() { // return server; // } // // public Integer getWait() { // return wait; // } // // public String getUrl() { // return url; // } // // }
import eu.se_bastiaan.tvnl.model.OdiData; import retrofit2.http.GET; import retrofit2.http.Query; import retrofit2.http.Url; import rx.Single;
package eu.se_bastiaan.tvnl.network.service; public interface OdiApiService { @GET
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/OdiData.java // public class OdiData { // // private Integer errorcode; // private String family; // private String path; // private String protocol; // private String server; // private Integer wait; // private String url; // // public Integer getErrorcode() { // return errorcode; // } // // public String getFamily() { // return family; // } // // public String getPath() { // return path; // } // // public String getProtocol() { // return protocol; // } // // public String getServer() { // return server; // } // // public Integer getWait() { // return wait; // } // // public String getUrl() { // return url; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/network/service/OdiApiService.java import eu.se_bastiaan.tvnl.model.OdiData; import retrofit2.http.GET; import retrofit2.http.Query; import retrofit2.http.Url; import rx.Single; package eu.se_bastiaan.tvnl.network.service; public interface OdiApiService { @GET
Single<OdiData> getData(@Url String url, @Query("extension") String extension);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/util/AnimUtil.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import eu.se_bastiaan.tvnl.TVNLApplication;
package eu.se_bastiaan.tvnl.util; public class AnimUtil { public static void fadeIn(View v) { if (v.getVisibility() == View.VISIBLE) return;
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/util/AnimUtil.java import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import eu.se_bastiaan.tvnl.TVNLApplication; package eu.se_bastiaan.tvnl.util; public class AnimUtil { public static void fadeIn(View v) { if (v.getVisibility() == View.VISIBLE) return;
Animation fadeInAnim = AnimationUtils.loadAnimation(TVNLApplication.get(), android.R.anim.fade_in);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/dialog/MessageDialogFragment.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.TVNLApplication;
.setTitle(getArguments().getString(TITLE)) .setMessage(getArguments().getString(MESSAGE)); if(positiveOnClickListener != null) builder.setPositiveButton(R.string.ok, positiveOnClickListener); if(negativeOnClickListener != null) builder.setPositiveButton(R.string.close, negativeOnClickListener); if(getArguments().getBoolean(CANCELABLE, true)) { setCancelable(true); } else { setCancelable(false); } return builder.create(); } public static void show(FragmentManager fm, String title, String message, Boolean cancelable, DialogInterface.OnClickListener positiveOnClickListener, DialogInterface.OnClickListener negativeOnClickListener) { MessageDialogFragment dialogFragment = new MessageDialogFragment(); Bundle args = new Bundle(); args.putString(TITLE, title); args.putString(MESSAGE, message); args.putBoolean(CANCELABLE, cancelable); dialogFragment.setArguments(args); dialogFragment.positiveOnClickListener = positiveOnClickListener; dialogFragment.negativeOnClickListener = negativeOnClickListener; dialogFragment.show(fm, "MessageDialogFragment"); } public static void show(FragmentManager fm, int titleRes, int messageRes, Boolean cancelable, DialogInterface.OnClickListener positiveOnClickListener, DialogInterface.OnClickListener negativeOnClickListener) {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/dialog/MessageDialogFragment.java import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import eu.se_bastiaan.tvnl.R; import eu.se_bastiaan.tvnl.TVNLApplication; .setTitle(getArguments().getString(TITLE)) .setMessage(getArguments().getString(MESSAGE)); if(positiveOnClickListener != null) builder.setPositiveButton(R.string.ok, positiveOnClickListener); if(negativeOnClickListener != null) builder.setPositiveButton(R.string.close, negativeOnClickListener); if(getArguments().getBoolean(CANCELABLE, true)) { setCancelable(true); } else { setCancelable(false); } return builder.create(); } public static void show(FragmentManager fm, String title, String message, Boolean cancelable, DialogInterface.OnClickListener positiveOnClickListener, DialogInterface.OnClickListener negativeOnClickListener) { MessageDialogFragment dialogFragment = new MessageDialogFragment(); Bundle args = new Bundle(); args.putString(TITLE, title); args.putString(MESSAGE, message); args.putBoolean(CANCELABLE, cancelable); dialogFragment.setArguments(args); dialogFragment.positiveOnClickListener = positiveOnClickListener; dialogFragment.negativeOnClickListener = negativeOnClickListener; dialogFragment.show(fm, "MessageDialogFragment"); } public static void show(FragmentManager fm, int titleRes, int messageRes, Boolean cancelable, DialogInterface.OnClickListener positiveOnClickListener, DialogInterface.OnClickListener negativeOnClickListener) {
show(fm, TVNLApplication.get().getString(titleRes), TVNLApplication.get().getString(messageRes), cancelable, positiveOnClickListener, negativeOnClickListener);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java // public class RecommendationService extends IntentService { // // private static final int MAX_RECOMMENDATIONS = 3; // // @Inject // UGApiService ugApiService; // // public RecommendationService() { // super("RecommendationService"); // } // // @Override // public void onCreate() { // super.onCreate(); // TVNLApplication.get().appComponent().inject(this); // } // // @Override // protected void onHandleIntent(Intent intent) { // try { // Thread.sleep(10000); // } catch (InterruptedException e) { // e.printStackTrace(); // } // // final RecommendationBuilder builder = new RecommendationBuilder() // .setContext(getApplicationContext()) // .setSmallIcon(R.drawable.ic_recommendation); // // // ugApiService.getRecommendations() // .subscribeOn(Schedulers.newThread()) // .observeOn(Schedulers.newThread()) // .subscribe(new Action1<List<Recommendation>>() { // @Override // public void call(List<Recommendation> recommendations) { // try { // for(int i = 0; i < MAX_RECOMMENDATIONS; i++) { // Recommendation recommendation = recommendations.get(i); // builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8")) // .setId(i) // .setPriority(i) // .setTitle(recommendation.getName()) // .setDescription(recommendation.getDescription()) // .setImage(recommendation.getImage()) // .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i)) // .build(); // } // // } catch (IOException e) { // Timber.e(e, "Unable to update recommendation"); // } // } // }, new Action1<Throwable>() { // @Override // public void call(Throwable throwable) { // Timber.e(throwable, "Unable to update recommendation"); // } // }); // } // // private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) { // Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId); // return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT); // } // // }
import android.app.Application; import android.content.Intent; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.multidex.MultiDexApplication; import eu.se_bastiaan.tvnl.service.RecommendationService; import timber.log.Timber; import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
package eu.se_bastiaan.tvnl; public class TVNLApplication extends MultiDexApplication { @Nullable private volatile AppInjectionComponent appInjectionComponent; private static TVNLApplication sThis; @Override public void onCreate() { super.onCreate(); sThis = this; if(BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } else { //Timber.plant(new CrashlyticsLogTree(Log.INFO)); } CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Regular.ttf") .setFontAttrId(R.attr.fontPath) .build() );
// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java // public class RecommendationService extends IntentService { // // private static final int MAX_RECOMMENDATIONS = 3; // // @Inject // UGApiService ugApiService; // // public RecommendationService() { // super("RecommendationService"); // } // // @Override // public void onCreate() { // super.onCreate(); // TVNLApplication.get().appComponent().inject(this); // } // // @Override // protected void onHandleIntent(Intent intent) { // try { // Thread.sleep(10000); // } catch (InterruptedException e) { // e.printStackTrace(); // } // // final RecommendationBuilder builder = new RecommendationBuilder() // .setContext(getApplicationContext()) // .setSmallIcon(R.drawable.ic_recommendation); // // // ugApiService.getRecommendations() // .subscribeOn(Schedulers.newThread()) // .observeOn(Schedulers.newThread()) // .subscribe(new Action1<List<Recommendation>>() { // @Override // public void call(List<Recommendation> recommendations) { // try { // for(int i = 0; i < MAX_RECOMMENDATIONS; i++) { // Recommendation recommendation = recommendations.get(i); // builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8")) // .setId(i) // .setPriority(i) // .setTitle(recommendation.getName()) // .setDescription(recommendation.getDescription()) // .setImage(recommendation.getImage()) // .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i)) // .build(); // } // // } catch (IOException e) { // Timber.e(e, "Unable to update recommendation"); // } // } // }, new Action1<Throwable>() { // @Override // public void call(Throwable throwable) { // Timber.e(throwable, "Unable to update recommendation"); // } // }); // } // // private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) { // Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId); // return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java import android.app.Application; import android.content.Intent; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.multidex.MultiDexApplication; import eu.se_bastiaan.tvnl.service.RecommendationService; import timber.log.Timber; import uk.co.chrisjenx.calligraphy.CalligraphyConfig; package eu.se_bastiaan.tvnl; public class TVNLApplication extends MultiDexApplication { @Nullable private volatile AppInjectionComponent appInjectionComponent; private static TVNLApplication sThis; @Override public void onCreate() { super.onCreate(); sThis = this; if(BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } else { //Timber.plant(new CrashlyticsLogTree(Log.INFO)); } CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/Regular.ttf") .setFontAttrId(R.attr.fontPath) .build() );
Intent recommendationIntent = new Intent(this, RecommendationService.class);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/viewpresenter/DescriptionPresenter.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/StreamInfo.java // public class StreamInfo implements Parcelable { // // private String id; // private String videoLocation; // private String title; // private String subtitle; // private String image; // private Boolean isLive; // private Long startPosition = 0L; // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image) { // this(id, videoLocation, title, subtitle, image, false); // } // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image, Long startPosition) { // this(id, videoLocation, title, subtitle, image, false); // this.startPosition = startPosition; // } // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image, Boolean isLive) { // this.id = id; // this.videoLocation = videoLocation; // this.title = title; // this.subtitle = subtitle; // this.image = image; // this.isLive = isLive; // } // // public String getId() { // return id; // } // // public String getVideoLocation() { // return videoLocation; // } // // public String getTitle() { // return title; // } // // public String getSubtitle() { // return subtitle; // } // // public String getImage() { // return image; // } // // public Boolean isLive() { // return isLive; // } // // public Long getStartPosition() { // return startPosition; // } // // protected StreamInfo(Parcel in) { // id = in.readString(); // videoLocation = in.readString(); // title = in.readString(); // subtitle = in.readString(); // image = in.readString(); // isLive = in.readInt() == 1; // startPosition = in.readLong(); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(id); // dest.writeString(videoLocation); // dest.writeString(title); // dest.writeString(subtitle); // dest.writeString(image); // dest.writeInt(isLive ? 1 : 0); // dest.writeLong(startPosition); // } // // @SuppressWarnings("unused") // public static final Parcelable.Creator<StreamInfo> CREATOR = new Parcelable.Creator<StreamInfo>() { // @Override // public StreamInfo createFromParcel(Parcel in) { // return new StreamInfo(in); // } // // @Override // public StreamInfo[] newArray(int size) { // return new StreamInfo[size]; // } // }; // }
import android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter; import eu.se_bastiaan.tvnl.model.StreamInfo;
package eu.se_bastiaan.tvnl.ui.viewpresenter; public class DescriptionPresenter extends AbstractDetailsDescriptionPresenter { @Override protected void onBindDescription(ViewHolder viewHolder, Object item) {
// Path: app/src/main/java/eu/se_bastiaan/tvnl/model/StreamInfo.java // public class StreamInfo implements Parcelable { // // private String id; // private String videoLocation; // private String title; // private String subtitle; // private String image; // private Boolean isLive; // private Long startPosition = 0L; // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image) { // this(id, videoLocation, title, subtitle, image, false); // } // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image, Long startPosition) { // this(id, videoLocation, title, subtitle, image, false); // this.startPosition = startPosition; // } // // public StreamInfo(String id, String videoLocation, String title, String subtitle, String image, Boolean isLive) { // this.id = id; // this.videoLocation = videoLocation; // this.title = title; // this.subtitle = subtitle; // this.image = image; // this.isLive = isLive; // } // // public String getId() { // return id; // } // // public String getVideoLocation() { // return videoLocation; // } // // public String getTitle() { // return title; // } // // public String getSubtitle() { // return subtitle; // } // // public String getImage() { // return image; // } // // public Boolean isLive() { // return isLive; // } // // public Long getStartPosition() { // return startPosition; // } // // protected StreamInfo(Parcel in) { // id = in.readString(); // videoLocation = in.readString(); // title = in.readString(); // subtitle = in.readString(); // image = in.readString(); // isLive = in.readInt() == 1; // startPosition = in.readLong(); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(id); // dest.writeString(videoLocation); // dest.writeString(title); // dest.writeString(subtitle); // dest.writeString(image); // dest.writeInt(isLive ? 1 : 0); // dest.writeLong(startPosition); // } // // @SuppressWarnings("unused") // public static final Parcelable.Creator<StreamInfo> CREATOR = new Parcelable.Creator<StreamInfo>() { // @Override // public StreamInfo createFromParcel(Parcel in) { // return new StreamInfo(in); // } // // @Override // public StreamInfo[] newArray(int size) { // return new StreamInfo[size]; // } // }; // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/viewpresenter/DescriptionPresenter.java import android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter; import eu.se_bastiaan.tvnl.model.StreamInfo; package eu.se_bastiaan.tvnl.ui.viewpresenter; public class DescriptionPresenter extends AbstractDetailsDescriptionPresenter { @Override protected void onBindDescription(ViewHolder viewHolder, Object item) {
if (!(item instanceof StreamInfo)) return;
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/receiver/BootReceiver.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java // public class RecommendationService extends IntentService { // // private static final int MAX_RECOMMENDATIONS = 3; // // @Inject // UGApiService ugApiService; // // public RecommendationService() { // super("RecommendationService"); // } // // @Override // public void onCreate() { // super.onCreate(); // TVNLApplication.get().appComponent().inject(this); // } // // @Override // protected void onHandleIntent(Intent intent) { // try { // Thread.sleep(10000); // } catch (InterruptedException e) { // e.printStackTrace(); // } // // final RecommendationBuilder builder = new RecommendationBuilder() // .setContext(getApplicationContext()) // .setSmallIcon(R.drawable.ic_recommendation); // // // ugApiService.getRecommendations() // .subscribeOn(Schedulers.newThread()) // .observeOn(Schedulers.newThread()) // .subscribe(new Action1<List<Recommendation>>() { // @Override // public void call(List<Recommendation> recommendations) { // try { // for(int i = 0; i < MAX_RECOMMENDATIONS; i++) { // Recommendation recommendation = recommendations.get(i); // builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8")) // .setId(i) // .setPriority(i) // .setTitle(recommendation.getName()) // .setDescription(recommendation.getDescription()) // .setImage(recommendation.getImage()) // .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i)) // .build(); // } // // } catch (IOException e) { // Timber.e(e, "Unable to update recommendation"); // } // } // }, new Action1<Throwable>() { // @Override // public void call(Throwable throwable) { // Timber.e(throwable, "Unable to update recommendation"); // } // }); // } // // private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) { // Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId); // return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT); // } // // }
import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import eu.se_bastiaan.tvnl.service.RecommendationService;
package eu.se_bastiaan.tvnl.receiver; public class BootReceiver extends BroadcastReceiver { private static final long INITIAL_DELAY = 5000; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().endsWith(Intent.ACTION_BOOT_COMPLETED)) { scheduleRecommendationUpdate(context); } } private void scheduleRecommendationUpdate(Context context) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Path: app/src/main/java/eu/se_bastiaan/tvnl/service/RecommendationService.java // public class RecommendationService extends IntentService { // // private static final int MAX_RECOMMENDATIONS = 3; // // @Inject // UGApiService ugApiService; // // public RecommendationService() { // super("RecommendationService"); // } // // @Override // public void onCreate() { // super.onCreate(); // TVNLApplication.get().appComponent().inject(this); // } // // @Override // protected void onHandleIntent(Intent intent) { // try { // Thread.sleep(10000); // } catch (InterruptedException e) { // e.printStackTrace(); // } // // final RecommendationBuilder builder = new RecommendationBuilder() // .setContext(getApplicationContext()) // .setSmallIcon(R.drawable.ic_recommendation); // // // ugApiService.getRecommendations() // .subscribeOn(Schedulers.newThread()) // .observeOn(Schedulers.newThread()) // .subscribe(new Action1<List<Recommendation>>() { // @Override // public void call(List<Recommendation> recommendations) { // try { // for(int i = 0; i < MAX_RECOMMENDATIONS; i++) { // Recommendation recommendation = recommendations.get(i); // builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(recommendation.getImage(), "UTF-8")) // .setId(i) // .setPriority(i) // .setTitle(recommendation.getName()) // .setDescription(recommendation.getDescription()) // .setImage(recommendation.getImage()) // .setIntent(buildPendingIntent(recommendation.toOverviewGridItem(), i)) // .build(); // } // // } catch (IOException e) { // Timber.e(e, "Unable to update recommendation"); // } // } // }, new Action1<Throwable>() { // @Override // public void call(Throwable throwable) { // Timber.e(throwable, "Unable to update recommendation"); // } // }); // } // // private PendingIntent buildPendingIntent(OverviewGridItem media, int notifId) { // Intent detailIntent = DetailsActivity.buildIntent(this, media, notifId); // return PendingIntent.getActivity(this, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT); // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/receiver/BootReceiver.java import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import eu.se_bastiaan.tvnl.service.RecommendationService; package eu.se_bastiaan.tvnl.receiver; public class BootReceiver extends BroadcastReceiver { private static final long INITIAL_DELAY = 5000; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().endsWith(Intent.ACTION_BOOT_COMPLETED)) { scheduleRecommendationUpdate(context); } } private void scheduleRecommendationUpdate(Context context) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent recommendationIntent = new Intent(context, RecommendationService.class);
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/AppModule.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/EventBus.java // public class EventBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // public EventBus() { // } // // public void postOnMain(final Object event) { // if(Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // this.mainThread.post(new Runnable() { // public void run() { // EventBus.this.post(event); // } // }); // } // // } // }
import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import eu.se_bastiaan.tvnl.content.EventBus;
package eu.se_bastiaan.tvnl; @Module public class AppModule { @NonNull private final Application app; AppModule(@NonNull Application app) { this.app = app; } @Provides @NonNull @Singleton Context provideContext() { return app; } @Provides @Singleton
// Path: app/src/main/java/eu/se_bastiaan/tvnl/content/EventBus.java // public class EventBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // public EventBus() { // } // // public void postOnMain(final Object event) { // if(Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // this.mainThread.post(new Runnable() { // public void run() { // EventBus.this.post(event); // } // }); // } // // } // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/AppModule.java import android.app.Application; import android.content.Context; import android.content.res.Resources; import android.support.annotation.NonNull; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import eu.se_bastiaan.tvnl.content.EventBus; package eu.se_bastiaan.tvnl; @Module public class AppModule { @NonNull private final Application app; AppModule(@NonNull Application app) { this.app = app; } @Provides @NonNull @Singleton Context provideContext() { return app; } @Provides @Singleton
EventBus provideBus() {
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/presenter/base/BasePresenter.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.os.Bundle; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.TVNLApplication; import nucleus.presenter.RxPresenter; import nucleus.view.ViewWithPresenter; import rx.Observable; import rx.functions.Func1;
package eu.se_bastiaan.tvnl.ui.presenter.base; public abstract class BasePresenter<V extends ViewWithPresenter> extends RxPresenter<V> { @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState);
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/presenter/base/BasePresenter.java import android.os.Bundle; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.TVNLApplication; import nucleus.presenter.RxPresenter; import nucleus.view.ViewWithPresenter; import rx.Observable; import rx.functions.Func1; package eu.se_bastiaan.tvnl.ui.presenter.base; public abstract class BasePresenter<V extends ViewWithPresenter> extends RxPresenter<V> { @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState);
injectComponent(TVNLApplication.get().appComponent());
se-bastiaan/TVNL-AndroidTV
app/src/main/java/eu/se_bastiaan/tvnl/ui/presenter/base/BasePresenter.java
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // }
import android.os.Bundle; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.TVNLApplication; import nucleus.presenter.RxPresenter; import nucleus.view.ViewWithPresenter; import rx.Observable; import rx.functions.Func1;
package eu.se_bastiaan.tvnl.ui.presenter.base; public abstract class BasePresenter<V extends ViewWithPresenter> extends RxPresenter<V> { @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); injectComponent(TVNLApplication.get().appComponent()); } protected Observable<V> viewFiltered() { return view().filter(new Func1<V, Boolean>() { @Override public Boolean call(V v) { return v != null; } }); }
// Path: app/src/main/java/eu/se_bastiaan/tvnl/AppInjectionComponent.java // @Singleton // @Component( // modules = { // AppModule.class, // NetworkModule.class // } // ) // public interface AppInjectionComponent { // // void inject(@NonNull MainActivity activity); // void inject(@NonNull DetailsActivity activity); // void inject(@NonNull SearchActivity activity); // void inject(@NonNull VideoPlayerActivity activity); // // void inject(@NonNull BrowseFragPresenter presenter); // void inject(@NonNull VideoPlayerFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragPresenter presenter); // void inject(@NonNull PlaybackOverlayFragment presenter); // void inject(@NonNull SearchFragPresenter presenter); // void inject(@NonNull DetailsFragPresenter presenter); // // void inject(@NonNull OkHttpGlideModule module); // // void inject(@NonNull RecommendationContentProvider contentProvider); // void inject(@NonNull RecommendationService service); // // final class Initializer { // private Initializer() { // /* No instances. */ // } // // public static AppInjectionComponent init(TVNLApplication application) { // return DaggerAppInjectionComponent // .builder() // .appModule(new AppModule(application)) // .networkModule(new NetworkModule()) // .build(); // } // } // // } // // Path: app/src/main/java/eu/se_bastiaan/tvnl/TVNLApplication.java // public class TVNLApplication extends MultiDexApplication { // // @Nullable // private volatile AppInjectionComponent appInjectionComponent; // private static TVNLApplication sThis; // // @Override // public void onCreate() { // super.onCreate(); // sThis = this; // // if(BuildConfig.DEBUG) { // Timber.plant(new Timber.DebugTree()); // } else { // //Timber.plant(new CrashlyticsLogTree(Log.INFO)); // } // // CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Regular.ttf") // .setFontAttrId(R.attr.fontPath) // .build() // ); // // Intent recommendationIntent = new Intent(this, RecommendationService.class); // startService(recommendationIntent); // } // // public static TVNLApplication get() { // return sThis; // } // // @NonNull // public AppInjectionComponent appComponent() { // if (appInjectionComponent == null) { // synchronized (Application.class) { // if (appInjectionComponent == null) { // appInjectionComponent = AppInjectionComponent.Initializer.init(this); // } // } // } // // //noinspection ConstantConditions // return appInjectionComponent; // } // // } // Path: app/src/main/java/eu/se_bastiaan/tvnl/ui/presenter/base/BasePresenter.java import android.os.Bundle; import eu.se_bastiaan.tvnl.AppInjectionComponent; import eu.se_bastiaan.tvnl.TVNLApplication; import nucleus.presenter.RxPresenter; import nucleus.view.ViewWithPresenter; import rx.Observable; import rx.functions.Func1; package eu.se_bastiaan.tvnl.ui.presenter.base; public abstract class BasePresenter<V extends ViewWithPresenter> extends RxPresenter<V> { @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); injectComponent(TVNLApplication.get().appComponent()); } protected Observable<V> viewFiltered() { return view().filter(new Func1<V, Boolean>() { @Override public Boolean call(V v) { return v != null; } }); }
protected abstract void injectComponent(AppInjectionComponent component);
ohmdb/ohmdb
ohmdb-utils/src/main/java/com/ohmdb/numbers/Nums.java
// Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // }
import com.ohmdb.util.Errors; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.SortedSet; import com.ohmdb.abstracts.Numbers; import com.ohmdb.util.Check;
} else if (array instanceof long[]) { return from((long[]) array); } else if (array instanceof Object[]) { return from((Object[]) array); } else if (array == null) { return none(); } else { throw Errors.rte("Wrong array type: " + array); } } public static int rnd(int n) { return (int) (Math.random() * n); } public static int rnd(int min, int max) { return min + rnd(max - min + 1); } private static boolean contains(int[] nums, int count, int val) { for (int i = 0; i < count; i++) { if (nums[i] == val) { return true; } } return false; } public static Numbers random(int minCount, int maxCount, int minVal, int maxVal) { int possible = maxVal - minVal + 1;
// Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // } // Path: ohmdb-utils/src/main/java/com/ohmdb/numbers/Nums.java import com.ohmdb.util.Errors; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.SortedSet; import com.ohmdb.abstracts.Numbers; import com.ohmdb.util.Check; } else if (array instanceof long[]) { return from((long[]) array); } else if (array instanceof Object[]) { return from((Object[]) array); } else if (array == null) { return none(); } else { throw Errors.rte("Wrong array type: " + array); } } public static int rnd(int n) { return (int) (Math.random() * n); } public static int rnd(int min, int max) { return min + rnd(max - min + 1); } private static boolean contains(int[] nums, int count, int val) { for (int i = 0; i < count; i++) { if (nums[i] == val) { return true; } } return false; } public static Numbers random(int minCount, int maxCount, int minVal, int maxVal) { int possible = maxVal - minVal + 1;
Check.state(maxCount <= possible);
ohmdb/ohmdb
ohmdb-core/src/main/java/com/ohmdb/TableInternals.java
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // }
import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo;
package com.ohmdb; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public interface TableInternals<E> { void fill(long id, String columnName, Object value); ReentrantReadWriteLock getLock(); void commit(); void rollback(); Class<E> getClazz();
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; package com.ohmdb; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public interface TableInternals<E> { void fill(long id, String columnName, Object value); ReentrantReadWriteLock getLock(); void commit(); void rollback(); Class<E> getClazz();
void setInsider(DbInsider insider);
ohmdb/ohmdb
ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // }
import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper;
} @Override public void fill(long id, String columnName, Object value) { } @Override public ReentrantReadWriteLock getLock() { return null; } @Override public void commit() { } @Override public void rollback() { } @Override public Class getClazz() { return null; } @Override
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // } // Path: ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper; } @Override public void fill(long id, String columnName, Object value) { } @Override public ReentrantReadWriteLock getLock() { return null; } @Override public void commit() { } @Override public void rollback() { } @Override public Class getClazz() { return null; } @Override
public void setInsider(DbInsider insider) {
ohmdb/ohmdb
ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // }
import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper;
@Override public Object read(long id, String columnName) { return null; } @Override public void print() { } @Override public int size() { return 0; } @Override public Object queryHelper() { return null; } @Override public String nameOf(Object column) { return null; } @Override
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // } // Path: ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper; @Override public Object read(long id, String columnName) { return null; } @Override public void print() { } @Override public int size() { return 0; } @Override public Object queryHelper() { return null; } @Override public String nameOf(Object column) { return null; } @Override
public long[] find(SearchCriteria criteria) {
ohmdb/ohmdb
ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // }
import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper;
@Override public long[] find(SearchCriteria criteria) { return null; } @Override public Ids all() { return null; } @Override public Ids withIds(long... ids) { return null; } @Override public Object[] getAll(long... ids) { return null; } @Override public void createIndexOn(Object column) { } @Override
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // } // Path: ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper; @Override public long[] find(SearchCriteria criteria) { return null; } @Override public Ids all() { return null; } @Override public Ids withIds(long... ids) { return null; } @Override public Object[] getAll(long... ids) { return null; } @Override public void createIndexOn(Object column) { } @Override
public void createIndexOn(Object column, Transformer transformer) {
ohmdb/ohmdb
ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // }
import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper;
return null; } @Override public Object[] getAll(long... ids) { return null; } @Override public void createIndexOn(Object column) { } @Override public void createIndexOn(Object column, Transformer transformer) { } @Override public void createIndexOnNamed(String columnName) { } @Override public void createIndexOnNamed(String columnName, Transformer transformer) { } @Override
// Path: ohmdb-core/src/main/java/com/ohmdb/TableInternals.java // public interface TableInternals<E> { // // void fill(long id, String columnName, Object value); // // ReentrantReadWriteLock getLock(); // // void commit(); // // void rollback(); // // Class<E> getClazz(); // // void setInsider(DbInsider insider); // // JokerCreator jokerator(); // // void updateObj(Object entity); // // void addTrigger(TriggerAction action, Trigger<E> trigger); // // void forEach(Visitor<E> visitor); // // void forEach(long[] ids, Visitor<E> visitor); // // PropertyInfo[] props(); // // } // // Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/SearchCriteria.java // public interface SearchCriteria { // // SearchCriteria[] criteria(); // // SearchCriterion criterion(); // // SearchCriteriaKind kind(); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Transformer.java // public interface Transformer<T> { // // T transform(T value); // // } // Path: ohmdb-test/src/main/java/com/ohmdb/test/MockTable.java import com.ohmdb.api.SearchCriteria; import com.ohmdb.api.Table; import com.ohmdb.api.Transformer; import com.ohmdb.api.Trigger; import com.ohmdb.api.TriggerAction; import com.ohmdb.api.Visitor; import com.ohmdb.bean.PropertyInfo; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.ohmdb.TableInternals; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.JokerCreator; import com.ohmdb.api.Criteria; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Ids; import com.ohmdb.api.Mapper; return null; } @Override public Object[] getAll(long... ids) { return null; } @Override public void createIndexOn(Object column) { } @Override public void createIndexOn(Object column, Transformer transformer) { } @Override public void createIndexOnNamed(String columnName) { } @Override public void createIndexOnNamed(String columnName, Transformer transformer) { } @Override
public CustomIndex index(Mapper mapper, Object... columns) {
ohmdb/ohmdb
ohmdb-core/src/main/java/com/ohmdb/links/LinksBuilder.java
// Path: ohmdb-api/src/main/java/com/ohmdb/api/Links.java // public interface Links { // // int size(); // // long from(int index); // // long[] to(int index); // // Links inverse(); // // }
import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; import com.ohmdb.api.Links; import com.ohmdb.util.UTILS;
package com.ohmdb.links; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class LinksBuilder { private SortedMap<Long, SortedSet<Long>> links = new TreeMap<Long, SortedSet<Long>>(); private SortedSet<Long> linkedTos = new TreeSet<Long>(); public void link(long from, long to) { SortedSet<Long> ll = links.get(from); if (ll == null) { ll = new TreeSet<Long>(); links.put(from, ll); } if (to != -1) { ll.add(to); if (from != -1) { linkedTos.add(to); } } }
// Path: ohmdb-api/src/main/java/com/ohmdb/api/Links.java // public interface Links { // // int size(); // // long from(int index); // // long[] to(int index); // // Links inverse(); // // } // Path: ohmdb-core/src/main/java/com/ohmdb/links/LinksBuilder.java import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; import com.ohmdb.api.Links; import com.ohmdb.util.UTILS; package com.ohmdb.links; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class LinksBuilder { private SortedMap<Long, SortedSet<Long>> links = new TreeMap<Long, SortedSet<Long>>(); private SortedSet<Long> linkedTos = new TreeSet<Long>(); public void link(long from, long to) { SortedSet<Long> ll = links.get(from); if (ll == null) { ll = new TreeSet<Long>(); links.put(from, ll); } if (to != -1) { ll.add(to); if (from != -1) { linkedTos.add(to); } } }
public Links build() {
ohmdb/ohmdb
ohmdb-test/src/test/java/com/ohmdb/test/RelationShadow.java
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // }
import com.ohmdb.abstracts.RelationInternals; import com.ohmdb.util.ProxyUtil; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.RWRelation;
package com.ohmdb.test; /* * #%L * ohmdb-test * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class RelationShadow extends TestCommons { private final String relationName; private final TestInsider insider; private RWRelation relation; private RelationInternals internals; public RelationShadow(String relationName, TestInsider insider) { this.relationName = relationName; this.insider = insider; } public void setRelation(RWRelation relation) { this.relation = relation; this.internals = (RelationInternals) relation;
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/DbInsider.java // public interface DbInsider { // // void invalidId(Class<?> table, long id); // // void invalidColumn(Class<?> table, String column); // // void inserting(Class<?> table, long id, Object entity); // // void inserted(Class<?> table, long id, Object entity); // // void insertingCell(Class<?> table, long id, String column, Object value); // // void uninserting(Class<?> table, long id); // // void uninsertingCell(Class<?> table, long id, String column, Object value); // // void changing(Class<?> table, long id, String col, Object value); // // void changed(Class<?> table, long id, String col, Object value); // // void unchanging(Class<?> table, long id, String column, Object oldValue, Object value); // // void deleting(Class<?> table, long id); // // void deletingCell(Class<?> table, long id, String column); // // void deleted(Class<?> table, long id); // // void undeleting(Class<?> table, long id); // // void undeletingCell(Class<?> table, long id, String column); // // void linking(String relation, long from, long to); // // void linked(String relation, long from, long to); // // void delinking(String relation, long from, long to); // // void delinked(String relation, long from, long to); // // void deletingLinksFrom(String relation, long id); // // void deletedLinksFrom(String relation, long id); // // void deletingLinksTo(String relation, long id); // // void deletedLinksTo(String relation, long id); // // void getting(Class<?> table, long id); // // void got(Class<?> table, long id, Object entity); // // void reading(Class<?> table, long id, String column); // // void read(Class<?> table, long id, String column, Object value); // // void unlinking(long fromId, Numbers toIds); // // void undelinking(long fromId, Numbers toIds); // // void undelinking(Numbers fromIds, long toId); // // } // Path: ohmdb-test/src/test/java/com/ohmdb/test/RelationShadow.java import com.ohmdb.abstracts.RelationInternals; import com.ohmdb.util.ProxyUtil; import com.ohmdb.abstracts.DbInsider; import com.ohmdb.abstracts.RWRelation; package com.ohmdb.test; /* * #%L * ohmdb-test * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class RelationShadow extends TestCommons { private final String relationName; private final TestInsider insider; private RWRelation relation; private RelationInternals internals; public RelationShadow(String relationName, TestInsider insider) { this.relationName = relationName; this.insider = insider; } public void setRelation(RWRelation relation) { this.relation = relation; this.internals = (RelationInternals) relation;
this.internals.setInsider(ProxyUtil.tracer(DbInsider.class, insider));
ohmdb/ohmdb
ohmdb-dsl/src/main/java/com/ohmdb/dsl/rel/SearchCriterionImpl.java
// Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Op.java // public enum Op { // // GT(">"), GTE(">="), LT("<"), LTE("<="), EQ("="), NEQ("!="), MATCH("MATCH"); // // private final String sign; // // Op(String sign) { // this.sign = sign; // } // // public String sign() { // return sign; // } // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // }
import com.ohmdb.api.SearchCriterion; import com.ohmdb.util.Check; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Op;
package com.ohmdb.dsl.rel; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class SearchCriterionImpl implements SearchCriterion { private final Op op; private final Object value; private final String columnName;
// Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Op.java // public enum Op { // // GT(">"), GTE(">="), LT("<"), LTE("<="), EQ("="), NEQ("!="), MATCH("MATCH"); // // private final String sign; // // Op(String sign) { // this.sign = sign; // } // // public String sign() { // return sign; // } // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // } // Path: ohmdb-dsl/src/main/java/com/ohmdb/dsl/rel/SearchCriterionImpl.java import com.ohmdb.api.SearchCriterion; import com.ohmdb.util.Check; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Op; package com.ohmdb.dsl.rel; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class SearchCriterionImpl implements SearchCriterion { private final Op op; private final Object value; private final String columnName;
private final CustomIndex<?, ?> indexer;
ohmdb/ohmdb
ohmdb-dsl/src/main/java/com/ohmdb/dsl/rel/SearchCriterionImpl.java
// Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Op.java // public enum Op { // // GT(">"), GTE(">="), LT("<"), LTE("<="), EQ("="), NEQ("!="), MATCH("MATCH"); // // private final String sign; // // Op(String sign) { // this.sign = sign; // } // // public String sign() { // return sign; // } // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // }
import com.ohmdb.api.SearchCriterion; import com.ohmdb.util.Check; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Op;
package com.ohmdb.dsl.rel; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class SearchCriterionImpl implements SearchCriterion { private final Op op; private final Object value; private final String columnName; private final CustomIndex<?, ?> indexer; public SearchCriterionImpl(String columnName, Op op, Object value) {
// Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/Op.java // public enum Op { // // GT(">"), GTE(">="), LT("<"), LTE("<="), EQ("="), NEQ("!="), MATCH("MATCH"); // // private final String sign; // // Op(String sign) { // this.sign = sign; // } // // public String sign() { // return sign; // } // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // } // Path: ohmdb-dsl/src/main/java/com/ohmdb/dsl/rel/SearchCriterionImpl.java import com.ohmdb.api.SearchCriterion; import com.ohmdb.util.Check; import com.ohmdb.api.CustomIndex; import com.ohmdb.api.Op; package com.ohmdb.dsl.rel; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class SearchCriterionImpl implements SearchCriterion { private final Op op; private final Object value; private final String columnName; private final CustomIndex<?, ?> indexer; public SearchCriterionImpl(String columnName, Op op, Object value) {
Check.notNull(columnName, "column name");
ohmdb/ohmdb
ohmdb-core/src/main/java/com/ohmdb/impl/IndexerImpl.java
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/ComplexIndex.java // public interface ComplexIndex<E> { // // void add(E value, long id); // // void remove(E oldValue, long id); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // }
import com.ohmdb.api.CustomIndex; import com.ohmdb.abstracts.ComplexIndex; import com.ohmdb.abstracts.Index;
package com.ohmdb.impl; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class IndexerImpl<E, T> implements CustomIndex<E, T> { @SuppressWarnings("unused")
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/ComplexIndex.java // public interface ComplexIndex<E> { // // void add(E value, long id); // // void remove(E oldValue, long id); // // } // // Path: ohmdb-api/src/main/java/com/ohmdb/api/CustomIndex.java // public interface CustomIndex<E, T> { // // } // Path: ohmdb-core/src/main/java/com/ohmdb/impl/IndexerImpl.java import com.ohmdb.api.CustomIndex; import com.ohmdb.abstracts.ComplexIndex; import com.ohmdb.abstracts.Index; package com.ohmdb.impl; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class IndexerImpl<E, T> implements CustomIndex<E, T> { @SuppressWarnings("unused")
private final ComplexIndex<E> complexIndex;
ohmdb/ohmdb
ohmdb-core/src/main/java/com/ohmdb/filestore/ZonesImpl.java
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/Zones.java // public interface Zones { // // public abstract Set<Long> occupy(int num); // // public abstract void occupied(long position); // // public abstract void release(long position); // // public abstract void releaseAll(long... positions); // // public abstract void releaseAll(Set<Long> positions); // // public abstract void occupiedAll(Set<Long> positions); // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // }
import java.util.BitSet; import java.util.Set; import java.util.TreeSet; import com.ohmdb.abstracts.Zones; import com.ohmdb.util.Check; import com.ohmdb.util.Errors;
package com.ohmdb.filestore; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class ZonesImpl implements Zones { // covers a 16 KB block private final BitSet bs = new BitSet(16 * 1024 / FileStore.BLOCK_SIZE); private int cardinality; @Override public synchronized Set<Long> occupy(int num) {
// Path: ohmdb-internal-api/src/main/java/com/ohmdb/abstracts/Zones.java // public interface Zones { // // public abstract Set<Long> occupy(int num); // // public abstract void occupied(long position); // // public abstract void release(long position); // // public abstract void releaseAll(long... positions); // // public abstract void releaseAll(Set<Long> positions); // // public abstract void occupiedAll(Set<Long> positions); // // } // // Path: ohmdb-utils/src/main/java/com/ohmdb/util/Check.java // public class Check { // // public static void state(boolean expectedCondition) { // if (!expectedCondition) { // throw new IllegalStateException(); // } // } // // public static void state(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalStateException(String.format(message, args)); // } // } // // public static void notNulls(Object[] objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNulls2(Object... objs) { // for (Object value : objs) { // if (value == null) { // throw new IllegalStateException(String.format("The argument must NOT be null!")); // } // } // } // // public static void notNull(Object value, String desc) { // if (value == null) { // throw new IllegalStateException(String.format("The %s must NOT be null!", desc)); // } // } // // public static void arg(boolean expectedCondition, String message, Object... args) { // if (!expectedCondition) { // throw new IllegalArgumentException(String.format(message, args)); // } // } // // } // Path: ohmdb-core/src/main/java/com/ohmdb/filestore/ZonesImpl.java import java.util.BitSet; import java.util.Set; import java.util.TreeSet; import com.ohmdb.abstracts.Zones; import com.ohmdb.util.Check; import com.ohmdb.util.Errors; package com.ohmdb.filestore; /* * #%L * ohmdb-core * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class ZonesImpl implements Zones { // covers a 16 KB block private final BitSet bs = new BitSet(16 * 1024 / FileStore.BLOCK_SIZE); private int cardinality; @Override public synchronized Set<Long> occupy(int num) {
Check.arg(num > 0, "Ocupation size must be greater than 0!");
ohmdb/ohmdb
ohmdb-dsl/src/main/java/com/ohmdb/dsl/impl/ParamImpl.java
// Path: ohmdb-api/src/main/java/com/ohmdb/api/ParameterBinding.java // public interface ParameterBinding<T> { // // T value(); // // Parameter<T> param(); // // }
import com.ohmdb.api.Parameter; import com.ohmdb.api.ParameterBinding;
package com.ohmdb.dsl.impl; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class ParamImpl<T> implements Parameter<T> { private final String name; private final Class<T> type; public ParamImpl(String name, Class<T> type) { this.name = name; this.type = type; } @Override public String name() { return name; } @Override
// Path: ohmdb-api/src/main/java/com/ohmdb/api/ParameterBinding.java // public interface ParameterBinding<T> { // // T value(); // // Parameter<T> param(); // // } // Path: ohmdb-dsl/src/main/java/com/ohmdb/dsl/impl/ParamImpl.java import com.ohmdb.api.Parameter; import com.ohmdb.api.ParameterBinding; package com.ohmdb.dsl.impl; /* * #%L * ohmdb-dsl * %% * Copyright (C) 2013 - 2014 Nikolche Mihajlovski * %% * 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. * #L% */ public class ParamImpl<T> implements Parameter<T> { private final String name; private final Class<T> type; public ParamImpl(String name, Class<T> type) { this.name = name; this.type = type; } @Override public String name() { return name; } @Override
public ParameterBinding<T> as(T value) {
marcingrzejszczak/mockito-cookbook
chapter03/src/test/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/hamcrest/TaxFactorProcessorTestNgTest.java
// Path: chapter03/src/main/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/TaxService.java // public interface TaxService { // // double calculateTaxFactorFor(Person person); // // void updateTaxData(double taxFactor, Person person); // // }
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.*; import static org.mockito.AdditionalAnswers.*; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Mockito.*; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.FinalTaxService; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxFactorProcessor; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxService; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person;
package com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.hamcrest; @Listeners(MockitoTestNGListener.class) public class TaxFactorProcessorTestNgTest { FinalTaxService finalTaxService = new FinalTaxService();
// Path: chapter03/src/main/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/TaxService.java // public interface TaxService { // // double calculateTaxFactorFor(Person person); // // void updateTaxData(double taxFactor, Person person); // // } // Path: chapter03/src/test/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/hamcrest/TaxFactorProcessorTestNgTest.java import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.*; import static org.mockito.AdditionalAnswers.*; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Mockito.*; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.FinalTaxService; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxFactorProcessor; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxService; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; package com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.hamcrest; @Listeners(MockitoTestNGListener.class) public class TaxFactorProcessorTestNgTest { FinalTaxService finalTaxService = new FinalTaxService();
TaxService taxService = mock(TaxService.class, delegatesTo(finalTaxService));
marcingrzejszczak/mockito-cookbook
chapter04/src/test/java/com/blogspot/toomuchcoding/book/chapter4/_2_StubbingMethodThatReturnValues/varargs/hamcrest/MeanTaxFactorCalculatorTestNgTest.java
// Path: chapter04/src/main/java/com/blogspot/toomuchcoding/book/chapter4/common/returningvalue/MeanTaxFactorCalculator.java // public class MeanTaxFactorCalculator { // // private final TaxFactorFetcher taxFactorFetcher; // // public MeanTaxFactorCalculator(TaxFactorFetcher taxFactorFetcher) { // this.taxFactorFetcher = taxFactorFetcher; // } // // public double calculateMeanTaxFactorFor(Person person) { // double taxFactor = taxFactorFetcher.getTaxFactorFor(person); // double anotherTaxFactor = taxFactorFetcher.getTaxFactorFor(person); // return (taxFactor + anotherTaxFactor) / 2; // } // // }
import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.MeanTaxFactorCalculator; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.TaxFactorFetcher; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.mockito.InjectMocks; import org.mockito.Mock; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any;
package com.blogspot.toomuchcoding.book.chapter4._2_StubbingMethodThatReturnValues.varargs.hamcrest; @Listeners(MockitoTestNGListener.class) public class MeanTaxFactorCalculatorTestNgTest { @Mock TaxFactorFetcher taxFactorFetcher;
// Path: chapter04/src/main/java/com/blogspot/toomuchcoding/book/chapter4/common/returningvalue/MeanTaxFactorCalculator.java // public class MeanTaxFactorCalculator { // // private final TaxFactorFetcher taxFactorFetcher; // // public MeanTaxFactorCalculator(TaxFactorFetcher taxFactorFetcher) { // this.taxFactorFetcher = taxFactorFetcher; // } // // public double calculateMeanTaxFactorFor(Person person) { // double taxFactor = taxFactorFetcher.getTaxFactorFor(person); // double anotherTaxFactor = taxFactorFetcher.getTaxFactorFor(person); // return (taxFactor + anotherTaxFactor) / 2; // } // // } // Path: chapter04/src/test/java/com/blogspot/toomuchcoding/book/chapter4/_2_StubbingMethodThatReturnValues/varargs/hamcrest/MeanTaxFactorCalculatorTestNgTest.java import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.MeanTaxFactorCalculator; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.TaxFactorFetcher; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.mockito.InjectMocks; import org.mockito.Mock; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any; package com.blogspot.toomuchcoding.book.chapter4._2_StubbingMethodThatReturnValues.varargs.hamcrest; @Listeners(MockitoTestNGListener.class) public class MeanTaxFactorCalculatorTestNgTest { @Mock TaxFactorFetcher taxFactorFetcher;
@InjectMocks MeanTaxFactorCalculator systemUnderTest;
marcingrzejszczak/mockito-cookbook
chapter03/src/test/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/assertj/TaxFactorProcessorTestNgTest.java
// Path: chapter03/src/main/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/TaxService.java // public interface TaxService { // // double calculateTaxFactorFor(Person person); // // void updateTaxData(double taxFactor, Person person); // // }
import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.FinalTaxService; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxFactorProcessor; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxService; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.AdditionalAnswers.delegatesTo; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock;
package com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.assertj; @Listeners(MockitoTestNGListener.class) public class TaxFactorProcessorTestNgTest { FinalTaxService finalTaxService = new FinalTaxService();
// Path: chapter03/src/main/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/TaxService.java // public interface TaxService { // // double calculateTaxFactorFor(Person person); // // void updateTaxData(double taxFactor, Person person); // // } // Path: chapter03/src/test/java/com/blogspot/toomuchcoding/book/chapter3/_5_DelegateTo/assertj/TaxFactorProcessorTestNgTest.java import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.FinalTaxService; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxFactorProcessor; import com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.TaxService; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.AdditionalAnswers.delegatesTo; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; package com.blogspot.toomuchcoding.book.chapter3._5_DelegateTo.assertj; @Listeners(MockitoTestNGListener.class) public class TaxFactorProcessorTestNgTest { FinalTaxService finalTaxService = new FinalTaxService();
TaxService taxService = mock(TaxService.class, delegatesTo(finalTaxService));
marcingrzejszczak/mockito-cookbook
chapter09/src/test/java/com/blogspot/toomuchcoding/book/chapter9/InjectingWithSpring/TaxTransfererCodeConfigurationReusedMockTestNgTest.java
// Path: chapter09/src/main/java/com/blogspot/toomuchcoding/book/chapter9/exception/CustomException.java // public class CustomException extends RuntimeException { // // }
import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.*; import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.when; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.BDDMockito.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.Test; import com.blogspot.toomuchcoding.book.chapter9.exception.CustomException; import com.blogspot.toomuchcoding.person.Person;
package com.blogspot.toomuchcoding.book.chapter9.InjectingWithSpring; /** * Added prefixes to test method names to ensure method execution order */ @ContextConfiguration(classes = {TaxConfiguration.class, ReusedMockTaxConfiguration.class}) public class TaxTransfererCodeConfigurationReusedMockTestNgTest extends AbstractTestNGSpringContextTests { @Autowired TaxTransferer taxTransferer; @Autowired TaxService taxService; @Test(priority = 1) public void _1_should_fail_to_transfer_tax_for_person() { // given Person person = new Person();
// Path: chapter09/src/main/java/com/blogspot/toomuchcoding/book/chapter9/exception/CustomException.java // public class CustomException extends RuntimeException { // // } // Path: chapter09/src/test/java/com/blogspot/toomuchcoding/book/chapter9/InjectingWithSpring/TaxTransfererCodeConfigurationReusedMockTestNgTest.java import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.*; import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.when; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.BDDMockito.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.testng.annotations.Test; import com.blogspot.toomuchcoding.book.chapter9.exception.CustomException; import com.blogspot.toomuchcoding.person.Person; package com.blogspot.toomuchcoding.book.chapter9.InjectingWithSpring; /** * Added prefixes to test method names to ensure method execution order */ @ContextConfiguration(classes = {TaxConfiguration.class, ReusedMockTaxConfiguration.class}) public class TaxTransfererCodeConfigurationReusedMockTestNgTest extends AbstractTestNGSpringContextTests { @Autowired TaxTransferer taxTransferer; @Autowired TaxService taxService; @Test(priority = 1) public void _1_should_fail_to_transfer_tax_for_person() { // given Person person = new Person();
willThrow(CustomException.class).given(taxService).transferTaxFor(any(Person.class));
marcingrzejszczak/mockito-cookbook
chapter04/src/test/java/com/blogspot/toomuchcoding/book/chapter4/_3_StubbingMethodThatThrowsException/subsequent/hamcrest/MeanTaxFactorCalculatorTestNgTest.java
// Path: chapter04/src/main/java/com/blogspot/toomuchcoding/book/chapter4/common/returningvalue/MeanTaxFactorCalculator.java // public class MeanTaxFactorCalculator { // // private final TaxFactorFetcher taxFactorFetcher; // // public MeanTaxFactorCalculator(TaxFactorFetcher taxFactorFetcher) { // this.taxFactorFetcher = taxFactorFetcher; // } // // public double calculateMeanTaxFactorFor(Person person) { // double taxFactor = taxFactorFetcher.getTaxFactorFor(person); // double anotherTaxFactor = taxFactorFetcher.getTaxFactorFor(person); // return (taxFactor + anotherTaxFactor) / 2; // } // // }
import com.blogspot.toomuchcoding.book.chapter4.common.exception.InvalidTaxFactorException; import com.blogspot.toomuchcoding.book.chapter4.common.exception.TaxServiceUnavailableException; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.MeanTaxFactorCalculator; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.TaxFactorFetcher; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.mockito.InjectMocks; import org.mockito.Mock; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static com.googlecode.catchexception.CatchException.caughtException; import static com.googlecode.catchexception.apis.CatchExceptionBdd.when; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any;
package com.blogspot.toomuchcoding.book.chapter4._3_StubbingMethodThatThrowsException.subsequent.hamcrest; @Listeners(MockitoTestNGListener.class) public class MeanTaxFactorCalculatorTestNgTest { @Mock TaxFactorFetcher taxFactorFetcher;
// Path: chapter04/src/main/java/com/blogspot/toomuchcoding/book/chapter4/common/returningvalue/MeanTaxFactorCalculator.java // public class MeanTaxFactorCalculator { // // private final TaxFactorFetcher taxFactorFetcher; // // public MeanTaxFactorCalculator(TaxFactorFetcher taxFactorFetcher) { // this.taxFactorFetcher = taxFactorFetcher; // } // // public double calculateMeanTaxFactorFor(Person person) { // double taxFactor = taxFactorFetcher.getTaxFactorFor(person); // double anotherTaxFactor = taxFactorFetcher.getTaxFactorFor(person); // return (taxFactor + anotherTaxFactor) / 2; // } // // } // Path: chapter04/src/test/java/com/blogspot/toomuchcoding/book/chapter4/_3_StubbingMethodThatThrowsException/subsequent/hamcrest/MeanTaxFactorCalculatorTestNgTest.java import com.blogspot.toomuchcoding.book.chapter4.common.exception.InvalidTaxFactorException; import com.blogspot.toomuchcoding.book.chapter4.common.exception.TaxServiceUnavailableException; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.MeanTaxFactorCalculator; import com.blogspot.toomuchcoding.book.chapter4.common.returningvalue.TaxFactorFetcher; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.mockito.InjectMocks; import org.mockito.Mock; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static com.googlecode.catchexception.CatchException.caughtException; import static com.googlecode.catchexception.apis.CatchExceptionBdd.when; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.any; package com.blogspot.toomuchcoding.book.chapter4._3_StubbingMethodThatThrowsException.subsequent.hamcrest; @Listeners(MockitoTestNGListener.class) public class MeanTaxFactorCalculatorTestNgTest { @Mock TaxFactorFetcher taxFactorFetcher;
@InjectMocks MeanTaxFactorCalculator systemUnderTest;
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope
ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new ButtonPresenter(interactor, numberUpdateYoke); } @Provides @ButtonScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new ButtonPresenter(interactor, numberUpdateYoke); } @Provides @ButtonScope
ButtonContract.Interactor provideInteractor(FakeDb fakeDb) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides;
package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new ButtonPresenter(interactor, numberUpdateYoke); } @Provides @ButtonScope ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { return new ButtonInteractor(fakeDb); } @Provides @ButtonScope
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: sample/src/main/java/com/metova/privvy/sample/db/FakeDb.java // @Singleton // public class FakeDb { // // private PublishRelay<Number> numberRelay = PublishRelay.create(); // // private Number number = new Number(); // // @Inject // public FakeDb() { // } // // public Flowable<Number> getNumber() { // return Flowable.just(number); // } // // public void updateNumberBy(int value) { // number.value += value; // numberRelay.accept(this.number); // } // // public Flowable<Number> numberUpdates() { // return numberRelay.toFlowable(BackpressureStrategy.BUFFER); // } // // public Flowable<List<DescriptiveNumber>> getNumberList() { // List<DescriptiveNumber> list = new ArrayList<>(); // // for (int i = 0; i < 10; i++) { // DescriptiveNumber num = new DescriptiveNumber(); // num.description = "Number: "; // num.value = i; // list.add(num); // } // return Flowable.just(list); // } // // public void setNumberValue(int value) { // number.value = value; // } // // public Flowable<DescriptiveNumber> updateListItem(int position) { // //fake database interaction that flags the model somehow // DescriptiveNumber num = new DescriptiveNumber(); // num.value = position; // num.description = "Magic Number: "; // // return Flowable.just(num); // } // } // // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/NumberUpdateYoke.java // public interface NumberUpdateYoke { // // Flowable<Integer> onNumberChanged(); // // void changeNumber(int newNumber); // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonModule.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.sample.db.FakeDb; import com.metova.privvy.sample.ui.floatingnumber.NumberUpdateYoke; import dagger.Module; import dagger.Provides; package com.metova.privvy.sample.ui.floatingnumber.buttons; @Module public final class ButtonModule { public ButtonModule() { } @Provides @ButtonScope ButtonContract.Presenter providePresenter(ButtonContract.Interactor interactor, NumberUpdateYoke numberUpdateYoke) { return new ButtonPresenter(interactor, numberUpdateYoke); } @Provides @ButtonScope ButtonContract.Interactor provideInteractor(FakeDb fakeDb) { return new ButtonInteractor(fakeDb); } @Provides @ButtonScope
ButtonContract.Router provideButtonRouter(PrivvyHost host) {
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter;
package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter; package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
getHost().goTo(RouteData.Builder().viewType(ViewType.ACTIVITY).viewClass(MainActivity.class).build());
metova/privvy
sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // }
import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter;
package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java // public interface PrivvyHost { // // void initialize(RouteData... routes); // // void replace(RouteData oldComponent, RouteData newComponent); // // void goTo(RouteData newComponent); // } // // Path: privvy/src/main/java/com/metova/privvy/RouteData.java // @AutoValue // public abstract class RouteData { // // public abstract ViewType viewType(); // public abstract Class<?> viewClass(); // public abstract int viewId(); // // public static Builder Builder() { // return new AutoValue_RouteData.Builder().viewId(0); // } // // public String tag() { // return viewClass().getSimpleName(); // } // // @AutoValue.Builder // public interface Builder { // Builder viewType(ViewType viewType); // Builder viewClass(Class<?> viewClass); // Builder viewId(@IdRes int viewId); // RouteData build(); // } // } // // Path: privvy/src/main/java/com/metova/privvy/ViewType.java // public enum ViewType { // ACTIVITY, // FRAGMENT // } // // Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java // public class MainActivity extends AppCompatActivity implements PrivvyHost { // // public HostComponent hostComponent; // // private PrivvyHostDelegate hostDelegate; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // hostComponent = SampleApplication.component.newHost() // .hostModule(new HostModule(this)) // .build(); // // hostDelegate = new PrivvyHostDelegate(this); // // setContentView(R.layout.main_activity); // // initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA); // } // // @Override // public void initialize(RouteData... routeData) { // hostDelegate.initialize(routeData); // } // // @Override // public void replace(RouteData oldComponent, RouteData newComponent) { // hostDelegate.replace(oldComponent, newComponent); // } // // @Override // public void goTo(RouteData newComponent) { // hostDelegate.goTo(newComponent); // } // } // // Path: privvy/src/main/java/com/metova/privvy/PrivvyRouter.java // public class PrivvyRouter implements PrivvyContract.Router { // // private PrivvyHost host; // // public PrivvyRouter(PrivvyHost host) { // this.host = host; // } // // @Override // public PrivvyHost getHost() { // return host; // } // // } // Path: sample/src/main/java/com/metova/privvy/sample/ui/list/ListRouter.java import com.metova.privvy.PrivvyHost; import com.metova.privvy.RouteData; import com.metova.privvy.ViewType; import com.metova.privvy.sample.MainActivity; import com.metova.privvy.PrivvyRouter; package com.metova.privvy.sample.ui.list; class ListRouter extends PrivvyRouter implements ListContract.Router { ListRouter(PrivvyHost host) { super(host); } @Override public void navigateToMain() {
getHost().goTo(RouteData.Builder().viewType(ViewType.ACTIVITY).viewClass(MainActivity.class).build());