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
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/SubscribeFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; import net.eusashead.iot.mqtt.SubscribeMessage; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscribeFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final SubscribeFactory factory = new SubscribeFactory(client); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); final ArgumentCaptor<IMqttMessageListener[]> messageListener = ArgumentCaptor .forClass(IMqttMessageListener[].class); final String[] topics = new String[] { "topic1", "topic2" }; final int[] qos = new int[] { 1, 2 };
// Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/SubscribeFactoryTest.java import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; import net.eusashead.iot.mqtt.SubscribeMessage; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscribeFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final SubscribeFactory factory = new SubscribeFactory(client); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); final ArgumentCaptor<IMqttMessageListener[]> messageListener = ArgumentCaptor .forClass(IMqttMessageListener[].class); final String[] topics = new String[] { "topic1", "topic2" }; final int[] qos = new int[] { 1, 2 };
final Flowable<SubscribeMessage> obs = factory.create(topics, qos,
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage;
Assert.assertFalse(this.asyncClient.isConnected()); Assert.assertFalse(this.observableClient.isConnected()); } @Test(expected = MqttException.class) public void itCanClose() throws Throwable { Assert.assertFalse(this.asyncClient.isConnected()); Assert.assertFalse(this.observableClient.isConnected()); final Completable obs1 = this.observableClient.connect(); obs1.blockingAwait(); final Completable obs2 = this.observableClient.disconnect(); obs2.blockingAwait(); final Completable obs3 = this.observableClient.close(); obs3.blockingAwait(); // Should error AsyncPahoUtils.connect(this.asyncClient); } @Test public void itCanSubscribe() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>();
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage; Assert.assertFalse(this.asyncClient.isConnected()); Assert.assertFalse(this.observableClient.isConnected()); } @Test(expected = MqttException.class) public void itCanClose() throws Throwable { Assert.assertFalse(this.asyncClient.isConnected()); Assert.assertFalse(this.observableClient.isConnected()); final Completable obs1 = this.observableClient.connect(); obs1.blockingAwait(); final Completable obs2 = this.observableClient.disconnect(); obs2.blockingAwait(); final Completable obs3 = this.observableClient.close(); obs3.blockingAwait(); // Should error AsyncPahoUtils.connect(this.asyncClient); } @Test public void itCanSubscribe() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>();
final AtomicReference<SubscribeMessage> result = new AtomicReference<>();
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage;
@Test public void itCanSubscribe() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>(); final AtomicReference<SubscribeMessage> result = new AtomicReference<>(); // Callback to monitor delivery completion this.asyncClient.setCallback(new MqttCallback() { @Override public void messageArrived(final String topic, final MqttMessage m) throws Exception { } @Override public void deliveryComplete(final IMqttDeliveryToken t) { token.set(t); latch.countDown(); } @Override public void connectionLost(final Throwable cause) { } }); // Subscribe
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage; @Test public void itCanSubscribe() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>(); final AtomicReference<SubscribeMessage> result = new AtomicReference<>(); // Callback to monitor delivery completion this.asyncClient.setCallback(new MqttCallback() { @Override public void messageArrived(final String topic, final MqttMessage m) throws Exception { } @Override public void deliveryComplete(final IMqttDeliveryToken t) { token.set(t); latch.countDown(); } @Override public void connectionLost(final Throwable cause) { } }); // Subscribe
final PublishMessage expected = PublishMessage
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage;
@Override public void connectionLost(final Throwable cause) { } }); // Subscribe this.observableClient.subscribe(TOPIC, 1).subscribe(r -> { messageCount.incrementAndGet(); latch.countDown(); }); // Publish a test message AsyncPahoUtils.publish(this.asyncClient, TOPIC, new byte[] { 'a', 'b', 'c' }); AsyncPahoUtils.publish(this.asyncClient, TOPIC, new byte[] { 'd', 'e', 'f' }); // Await for async completion latch.await(); Assert.assertEquals(2, messageCount.get()); } @Test public void itCanPublish() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>();
// Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PahoObservableMqttClientITCase.java import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import io.reactivex.Completable; import io.reactivex.Single; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.SubscribeMessage; @Override public void connectionLost(final Throwable cause) { } }); // Subscribe this.observableClient.subscribe(TOPIC, 1).subscribe(r -> { messageCount.incrementAndGet(); latch.countDown(); }); // Publish a test message AsyncPahoUtils.publish(this.asyncClient, TOPIC, new byte[] { 'a', 'b', 'c' }); AsyncPahoUtils.publish(this.asyncClient, TOPIC, new byte[] { 'd', 'e', 'f' }); // Await for async completion latch.await(); Assert.assertEquals(2, messageCount.get()); } @Test public void itCanPublish() throws Throwable { AsyncPahoUtils.connect(this.asyncClient); final CountDownLatch latch = new CountDownLatch(2); final AtomicReference<IMqttDeliveryToken> token = new AtomicReference<>();
final AtomicReference<PublishToken> pubToken = new AtomicReference<>();
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/DisconnectFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/paho/DisconnectFactory.java // static final class DisconnectActionListener // extends CompletableEmitterMqttActionListener { // // public DisconnectActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // }
import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.DisconnectFactory.DisconnectActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class DisconnectFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final DisconnectFactory factory = new DisconnectFactory(client); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Completable obs = factory.create(); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).disconnect(Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
// Path: src/main/java/net/eusashead/iot/mqtt/paho/DisconnectFactory.java // static final class DisconnectActionListener // extends CompletableEmitterMqttActionListener { // // public DisconnectActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/DisconnectFactoryTest.java import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.DisconnectFactory.DisconnectActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class DisconnectFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final DisconnectFactory factory = new DisconnectFactory(client); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Completable obs = factory.create(); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).disconnect(Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
.getValue() instanceof DisconnectFactory.DisconnectActionListener);
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/UnsubscribeFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/paho/UnsubscribeFactory.java // static final class UnsubscribeActionListener // extends CompletableEmitterMqttActionListener { // // public UnsubscribeActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // }
import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.UnsubscribeFactory.UnsubscribeActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class UnsubscribeFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final UnsubscribeFactory factory = new UnsubscribeFactory(client); final String[] topics = new String[] { "topic1", "topic2" }; final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Completable obs = factory.create(topics); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).unsubscribe(Matchers.same(topics), Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
// Path: src/main/java/net/eusashead/iot/mqtt/paho/UnsubscribeFactory.java // static final class UnsubscribeActionListener // extends CompletableEmitterMqttActionListener { // // public UnsubscribeActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/UnsubscribeFactoryTest.java import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.UnsubscribeFactory.UnsubscribeActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class UnsubscribeFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final UnsubscribeFactory factory = new UnsubscribeFactory(client); final String[] topics = new String[] { "topic1", "topic2" }; final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Completable obs = factory.create(topics); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).unsubscribe(Matchers.same(topics), Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
.getValue() instanceof UnsubscribeFactory.UnsubscribeActionListener);
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/SubscriberMqttMessageListenerTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import net.eusashead.iot.mqtt.SubscribeMessage; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.MqttMessage;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscriberMqttMessageListenerTest { @Test public void whenAValidObserverIsPassedToTheConstructorThenItIsConstructedWithoutError() { @SuppressWarnings("unchecked")
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/SubscriberMqttMessageListenerTest.java import net.eusashead.iot.mqtt.SubscribeMessage; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.MqttMessage; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscriberMqttMessageListenerTest { @Test public void whenAValidObserverIsPassedToTheConstructorThenItIsConstructedWithoutError() { @SuppressWarnings("unchecked")
final FlowableEmitter<MqttMessage> observer = Mockito
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/SubscriberMqttMessageListenerTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import net.eusashead.iot.mqtt.SubscribeMessage; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.MqttMessage;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscriberMqttMessageListenerTest { @Test public void whenAValidObserverIsPassedToTheConstructorThenItIsConstructedWithoutError() { @SuppressWarnings("unchecked") final FlowableEmitter<MqttMessage> observer = Mockito .mock(FlowableEmitter.class); new SubscriberMqttMessageListener(observer); } @Test(expected = NullPointerException.class) public void whenANulldObserverIsPassedToTheConstructorThenItThrowsAnError() { final FlowableEmitter<MqttMessage> observer = null; new SubscriberMqttMessageListener(observer); } @Test public void whenAMessageArrivesThenTheObserverIsNotified() throws Exception { @SuppressWarnings("unchecked") final FlowableEmitter<MqttMessage> observer = Mockito .mock(FlowableEmitter.class); final IMqttMessageListener listener = new SubscriberMqttMessageListener( observer); final String expectedTopic = "expected"; final byte[] expectedPayload = new byte[] { 'a', 'b', 'c' }; final org.eclipse.paho.client.mqttv3.MqttMessage expectedMessage = new org.eclipse.paho.client.mqttv3.MqttMessage( expectedPayload); expectedMessage.setQos(2); expectedMessage.setId(1); expectedMessage.setRetained(true);
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/SubscriberMqttMessageListenerTest.java import net.eusashead.iot.mqtt.SubscribeMessage; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.MqttMessage; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class SubscriberMqttMessageListenerTest { @Test public void whenAValidObserverIsPassedToTheConstructorThenItIsConstructedWithoutError() { @SuppressWarnings("unchecked") final FlowableEmitter<MqttMessage> observer = Mockito .mock(FlowableEmitter.class); new SubscriberMqttMessageListener(observer); } @Test(expected = NullPointerException.class) public void whenANulldObserverIsPassedToTheConstructorThenItThrowsAnError() { final FlowableEmitter<MqttMessage> observer = null; new SubscriberMqttMessageListener(observer); } @Test public void whenAMessageArrivesThenTheObserverIsNotified() throws Exception { @SuppressWarnings("unchecked") final FlowableEmitter<MqttMessage> observer = Mockito .mock(FlowableEmitter.class); final IMqttMessageListener listener = new SubscriberMqttMessageListener( observer); final String expectedTopic = "expected"; final byte[] expectedPayload = new byte[] { 'a', 'b', 'c' }; final org.eclipse.paho.client.mqttv3.MqttMessage expectedMessage = new org.eclipse.paho.client.mqttv3.MqttMessage( expectedPayload); expectedMessage.setQos(2); expectedMessage.setId(1); expectedMessage.setRetained(true);
final ArgumentCaptor<SubscribeMessage> actualMessage = ArgumentCaptor
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // }
import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1";
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1";
final PublishMessage msg = PublishMessage
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // }
import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1"; final PublishMessage msg = PublishMessage .create(new byte[] { 'a', 'b', 'c' }, 1, true); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1"; final PublishMessage msg = PublishMessage .create(new byte[] { 'a', 'b', 'c' }, 1, true); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When
final Single<PublishToken> obs = factory.create(topic, msg);
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // }
import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1"; final PublishMessage msg = PublishMessage .create(new byte[] { 'a', 'b', 'c' }, 1, true); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Single<PublishToken> obs = factory.create(topic, msg); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class PublishFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { // Given final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final PublishFactory factory = new PublishFactory(client); final String topic = "topic1"; final PublishMessage msg = PublishMessage .create(new byte[] { 'a', 'b', 'c' }, 1, true); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Single<PublishToken> obs = factory.create(topic, msg); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener
.getValue() instanceof PublishFactory.PublishActionListener);
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // }
import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener;
final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Single<PublishToken> obs = factory.create(topic, msg); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener .getValue() instanceof PublishFactory.PublishActionListener); } @Test public void whenCreateIsCalledAndAnErrorOccursThenObserverOnErrorIsCalled() throws Throwable { this.expectedException.expectCause(isA(MqttException.class)); final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); Mockito.when(client.publish(Matchers.any(String.class), Matchers.any(byte[].class), Matchers.any(int.class), Matchers.any(boolean.class), Matchers.isNull(), Matchers.any(PublishFactory.PublishActionListener.class))) .thenThrow(new MqttException( MqttException.REASON_CODE_CLIENT_CONNECTED)); final PublishFactory factory = new PublishFactory(client); final Single<PublishToken> obs = factory.create("topic1",
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener; final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); // When final Single<PublishToken> obs = factory.create(topic, msg); // Then Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener .getValue() instanceof PublishFactory.PublishActionListener); } @Test public void whenCreateIsCalledAndAnErrorOccursThenObserverOnErrorIsCalled() throws Throwable { this.expectedException.expectCause(isA(MqttException.class)); final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); Mockito.when(client.publish(Matchers.any(String.class), Matchers.any(byte[].class), Matchers.any(int.class), Matchers.any(boolean.class), Matchers.isNull(), Matchers.any(PublishFactory.PublishActionListener.class))) .thenThrow(new MqttException( MqttException.REASON_CODE_CLIENT_CONNECTED)); final PublishFactory factory = new PublishFactory(client); final Single<PublishToken> obs = factory.create("topic1",
Mockito.mock(MqttMessage.class));
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // }
import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener;
obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener .getValue() instanceof PublishFactory.PublishActionListener); } @Test public void whenCreateIsCalledAndAnErrorOccursThenObserverOnErrorIsCalled() throws Throwable { this.expectedException.expectCause(isA(MqttException.class)); final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); Mockito.when(client.publish(Matchers.any(String.class), Matchers.any(byte[].class), Matchers.any(int.class), Matchers.any(boolean.class), Matchers.isNull(), Matchers.any(PublishFactory.PublishActionListener.class))) .thenThrow(new MqttException( MqttException.REASON_CODE_CLIENT_CONNECTED)); final PublishFactory factory = new PublishFactory(client); final Single<PublishToken> obs = factory.create("topic1", Mockito.mock(MqttMessage.class)); obs.blockingGet(); } @Test public void whenOnSuccessIsCalledThenObserverOnNextAndOnCompletedAreCalled() throws Exception { @SuppressWarnings("unchecked")
// Path: src/main/java/net/eusashead/iot/mqtt/MqttMessage.java // public interface MqttMessage { // // boolean isRetained(); // // int getQos(); // // byte[] getPayload(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/MqttToken.java // public interface MqttToken { // // String getClientId(); // // /** // * Returns the topic string for the this token or null if nothing has been // * published // * // * @return {@link String} topics for the token or null // */ // String[] getTopics(); // // /** // * Returns the identifier for the message associated with this token // * // * @return {@link String} message identifier // */ // public int getMessageId(); // // /** // * Whether a session is present for this topic // * // * @return <code>true</code> if session present or <code>false</code> // * otherwise // */ // public boolean getSessionPresent(); // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishMessage.java // public interface PublishMessage extends MqttMessage { // // static PublishMessage create(final byte[] payload, final int qos, // final boolean retained) { // return new PublishMessageImpl(payload, qos, retained); // } // // class PublishMessageImpl extends AbstractMqttMessage // implements PublishMessage { // // private PublishMessageImpl(final byte[] payload, final int qos, // final boolean retained) { // super(payload, qos, retained); // } // // @Override // public String toString() { // return "PublishMessageImpl [payload=" + Arrays.toString(payload) // + ", qos=" + qos + ", retained=" + retained + "]"; // } // // } // // } // // Path: src/main/java/net/eusashead/iot/mqtt/PublishToken.java // public interface PublishToken extends MqttToken { // // } // // Path: src/main/java/net/eusashead/iot/mqtt/paho/PublishFactory.java // static final class PublishActionListener // extends BaseEmitterMqttActionListener { // // private final SingleEmitter<? super PublishToken> emitter; // // public PublishActionListener( // final SingleEmitter<? super PublishToken> emitter) { // this.emitter = Objects.requireNonNull(emitter); // } // // @Override // public OnError getOnError() { // return new OnError() { // // @Override // public void onError(final Throwable t) { // PublishActionListener.this.emitter.onError(t); // } // }; // } // // @Override // public void onSuccess(final IMqttToken mqttToken) { // // final PublishToken publishToken = new PublishToken() { // // @Override // public String getClientId() { // return mqttToken.getClient().getClientId(); // } // // @Override // public String[] getTopics() { // return mqttToken.getTopics(); // } // // @Override // public int getMessageId() { // return mqttToken.getMessageId(); // } // // @Override // public boolean getSessionPresent() { // return mqttToken.getSessionPresent(); // } // // }; // this.emitter.onSuccess(publishToken); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/PublishFactoryTest.java import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Single; import io.reactivex.SingleEmitter; import net.eusashead.iot.mqtt.MqttMessage; import net.eusashead.iot.mqtt.MqttToken; import net.eusashead.iot.mqtt.PublishMessage; import net.eusashead.iot.mqtt.PublishToken; import net.eusashead.iot.mqtt.paho.PublishFactory.PublishActionListener; obs.subscribe(); Mockito.verify(client).publish(Matchers.same(topic), Matchers.same(msg.getPayload()), Matchers.anyInt(), Matchers.anyBoolean(), Matchers.any(), actionListener.capture()); Assert.assertTrue(actionListener .getValue() instanceof PublishFactory.PublishActionListener); } @Test public void whenCreateIsCalledAndAnErrorOccursThenObserverOnErrorIsCalled() throws Throwable { this.expectedException.expectCause(isA(MqttException.class)); final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); Mockito.when(client.publish(Matchers.any(String.class), Matchers.any(byte[].class), Matchers.any(int.class), Matchers.any(boolean.class), Matchers.isNull(), Matchers.any(PublishFactory.PublishActionListener.class))) .thenThrow(new MqttException( MqttException.REASON_CODE_CLIENT_CONNECTED)); final PublishFactory factory = new PublishFactory(client); final Single<PublishToken> obs = factory.create("topic1", Mockito.mock(MqttMessage.class)); obs.blockingGet(); } @Test public void whenOnSuccessIsCalledThenObserverOnNextAndOnCompletedAreCalled() throws Exception { @SuppressWarnings("unchecked")
final SingleEmitter<MqttToken> observer = Mockito
patrickvankann/rxmqtt
src/main/java/net/eusashead/iot/mqtt/paho/SubscribeFactory.java
// Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // }
import io.reactivex.Flowable; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.SubscribeMessage; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import io.reactivex.BackpressureStrategy;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ public class SubscribeFactory extends BaseMqttActionFactory { static final class SubscribeActionListener
// Path: src/main/java/net/eusashead/iot/mqtt/SubscribeMessage.java // public interface SubscribeMessage extends MqttMessage { // // int getId(); // // String getTopic(); // // static SubscribeMessage create(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // return new SubscribeMessageImpl(id, topic, payload, qos, retained); // } // // class SubscribeMessageImpl extends AbstractMqttMessage // implements SubscribeMessage { // // private final int id; // private final String topic; // // private SubscribeMessageImpl(final int id, final String topic, // final byte[] payload, final int qos, final boolean retained) { // super(payload, qos, retained); // this.id = Objects.requireNonNull(id); // this.topic = Objects.requireNonNull(topic); // } // // @Override // public int getId() { // return this.id; // } // // @Override // public String getTopic() { // return this.topic; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + id; // result = prime * result + ((topic == null) ? 0 : topic.hashCode()); // return result; // } // // @Override // public boolean equals(final Object obj) { // if (this == obj) { // return true; // } // if (!super.equals(obj)) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final SubscribeMessageImpl other = (SubscribeMessageImpl) obj; // if (id != other.id) { // return false; // } // if (topic == null) { // if (other.topic != null) { // return false; // } // } else if (!topic.equals(other.topic)) { // return false; // } // return true; // } // // @Override // public String toString() { // return "SubscribeMessageImpl [id=" + id + ", topic=" + topic // + ", payload=" + Arrays.toString(payload) + ", qos=" + qos // + ", retained=" + retained + "]"; // } // // } // // } // Path: src/main/java/net/eusashead/iot/mqtt/paho/SubscribeFactory.java import io.reactivex.Flowable; import io.reactivex.FlowableEmitter; import net.eusashead.iot.mqtt.SubscribeMessage; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttException; import io.reactivex.BackpressureStrategy; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ public class SubscribeFactory extends BaseMqttActionFactory { static final class SubscribeActionListener
extends FlowableEmitterMqttActionListener<SubscribeMessage> {
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/ConnectFactoryTest.java
// Path: src/main/java/net/eusashead/iot/mqtt/paho/ConnectFactory.java // static final class ConnectActionListener // extends CompletableEmitterMqttActionListener { // // public ConnectActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // }
import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.ConnectFactory.ConnectActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test;
package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class ConnectFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final MqttConnectOptions options = Mockito .mock(MqttConnectOptions.class); final ConnectFactory factory = new ConnectFactory(client, options); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); final Completable obs = factory.create(); Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).connect(Matchers.same(options), Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
// Path: src/main/java/net/eusashead/iot/mqtt/paho/ConnectFactory.java // static final class ConnectActionListener // extends CompletableEmitterMqttActionListener { // // public ConnectActionListener(final CompletableEmitter emitter) { // super(emitter); // } // // @Override // public void onSuccess(final IMqttToken asyncActionToken) { // this.emitter.onComplete(); // } // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/ConnectFactoryTest.java import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mockito; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; import net.eusashead.iot.mqtt.paho.ConnectFactory.ConnectActionListener; import static org.hamcrest.Matchers.isA; import org.eclipse.paho.client.mqttv3.IMqttActionListener; import org.eclipse.paho.client.mqttv3.IMqttAsyncClient; import org.eclipse.paho.client.mqttv3.IMqttToken; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; package net.eusashead.iot.mqtt.paho; /* * #[license] * rxmqtt * %% * Copyright (C) 2013 - 2016 Eusa's Head * %% * 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. * %[license] */ @RunWith(JUnit4.class) public class ConnectFactoryTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void whenCreateIsCalledThenAnObservableIsReturned() throws Exception { final IMqttAsyncClient client = Mockito.mock(IMqttAsyncClient.class); final MqttConnectOptions options = Mockito .mock(MqttConnectOptions.class); final ConnectFactory factory = new ConnectFactory(client, options); final ArgumentCaptor<IMqttActionListener> actionListener = ArgumentCaptor .forClass(IMqttActionListener.class); final Completable obs = factory.create(); Assert.assertNotNull(obs); obs.subscribe(); Mockito.verify(client).connect(Matchers.same(options), Matchers.isNull(), actionListener.capture()); Assert.assertTrue(actionListener
.getValue() instanceof ConnectFactory.ConnectActionListener);
patrickvankann/rxmqtt
src/test/java/net/eusashead/iot/mqtt/paho/ToxiproxyConnectivityITCase.java
// Path: src/main/java/net/eusashead/iot/mqtt/ObservableMqttClient.java // public interface ObservableMqttClient { // // /** // * Get the MQTT broker URI // * // * @return the MQTT broker URI string // */ // String getBrokerUri(); // // /** // * Get the MQTT client id from the underlying MQTT client // * // * @return {@link String} client identifier // */ // String getClientId(); // // /** // * Whether the MQTT client is connected to the broker // * // * @return <code>true</code> if connected, <code>false</code> otherwise // */ // boolean isConnected(); // // /** // * Close the MQTT client // * // * @return {@link Completable} that will complete on successful closure // */ // Completable close(); // // /** // * Connect the MQTT client // * // * @return {@link Completable} that will complete on successful connection // */ // Completable connect(); // // /** // * Disconnect the MQTT client // * // * @return {@link Completable} that will complete on successful // * disconnection // */ // Completable disconnect(); // // /** // * Publish an {@link PublishMessage} to a {@link String} topic. // * // * @param topic {@link String} topic name // * @param msg {@link PublishMessage} message to publish // * // * @return {@link Single} that will complete on successful publication with // * a {@link PublishToken} // */ // Single<PublishToken> publish(String topic, PublishMessage msg); // // /** // * Subscribe to multiple {@link String} topics to receive multiple // * {@link SubscribeMessage} at the given QOS levels // * // * @param topics {@link String} topic names // * @param qos QOS level to use for subscription // * // * @return {@link Flowable} that will receive multiple // * {@link SubscribeMessage} // */ // Flowable<SubscribeMessage> subscribe(String[] topics, int[] qos); // // /** // * Subscribe to a {@link String} topic to receive multiple // * {@link SubscribeMessage} at the supplied QOS level // * // * @param topic {@link String} topic name // * @param qos QOS level to use for subscription // * // * @return {@link Flowable} that will receive multiple // * {@link SubscribeMessage} // */ // Flowable<SubscribeMessage> subscribe(String topic, int qos); // // /** // * Unsubscribe from the given topics {@link String} array // * // * @param topics {@link String} topic names // * // * @return {@link Completable} that will complete on successful unsubscribe // */ // Completable unsubscribe(String[] topics); // // /** // * Unsubscribe from the given topic {@link String} // * // * @param topic {@link String} topic name // * // * @return {@link Completable} that will complete on successful unsubscribe // */ // Completable unsubscribe(String topic); // // }
import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import eu.rekawek.toxiproxy.Proxy; import eu.rekawek.toxiproxy.ToxiproxyClient; import net.eusashead.iot.mqtt.ObservableMqttClient; import java.io.IOException; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test;
} }); this.brokerProxy = proxyClient.createProxy("broker", PROXY_HOST + ":" + PROXY_PORT, BROKER_HOST + ":" + BROKER_PORT); this.brokerProxy.enable(); } @After public void after() throws Exception { // Remove the proxy if (this.brokerProxy != null) { this.brokerProxy.delete(); } } @Ignore @Test public void whenBrokerIsStoppedThenClientIsDisconnected() throws Throwable { // Create client with re-connect and dirty sessions MqttConnectOptions options = new MqttConnectOptions(); options.setAutomaticReconnect(false); options.setCleanSession(false); options.setKeepAliveInterval(1); options.setConnectionTimeout(1); String proxyUrl = "tcp://" + PROXY_HOST + ":" + PROXY_PORT; MqttAsyncClient asyncClient = new MqttAsyncClient(proxyUrl, "test-client-id", new MemoryPersistence());
// Path: src/main/java/net/eusashead/iot/mqtt/ObservableMqttClient.java // public interface ObservableMqttClient { // // /** // * Get the MQTT broker URI // * // * @return the MQTT broker URI string // */ // String getBrokerUri(); // // /** // * Get the MQTT client id from the underlying MQTT client // * // * @return {@link String} client identifier // */ // String getClientId(); // // /** // * Whether the MQTT client is connected to the broker // * // * @return <code>true</code> if connected, <code>false</code> otherwise // */ // boolean isConnected(); // // /** // * Close the MQTT client // * // * @return {@link Completable} that will complete on successful closure // */ // Completable close(); // // /** // * Connect the MQTT client // * // * @return {@link Completable} that will complete on successful connection // */ // Completable connect(); // // /** // * Disconnect the MQTT client // * // * @return {@link Completable} that will complete on successful // * disconnection // */ // Completable disconnect(); // // /** // * Publish an {@link PublishMessage} to a {@link String} topic. // * // * @param topic {@link String} topic name // * @param msg {@link PublishMessage} message to publish // * // * @return {@link Single} that will complete on successful publication with // * a {@link PublishToken} // */ // Single<PublishToken> publish(String topic, PublishMessage msg); // // /** // * Subscribe to multiple {@link String} topics to receive multiple // * {@link SubscribeMessage} at the given QOS levels // * // * @param topics {@link String} topic names // * @param qos QOS level to use for subscription // * // * @return {@link Flowable} that will receive multiple // * {@link SubscribeMessage} // */ // Flowable<SubscribeMessage> subscribe(String[] topics, int[] qos); // // /** // * Subscribe to a {@link String} topic to receive multiple // * {@link SubscribeMessage} at the supplied QOS level // * // * @param topic {@link String} topic name // * @param qos QOS level to use for subscription // * // * @return {@link Flowable} that will receive multiple // * {@link SubscribeMessage} // */ // Flowable<SubscribeMessage> subscribe(String topic, int qos); // // /** // * Unsubscribe from the given topics {@link String} array // * // * @param topics {@link String} topic names // * // * @return {@link Completable} that will complete on successful unsubscribe // */ // Completable unsubscribe(String[] topics); // // /** // * Unsubscribe from the given topic {@link String} // * // * @param topic {@link String} topic name // * // * @return {@link Completable} that will complete on successful unsubscribe // */ // Completable unsubscribe(String topic); // // } // Path: src/test/java/net/eusashead/iot/mqtt/paho/ToxiproxyConnectivityITCase.java import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import eu.rekawek.toxiproxy.Proxy; import eu.rekawek.toxiproxy.ToxiproxyClient; import net.eusashead.iot.mqtt.ObservableMqttClient; import java.io.IOException; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; } }); this.brokerProxy = proxyClient.createProxy("broker", PROXY_HOST + ":" + PROXY_PORT, BROKER_HOST + ":" + BROKER_PORT); this.brokerProxy.enable(); } @After public void after() throws Exception { // Remove the proxy if (this.brokerProxy != null) { this.brokerProxy.delete(); } } @Ignore @Test public void whenBrokerIsStoppedThenClientIsDisconnected() throws Throwable { // Create client with re-connect and dirty sessions MqttConnectOptions options = new MqttConnectOptions(); options.setAutomaticReconnect(false); options.setCleanSession(false); options.setKeepAliveInterval(1); options.setConnectionTimeout(1); String proxyUrl = "tcp://" + PROXY_HOST + ":" + PROXY_PORT; MqttAsyncClient asyncClient = new MqttAsyncClient(proxyUrl, "test-client-id", new MemoryPersistence());
ObservableMqttClient observableClient = observableClient(asyncClient, options);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/SettingsClient.java
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.DatabaseAccess;
package com.webwoz.wizard.client; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class SettingsClient implements Screen { private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel settingsPanel = new VerticalPanel(); private HorizontalPanel outputPanel = new HorizontalPanel(); private CheckBox textChk = new CheckBox("Text Output"); private CheckBox audioChk = new CheckBox("Audio Output"); private CheckBox mmChk = new CheckBox("Multi-Media Output"); // other variables private int expId; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/SettingsClient.java import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.DatabaseAccess; package com.webwoz.wizard.client; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class SettingsClient implements Screen { private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel settingsPanel = new VerticalPanel(); private HorizontalPanel outputPanel = new HorizontalPanel(); private CheckBox textChk = new CheckBox("Text Output"); private CheckBox audioChk = new CheckBox("Audio Output"); private CheckBox mmChk = new CheckBox("Multi-Media Output"); // other variables private int expId; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/NLUComp.java
// Path: webwozwizard/src/com/webwoz/wizard/server/components/NLUDefault.java // public class NLUDefault extends NLUComp { // // public NLUDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // }
import com.webwoz.wizard.server.components.NLUDefault;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class NLUComp implements Component { // variables private final int type = 3; private final String typeName = "NLU"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "NLU: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right NLU component switch (comp) { case 0:
// Path: webwozwizard/src/com/webwoz/wizard/server/components/NLUDefault.java // public class NLUDefault extends NLUComp { // // public NLUDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // Path: webwozwizard/src/com/webwoz/wizard/server/NLUComp.java import com.webwoz.wizard.server.components.NLUDefault; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class NLUComp implements Component { // variables private final int type = 3; private final String typeName = "NLU"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "NLU: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right NLU component switch (comp) { case 0:
return new NLUDefault(mode);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/NLGComp.java
// Path: webwozwizard/src/com/webwoz/wizard/server/components/NLGDefault.java // public class NLGDefault extends NLGComp { // // public NLGDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // }
import com.webwoz.wizard.server.components.NLGDefault;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class NLGComp implements Component { // variables private final int type = 4; private final String typeName = "NLG"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "NLG: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right NLG component switch (comp) { case 0:
// Path: webwozwizard/src/com/webwoz/wizard/server/components/NLGDefault.java // public class NLGDefault extends NLGComp { // // public NLGDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // Path: webwozwizard/src/com/webwoz/wizard/server/NLGComp.java import com.webwoz.wizard.server.components.NLGDefault; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class NLGComp implements Component { // variables private final int type = 4; private final String typeName = "NLG"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "NLG: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right NLG component switch (comp) { case 0:
return new NLGDefault(mode);
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/server/ASR.java
// Path: webwozclient/src/com/webwoz/client/server/Database.java // public class Database { // // // Database access // private Connection conn; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "testuser"; // private String pass = "testuser"; // // public Database() { // MySQLConnection(); // } // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public void storeData(String sql) { // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // }
import com.webwoz.client.server.Database; import java.io.IOException; import java.io.PrintWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
package com.webwoz.client.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class ASR extends HttpServlet { private String output;
// Path: webwozclient/src/com/webwoz/client/server/Database.java // public class Database { // // // Database access // private Connection conn; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "testuser"; // private String pass = "testuser"; // // public Database() { // MySQLConnection(); // } // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public void storeData(String sql) { // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // } // Path: webwozclient/src/com/webwoz/client/server/ASR.java import com.webwoz.client.server.Database; import java.io.IOException; import java.io.PrintWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; package com.webwoz.client.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class ASR extends HttpServlet { private String output;
private Database db = new Database();
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/WebWOZClient.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // }
import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.media.client.Audio; import com.google.gwt.media.client.Video; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PasswordTextBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync;
// text boxes private TextBox userTextBox; private PasswordTextBox pwTextBox; // buttons private Button loginButton; private Button logoutButton; private Button sendButton; // Text area private TextArea textInputTextArea; // handler private ClickHandler sendClickHandler; private KeyPressHandler sendKeyPressHandler; private ClickHandler loginClickHandler; private KeyPressHandler loginUserKeyPressHandler; private KeyPressHandler loginPWKeyPressHandler; private ClickHandler logoutClickHandler; // handler registration private HandlerRegistration sendClickHandlerRegistration; private HandlerRegistration sendKeyPressHandlerRegistration; private HandlerRegistration loginClickHandlerRegistration; private HandlerRegistration loginUserKeyPressHandlerRegistration; private HandlerRegistration loginPWKeyPressHandlerRegistration; private HandlerRegistration logoutClickHandlerRegistration; // RPC
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // Path: webwozclient/src/com/webwoz/client/client/WebWOZClient.java import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.media.client.Audio; import com.google.gwt.media.client.Video; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PasswordTextBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; // text boxes private TextBox userTextBox; private PasswordTextBox pwTextBox; // buttons private Button loginButton; private Button logoutButton; private Button sendButton; // Text area private TextArea textInputTextArea; // handler private ClickHandler sendClickHandler; private KeyPressHandler sendKeyPressHandler; private ClickHandler loginClickHandler; private KeyPressHandler loginUserKeyPressHandler; private KeyPressHandler loginPWKeyPressHandler; private ClickHandler logoutClickHandler; // handler registration private HandlerRegistration sendClickHandlerRegistration; private HandlerRegistration sendKeyPressHandlerRegistration; private HandlerRegistration loginClickHandlerRegistration; private HandlerRegistration loginUserKeyPressHandlerRegistration; private HandlerRegistration loginPWKeyPressHandlerRegistration; private HandlerRegistration logoutClickHandlerRegistration; // RPC
private DatabaseAccessAsync databaseAccessSvc;
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/WebWOZClient.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // }
import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.media.client.Audio; import com.google.gwt.media.client.Video; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PasswordTextBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync;
// panels to structure layout headPanel = new VerticalPanel(); titlePanel = new HorizontalPanel(); contentPanel = new VerticalPanel(); footPanel = new VerticalPanel(); loginPanel = new HorizontalPanel(); asrPanel = new VerticalPanel(); textPanel = new VerticalPanel(); audioPanel = new VerticalPanel(); mmPanel = new VerticalPanel(); txtInPanel = new HorizontalPanel(); // labels userLabel = new Label("User: "); pwLabel = new Label("Password: "); loginMessage = new Label(); // text boxes userTextBox = new TextBox(); pwTextBox = new PasswordTextBox(); // text areas textInputTextArea = new TextArea(); // buttons loginButton = new Button("login"); logoutButton = new Button("logout"); sendButton = new Button("Send"); // RPC
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // Path: webwozclient/src/com/webwoz/client/client/WebWOZClient.java import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.media.client.Audio; import com.google.gwt.media.client.Video; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PasswordTextBox; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; // panels to structure layout headPanel = new VerticalPanel(); titlePanel = new HorizontalPanel(); contentPanel = new VerticalPanel(); footPanel = new VerticalPanel(); loginPanel = new HorizontalPanel(); asrPanel = new VerticalPanel(); textPanel = new VerticalPanel(); audioPanel = new VerticalPanel(); mmPanel = new VerticalPanel(); txtInPanel = new HorizontalPanel(); // labels userLabel = new Label("User: "); pwLabel = new Label("Password: "); loginMessage = new Label(); // text boxes userTextBox = new TextBox(); pwTextBox = new PasswordTextBox(); // text areas textInputTextArea = new TextArea(); // buttons loginButton = new Button("login"); logoutButton = new Button("logout"); sendButton = new Button("Send"); // RPC
databaseAccessSvc = GWT.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/ComponentFactoryImpl.java
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // }
import java.util.ArrayList; import java.util.Date; import java.util.Vector; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.client.ComponentFactory; import java.text.DateFormat; import java.text.SimpleDateFormat;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class ComponentFactoryImpl extends RemoteServiceServlet implements
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // Path: webwozwizard/src/com/webwoz/wizard/server/ComponentFactoryImpl.java import java.util.ArrayList; import java.util.Date; import java.util.Vector; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.client.ComponentFactory; import java.text.DateFormat; import java.text.SimpleDateFormat; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class ComponentFactoryImpl extends RemoteServiceServlet implements
ComponentFactory {
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen02.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // }
import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; import com.webwoz.client.client.Screen;
package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen02 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel outputPanel = new VerticalPanel(); private HTML outputText = new HTML(""); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; private boolean reload; // RPC
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // Path: webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen02.java import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; import com.webwoz.client.client.Screen; package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen02 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel outputPanel = new VerticalPanel(); private HTML outputText = new HTML(""); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; private boolean reload; // RPC
private DatabaseAccessAsync databaseAccessSvc = GWT
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen02.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // }
import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; import com.webwoz.client.client.Screen;
package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen02 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel outputPanel = new VerticalPanel(); private HTML outputText = new HTML(""); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; private boolean reload; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // Path: webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen02.java import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.DatabaseAccessAsync; import com.webwoz.client.client.Screen; package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen02 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel outputPanel = new VerticalPanel(); private HTML outputText = new HTML(""); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; private boolean reload; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen01.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // }
import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.Screen; import com.webwoz.client.client.DatabaseAccessAsync; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.OpenEvent; import com.google.gwt.event.logical.shared.OpenHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DisclosurePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel;
package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen01 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel audioOutputPanel = new VerticalPanel(); private VerticalPanel textOutputPanel = new VerticalPanel(); private VerticalPanel mmOutputPanel = new VerticalPanel(); private HorizontalPanel controlPanel = new HorizontalPanel(); private VerticalPanel infoPanel = new VerticalPanel(); private HorizontalPanel contentPanel = new HorizontalPanel(); private DisclosurePanel translatedUtterancePanel = new DisclosurePanel( "Deutscher Text"); private DisclosurePanel originalUtterancePanel = new DisclosurePanel( "Englischer Originaltext"); private HTML info = new HTML(); private HTML intro = new HTML( "<p><strong>Bitte dr&uuml;cken Sie nun auf <strong>'Version A' </strong> bzw. <strong>'Version B' </strong> um das Experiment zu beginnen.</p>"); private HTML infoVersion01 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie eine Aussage des Systems nicht verstehen haben Sie die M&ouml;glicheit entweder den (maschinell &uuml;bersetzten) Deutschen Text oder den Englischen Orginaltext einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML infoVersion02 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie den &uuml;bersetzten Text nicht verstehen haben Sie die M&ouml;glicheit die orginale (Englische) Textversion einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML translUttText = new HTML(""); private HTML origUttText = new HTML(""); // Buttons private Button startV01Button = new Button("Version A"); private Button startV02Button = new Button("Version B"); private Button startV03Button = new Button("Video"); private Button startV04Button = new Button("English Text & Speech"); private Button stopButton = new Button("Stop"); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; // RPC
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // Path: webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen01.java import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.Screen; import com.webwoz.client.client.DatabaseAccessAsync; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.OpenEvent; import com.google.gwt.event.logical.shared.OpenHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DisclosurePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen01 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel audioOutputPanel = new VerticalPanel(); private VerticalPanel textOutputPanel = new VerticalPanel(); private VerticalPanel mmOutputPanel = new VerticalPanel(); private HorizontalPanel controlPanel = new HorizontalPanel(); private VerticalPanel infoPanel = new VerticalPanel(); private HorizontalPanel contentPanel = new HorizontalPanel(); private DisclosurePanel translatedUtterancePanel = new DisclosurePanel( "Deutscher Text"); private DisclosurePanel originalUtterancePanel = new DisclosurePanel( "Englischer Originaltext"); private HTML info = new HTML(); private HTML intro = new HTML( "<p><strong>Bitte dr&uuml;cken Sie nun auf <strong>'Version A' </strong> bzw. <strong>'Version B' </strong> um das Experiment zu beginnen.</p>"); private HTML infoVersion01 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie eine Aussage des Systems nicht verstehen haben Sie die M&ouml;glicheit entweder den (maschinell &uuml;bersetzten) Deutschen Text oder den Englischen Orginaltext einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML infoVersion02 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie den &uuml;bersetzten Text nicht verstehen haben Sie die M&ouml;glicheit die orginale (Englische) Textversion einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML translUttText = new HTML(""); private HTML origUttText = new HTML(""); // Buttons private Button startV01Button = new Button("Version A"); private Button startV02Button = new Button("Version B"); private Button startV03Button = new Button("Video"); private Button startV04Button = new Button("English Text & Speech"); private Button stopButton = new Button("Stop"); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; // RPC
private DatabaseAccessAsync databaseAccessSvc = GWT
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen01.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // }
import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.Screen; import com.webwoz.client.client.DatabaseAccessAsync; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.OpenEvent; import com.google.gwt.event.logical.shared.OpenHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DisclosurePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel;
package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen01 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel audioOutputPanel = new VerticalPanel(); private VerticalPanel textOutputPanel = new VerticalPanel(); private VerticalPanel mmOutputPanel = new VerticalPanel(); private HorizontalPanel controlPanel = new HorizontalPanel(); private VerticalPanel infoPanel = new VerticalPanel(); private HorizontalPanel contentPanel = new HorizontalPanel(); private DisclosurePanel translatedUtterancePanel = new DisclosurePanel( "Deutscher Text"); private DisclosurePanel originalUtterancePanel = new DisclosurePanel( "Englischer Originaltext"); private HTML info = new HTML(); private HTML intro = new HTML( "<p><strong>Bitte dr&uuml;cken Sie nun auf <strong>'Version A' </strong> bzw. <strong>'Version B' </strong> um das Experiment zu beginnen.</p>"); private HTML infoVersion01 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie eine Aussage des Systems nicht verstehen haben Sie die M&ouml;glicheit entweder den (maschinell &uuml;bersetzten) Deutschen Text oder den Englischen Orginaltext einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML infoVersion02 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie den &uuml;bersetzten Text nicht verstehen haben Sie die M&ouml;glicheit die orginale (Englische) Textversion einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML translUttText = new HTML(""); private HTML origUttText = new HTML(""); // Buttons private Button startV01Button = new Button("Version A"); private Button startV02Button = new Button("Version B"); private Button startV03Button = new Button("Video"); private Button startV04Button = new Button("English Text & Speech"); private Button stopButton = new Button("Stop"); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // // Path: webwozclient/src/com/webwoz/client/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // } // // Path: webwozclient/src/com/webwoz/client/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<Void> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getDateTime(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // Path: webwozclient/src/com/webwoz/client/client/layouts/ExampleClientScreen01.java import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.client.client.DatabaseAccess; import com.webwoz.client.client.Screen; import com.webwoz.client.client.DatabaseAccessAsync; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.OpenEvent; import com.google.gwt.event.logical.shared.OpenHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.DisclosurePanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HorizontalPanel; package com.webwoz.client.client.layouts; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExampleClientScreen01 implements Screen { // Panels private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel audioOutputPanel = new VerticalPanel(); private VerticalPanel textOutputPanel = new VerticalPanel(); private VerticalPanel mmOutputPanel = new VerticalPanel(); private HorizontalPanel controlPanel = new HorizontalPanel(); private VerticalPanel infoPanel = new VerticalPanel(); private HorizontalPanel contentPanel = new HorizontalPanel(); private DisclosurePanel translatedUtterancePanel = new DisclosurePanel( "Deutscher Text"); private DisclosurePanel originalUtterancePanel = new DisclosurePanel( "Englischer Originaltext"); private HTML info = new HTML(); private HTML intro = new HTML( "<p><strong>Bitte dr&uuml;cken Sie nun auf <strong>'Version A' </strong> bzw. <strong>'Version B' </strong> um das Experiment zu beginnen.</p>"); private HTML infoVersion01 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie eine Aussage des Systems nicht verstehen haben Sie die M&ouml;glicheit entweder den (maschinell &uuml;bersetzten) Deutschen Text oder den Englischen Orginaltext einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML infoVersion02 = new HTML( "<p><strong>Information:</strong><br /> Falls Sie den &uuml;bersetzten Text nicht verstehen haben Sie die M&ouml;glicheit die orginale (Englische) Textversion einzusehen. Bitte klicken sie dazu auf den ensprechenden Pfeil. Um die Session zu beenden dr&uuml;cken Sie bitte auf <strong>'Stop'</strong>.</p>"); private HTML translUttText = new HTML(""); private HTML origUttText = new HTML(""); // Buttons private Button startV01Button = new Button("Version A"); private Button startV02Button = new Button("Version B"); private Button startV03Button = new Button("Video"); private Button startV04Button = new Button("English Text & Speech"); private Button stopButton = new Button("Stop"); // Refresh interval private static final int REFRESH_INTERVAL = 1000; private Timer refreshTimer; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/ASRComp.java
// Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRDefault.java // public class ASRDefault extends ASRComp { // // public ASRDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRGoogle.java // public class ASRGoogle extends ASRComp { // // public ASRGoogle(int mode) { // super.setName("ON"); // super.setMode(mode); // } // // }
import com.webwoz.wizard.server.components.ASRDefault; import com.webwoz.wizard.server.components.ASRGoogle;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ASRComp implements Component { // variables private final int type = 1; private final String typeName = "ASR"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "ASR: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right ASR component switch (comp) { case 0:
// Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRDefault.java // public class ASRDefault extends ASRComp { // // public ASRDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRGoogle.java // public class ASRGoogle extends ASRComp { // // public ASRGoogle(int mode) { // super.setName("ON"); // super.setMode(mode); // } // // } // Path: webwozwizard/src/com/webwoz/wizard/server/ASRComp.java import com.webwoz.wizard.server.components.ASRDefault; import com.webwoz.wizard.server.components.ASRGoogle; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ASRComp implements Component { // variables private final int type = 1; private final String typeName = "ASR"; private String name; private int mode; // Sub classes to override this method public String getOutput(String input) { return "ASR: " + input; } public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right ASR component switch (comp) { case 0:
return new ASRDefault(mode);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/ASRComp.java
// Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRDefault.java // public class ASRDefault extends ASRComp { // // public ASRDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRGoogle.java // public class ASRGoogle extends ASRComp { // // public ASRGoogle(int mode) { // super.setName("ON"); // super.setMode(mode); // } // // }
import com.webwoz.wizard.server.components.ASRDefault; import com.webwoz.wizard.server.components.ASRGoogle;
public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right ASR component switch (comp) { case 0: return new ASRDefault(mode); case 1:
// Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRDefault.java // public class ASRDefault extends ASRComp { // // public ASRDefault(int mode) { // super.setMode(mode); // super.setName("Off"); // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/server/components/ASRGoogle.java // public class ASRGoogle extends ASRComp { // // public ASRGoogle(int mode) { // super.setName("ON"); // super.setMode(mode); // } // // } // Path: webwozwizard/src/com/webwoz/wizard/server/ASRComp.java import com.webwoz.wizard.server.components.ASRDefault; import com.webwoz.wizard.server.components.ASRGoogle; public int getType() { return type; } public String getName() { return name; } public int getMode() { return mode; } public String printType() { return typeName; } public void setName(String name) { this.name = name; } public void setMode(int mode) { this.mode = mode; } public Component getComponent(int comp, int mode) { // instantiate the right ASR component switch (comp) { case 0: return new ASRDefault(mode); case 1:
return new ASRGoogle(mode);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/DatabaseAccessImpl.java
// Path: webwozwizard/src/com/webwoz/wizard/server/Database.java // public class Database { // // // Database access // private Connection conn = null; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "wizard"; // private String pass = "wizard"; // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // MySQLConnection(); // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public int storeData(String sql) { // // MySQLConnection(); // // int lastInsertedId = 0; // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS); // ResultSet rs2 = stmt.getGeneratedKeys(); // // if (rs2 != null && rs2.next()) { // lastInsertedId = rs2.getInt(1); // } // // rs2.close(); // stmt.close(); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // return lastInsertedId; // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // }
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.server.Database; import com.webwoz.wizard.client.DatabaseAccess;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements
// Path: webwozwizard/src/com/webwoz/wizard/server/Database.java // public class Database { // // // Database access // private Connection conn = null; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "wizard"; // private String pass = "wizard"; // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // MySQLConnection(); // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public int storeData(String sql) { // // MySQLConnection(); // // int lastInsertedId = 0; // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS); // ResultSet rs2 = stmt.getGeneratedKeys(); // // if (rs2 != null && rs2.next()) { // lastInsertedId = rs2.getInt(1); // } // // rs2.close(); // stmt.close(); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // return lastInsertedId; // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // Path: webwozwizard/src/com/webwoz/wizard/server/DatabaseAccessImpl.java import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.server.Database; import com.webwoz.wizard.client.DatabaseAccess; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements
DatabaseAccess {
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/DatabaseAccessImpl.java
// Path: webwozwizard/src/com/webwoz/wizard/server/Database.java // public class Database { // // // Database access // private Connection conn = null; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "wizard"; // private String pass = "wizard"; // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // MySQLConnection(); // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public int storeData(String sql) { // // MySQLConnection(); // // int lastInsertedId = 0; // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS); // ResultSet rs2 = stmt.getGeneratedKeys(); // // if (rs2 != null && rs2.next()) { // lastInsertedId = rs2.getInt(1); // } // // rs2.close(); // stmt.close(); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // return lastInsertedId; // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // }
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.server.Database; import com.webwoz.wizard.client.DatabaseAccess;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements DatabaseAccess {
// Path: webwozwizard/src/com/webwoz/wizard/server/Database.java // public class Database { // // // Database access // private Connection conn = null; // private String url = "jdbc:mysql://localhost:3306/webwoz?allowMultiQueries=true&autoReconnect=true"; // private String user = "wizard"; // private String pass = "wizard"; // // public void MySQLConnection() { // // try { // Class.forName("com.mysql.jdbc.Driver").newInstance(); // conn = DriverManager.getConnection(url, user, pass); // // } catch (Exception e) { // System.out.println(e); // } // } // // // retrieveData // public String[][] retrieveData(String sql) { // MySQLConnection(); // // try { // Statement stmt = conn.createStatement(); // // ResultSet rs = stmt.executeQuery(sql); // // get rs meta data // ResultSetMetaData meta = rs.getMetaData(); // // get column count // int cCount = meta.getColumnCount(); // // // get result count in order to define the size of the array // int current = rs.getRow(); // rs.last(); // int count = rs.getRow(); // if (count != 0) { // // count = 0; // if (current == 0) { // rs.beforeFirst(); // } else { // rs.absolute(current); // } // // String[][] s = new String[count][cCount]; // int i = 0; // // while (rs.next()) { // for (int j = 0; j < cCount; j++) { // s[i][j] = rs.getString(j + 1); // } // i++; // } // rs.close(); // return s; // } else { // return null; // } // // } catch (Exception sqle) { // System.out.println(sqle); // return null; // // } finally { // // } // } // // // storeData // public int storeData(String sql) { // // MySQLConnection(); // // int lastInsertedId = 0; // // try { // Statement stmt = conn.createStatement(); // stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS); // ResultSet rs2 = stmt.getGeneratedKeys(); // // if (rs2 != null && rs2.next()) { // lastInsertedId = rs2.getInt(1); // } // // rs2.close(); // stmt.close(); // // } catch (Exception sqle) { // System.out.println(sqle); // // } finally { // // } // return lastInsertedId; // // } // // // close database connection // public void closeDBCon() { // try { // conn.close(); // } catch (Exception dbe) { // System.out.println(dbe); // } // // } // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // Path: webwozwizard/src/com/webwoz/wizard/server/DatabaseAccessImpl.java import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.wizard.server.Database; import com.webwoz.wizard.client.DatabaseAccess; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements DatabaseAccess {
private Database db = new Database();
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/SettingsScreen.java
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // }
import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.DatabaseAccess;
private VerticalPanel settingsSSPanel = new VerticalPanel(); private VerticalPanel settingsMMPanel = new VerticalPanel(); // Labels private Label settingsUserHeadingLabel = new Label(); private Label settingsUser1Label = new Label(); private Label settingsUser2Label = new Label(); private Label settingsASRLabel = new Label(); private Label settingsMTLabel = new Label(); private Label settingsTALabel = new Label(); private Label settingsDMLabel = new Label(); private Label settingsSSLabel = new Label(); private Label settingsMMLabel = new Label(); // list boxes private ListBox asrList1 = new ListBox(); private ListBox mtList1 = new ListBox(); private ListBox taList1 = new ListBox(); private ListBox dmList1 = new ListBox(); private ListBox ssList1 = new ListBox(); private ListBox mmList1 = new ListBox(); private ListBox asrList2 = new ListBox(); private ListBox mtList2 = new ListBox(); private ListBox taList2 = new ListBox(); private ListBox dmList2 = new ListBox(); private ListBox ssList2 = new ListBox(); private ListBox mmList2 = new ListBox(); // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/SettingsScreen.java import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.DatabaseAccess; private VerticalPanel settingsSSPanel = new VerticalPanel(); private VerticalPanel settingsMMPanel = new VerticalPanel(); // Labels private Label settingsUserHeadingLabel = new Label(); private Label settingsUser1Label = new Label(); private Label settingsUser2Label = new Label(); private Label settingsASRLabel = new Label(); private Label settingsMTLabel = new Label(); private Label settingsTALabel = new Label(); private Label settingsDMLabel = new Label(); private Label settingsSSLabel = new Label(); private Label settingsMMLabel = new Label(); // list boxes private ListBox asrList1 = new ListBox(); private ListBox mtList1 = new ListBox(); private ListBox taList1 = new ListBox(); private ListBox dmList1 = new ListBox(); private ListBox ssList1 = new ListBox(); private ListBox mmList1 = new ListBox(); private ListBox asrList2 = new ListBox(); private ListBox mtList2 = new ListBox(); private ListBox taList2 = new ListBox(); private ListBox dmList2 = new ListBox(); private ListBox ssList2 = new ListBox(); private ListBox mmList2 = new ListBox(); // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/server/WizardComp.java
// Path: webwozwizard/src/com/webwoz/wizard/server/components/WizardDefault.java // public class WizardDefault extends WizardComp { // // public WizardDefault(int mode) { // super.setMode(mode); // super.setName("Default"); // } // // }
import com.webwoz.wizard.server.components.WizardDefault;
package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class WizardComp implements Component { // variables private final int type = 0; private final String typeName = "Wizard"; private String name; private int mode; public int getType() { return type; } public String printType() { return typeName; } public String getOutput(String input) { return input; } public Component getComponent(int comp, int mode) { // instantiate the right Wizard component switch (comp) { case 0:
// Path: webwozwizard/src/com/webwoz/wizard/server/components/WizardDefault.java // public class WizardDefault extends WizardComp { // // public WizardDefault(int mode) { // super.setMode(mode); // super.setName("Default"); // } // // } // Path: webwozwizard/src/com/webwoz/wizard/server/WizardComp.java import com.webwoz.wizard.server.components.WizardDefault; package com.webwoz.wizard.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class WizardComp implements Component { // variables private final int type = 0; private final String typeName = "Wizard"; private String name; private int mode; public int getType() { return type; } public String printType() { return typeName; } public String getOutput(String input) { return input; } public Component getComponent(int comp, int mode) { // instantiate the right Wizard component switch (comp) { case 0:
return new WizardDefault(mode);
stephanschloegl/WebWOZ
webwozclient/src/com/webwoz/client/server/DatabaseAccessImpl.java
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // }
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.client.client.DatabaseAccess;
package com.webwoz.client.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements
// Path: webwozclient/src/com/webwoz/client/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // void storeData(String sql); // // String[][] retrieveData(String sql); // // String getDateTime(); // // void closeConnection(); // // } // Path: webwozclient/src/com/webwoz/client/server/DatabaseAccessImpl.java import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.webwoz.client.client.DatabaseAccess; package com.webwoz.client.server; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @SuppressWarnings("serial") public class DatabaseAccessImpl extends RemoteServiceServlet implements
DatabaseAccess {
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // }
import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label;
private HandlerRegistration[] addToFreeClickHandlerRegistration; private HandlerRegistration[] addDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] editDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] saveTabClickHandlerRegistration; private HandlerRegistration[] delTabClickHandlerRegistration; private HandlerRegistration[] editSlotHandlerRegistration; private HandlerRegistration[][] slotRadioButtonHandlerRegistration; private HandlerRegistration[] changeSlotValueHandlerRegistration; private HandlerRegistration[] deleteSlotValueHandlerRegistration; private HandlerRegistration[] addFreeTextHandlerRegistration; private HandlerRegistration[] editFreeTextHandlerRegistration; private HandlerRegistration[] uttButtUpClickHandlerRegistration; private HandlerRegistration[] uttButtDownClickHandlerRegistration; // Pop-ups private EditUtterancesPopup editUtterancesPopup; private EditDomainDataPopUp editDomainDataPopup; private EditTabsPopup editTabsPopup; private PrintReportPopup printReportPopup; private EditSlotPopUp editSlotPopUp; private AddSlotPopUp addSlotPopUp; private EditPreparedFreeTextPopup editFreeTextPopUp; // HTML private HTML reportTable; private HTML reportHeadingTable; private HTML statusHtml; private HTML loggedInHtml; // RPC
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; private HandlerRegistration[] addToFreeClickHandlerRegistration; private HandlerRegistration[] addDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] editDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] saveTabClickHandlerRegistration; private HandlerRegistration[] delTabClickHandlerRegistration; private HandlerRegistration[] editSlotHandlerRegistration; private HandlerRegistration[][] slotRadioButtonHandlerRegistration; private HandlerRegistration[] changeSlotValueHandlerRegistration; private HandlerRegistration[] deleteSlotValueHandlerRegistration; private HandlerRegistration[] addFreeTextHandlerRegistration; private HandlerRegistration[] editFreeTextHandlerRegistration; private HandlerRegistration[] uttButtUpClickHandlerRegistration; private HandlerRegistration[] uttButtDownClickHandlerRegistration; // Pop-ups private EditUtterancesPopup editUtterancesPopup; private EditDomainDataPopUp editDomainDataPopup; private EditTabsPopup editTabsPopup; private PrintReportPopup printReportPopup; private EditSlotPopUp editSlotPopUp; private AddSlotPopUp addSlotPopUp; private EditPreparedFreeTextPopup editFreeTextPopUp; // HTML private HTML reportTable; private HTML reportHeadingTable; private HTML statusHtml; private HTML loggedInHtml; // RPC
private DatabaseAccessAsync databaseAccessSvc;
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // }
import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label;
private HandlerRegistration[] addDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] editDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] saveTabClickHandlerRegistration; private HandlerRegistration[] delTabClickHandlerRegistration; private HandlerRegistration[] editSlotHandlerRegistration; private HandlerRegistration[][] slotRadioButtonHandlerRegistration; private HandlerRegistration[] changeSlotValueHandlerRegistration; private HandlerRegistration[] deleteSlotValueHandlerRegistration; private HandlerRegistration[] addFreeTextHandlerRegistration; private HandlerRegistration[] editFreeTextHandlerRegistration; private HandlerRegistration[] uttButtUpClickHandlerRegistration; private HandlerRegistration[] uttButtDownClickHandlerRegistration; // Pop-ups private EditUtterancesPopup editUtterancesPopup; private EditDomainDataPopUp editDomainDataPopup; private EditTabsPopup editTabsPopup; private PrintReportPopup printReportPopup; private EditSlotPopUp editSlotPopUp; private AddSlotPopUp addSlotPopUp; private EditPreparedFreeTextPopup editFreeTextPopUp; // HTML private HTML reportTable; private HTML reportHeadingTable; private HTML statusHtml; private HTML loggedInHtml; // RPC private DatabaseAccessAsync databaseAccessSvc;
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; private HandlerRegistration[] addDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] editDomainUtteranceClickHandlerRegistration; private HandlerRegistration[] saveTabClickHandlerRegistration; private HandlerRegistration[] delTabClickHandlerRegistration; private HandlerRegistration[] editSlotHandlerRegistration; private HandlerRegistration[][] slotRadioButtonHandlerRegistration; private HandlerRegistration[] changeSlotValueHandlerRegistration; private HandlerRegistration[] deleteSlotValueHandlerRegistration; private HandlerRegistration[] addFreeTextHandlerRegistration; private HandlerRegistration[] editFreeTextHandlerRegistration; private HandlerRegistration[] uttButtUpClickHandlerRegistration; private HandlerRegistration[] uttButtDownClickHandlerRegistration; // Pop-ups private EditUtterancesPopup editUtterancesPopup; private EditDomainDataPopUp editDomainDataPopup; private EditTabsPopup editTabsPopup; private PrintReportPopup printReportPopup; private EditSlotPopUp editSlotPopUp; private AddSlotPopUp addSlotPopUp; private EditPreparedFreeTextPopup editFreeTextPopUp; // HTML private HTML reportTable; private HTML reportHeadingTable; private HTML statusHtml; private HTML loggedInHtml; // RPC private DatabaseAccessAsync databaseAccessSvc;
private ComponentFactoryAsync componentFactorySvc;
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // }
import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label;
addDomainDataButton = new Button("Add Domain Data"); addFilterButton = new Button("Add Filter"); saveNotesButton = new Button("Save"); editFilterSaveButton = new Button("Save Changes"); editFilterDeleteButton = new Button("Delete Filter"); printReportButton = new Button("Print Report"); exportReportButton = new Button("Export Report"); exportNotesButton = new Button("Export Notes"); changeUttDomainEditButton = new Button("Save Changes"); addUttDomainEditButton = new Button("Add Utterance"); cancelUttDomainEditButton = new Button("Close"); deleteUttDomainEditButton = new Button("Delete Utterance"); cancelEditSlotPopUpButton = new Button("Close"); editFilterAddSlotButton = new Button("Add Filter Value"); cancelAddSlotPopUpButton = new Button("Close"); addFilterSaveButton = new Button("Add Filter"); addFilterValueButton = new Button("Add Value"); sendFreeTextButton = new Button("Send"); addFreeTextButton = new Button("Add Free Text Element"); closeFreeTextButton = new Button("Close"); editFreeTextButton = new Button("Save Changes"); deleteFreeTextButton = new Button("Delete Element"); // HTML reportTable = new HTML(); reportHeadingTable = new HTML(); statusHtml = new HTML(); loggedInHtml = new HTML(); // RPC
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; addDomainDataButton = new Button("Add Domain Data"); addFilterButton = new Button("Add Filter"); saveNotesButton = new Button("Save"); editFilterSaveButton = new Button("Save Changes"); editFilterDeleteButton = new Button("Delete Filter"); printReportButton = new Button("Print Report"); exportReportButton = new Button("Export Report"); exportNotesButton = new Button("Export Notes"); changeUttDomainEditButton = new Button("Save Changes"); addUttDomainEditButton = new Button("Add Utterance"); cancelUttDomainEditButton = new Button("Close"); deleteUttDomainEditButton = new Button("Delete Utterance"); cancelEditSlotPopUpButton = new Button("Close"); editFilterAddSlotButton = new Button("Add Filter Value"); cancelAddSlotPopUpButton = new Button("Close"); addFilterSaveButton = new Button("Add Filter"); addFilterValueButton = new Button("Add Value"); sendFreeTextButton = new Button("Send"); addFreeTextButton = new Button("Add Free Text Element"); closeFreeTextButton = new Button("Close"); editFreeTextButton = new Button("Save Changes"); deleteFreeTextButton = new Button("Delete Element"); // HTML reportTable = new HTML(); reportHeadingTable = new HTML(); statusHtml = new HTML(); loggedInHtml = new HTML(); // RPC
databaseAccessSvc = GWT.create(DatabaseAccess.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // }
import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label;
addFilterButton = new Button("Add Filter"); saveNotesButton = new Button("Save"); editFilterSaveButton = new Button("Save Changes"); editFilterDeleteButton = new Button("Delete Filter"); printReportButton = new Button("Print Report"); exportReportButton = new Button("Export Report"); exportNotesButton = new Button("Export Notes"); changeUttDomainEditButton = new Button("Save Changes"); addUttDomainEditButton = new Button("Add Utterance"); cancelUttDomainEditButton = new Button("Close"); deleteUttDomainEditButton = new Button("Delete Utterance"); cancelEditSlotPopUpButton = new Button("Close"); editFilterAddSlotButton = new Button("Add Filter Value"); cancelAddSlotPopUpButton = new Button("Close"); addFilterSaveButton = new Button("Add Filter"); addFilterValueButton = new Button("Add Value"); sendFreeTextButton = new Button("Send"); addFreeTextButton = new Button("Add Free Text Element"); closeFreeTextButton = new Button("Close"); editFreeTextButton = new Button("Save Changes"); deleteFreeTextButton = new Button("Delete Element"); // HTML reportTable = new HTML(); reportHeadingTable = new HTML(); statusHtml = new HTML(); loggedInHtml = new HTML(); // RPC databaseAccessSvc = GWT.create(DatabaseAccess.class);
// Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactory.java // @RemoteServiceRelativePath("componentFactory") // public interface ComponentFactory extends RemoteService { // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz); // // String pushOutput(String output, int user, String mode); // // Vector<String> getInput(String input, String uttid, String mode); // // void clearComponents(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/ComponentFactoryAsync.java // public interface ComponentFactoryAsync { // // void clearComponents(AsyncCallback<Void> callback); // // void pushComponents(int[][] components, int expid, String path, // String ssLang, String mtsrc, String mttrg, String mtosrc, // String mtotrg, String asrl, int wiz, AsyncCallback<Void> callback); // // void pushOutput(String output, int user, String mode, // AsyncCallback<String> callback); // // void getInput(String input, String uttid, String mode, // AsyncCallback<Vector<String>> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccessAsync.java // public interface DatabaseAccessAsync { // // void storeData(String sql, AsyncCallback<String> callback); // // void retrieveData(String sql, AsyncCallback<String[][]> callback); // // void getTimeStamp(AsyncCallback<String> callback); // // void closeConnection(AsyncCallback<Void> callback); // // } // // Path: webwozwizard/src/com/webwoz/wizard/client/Screen.java // public interface Screen { // VerticalPanel getScreen(); // // void stopReload(); // // void changeVisibility(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/wizardlayouts/DefaultWizardScreen.java import java.util.Date; import java.util.Vector; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.webwoz.wizard.client.ComponentFactory; import com.webwoz.wizard.client.ComponentFactoryAsync; import com.webwoz.wizard.client.DatabaseAccess; import com.webwoz.wizard.client.DatabaseAccessAsync; import com.webwoz.wizard.client.Screen; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; addFilterButton = new Button("Add Filter"); saveNotesButton = new Button("Save"); editFilterSaveButton = new Button("Save Changes"); editFilterDeleteButton = new Button("Delete Filter"); printReportButton = new Button("Print Report"); exportReportButton = new Button("Export Report"); exportNotesButton = new Button("Export Notes"); changeUttDomainEditButton = new Button("Save Changes"); addUttDomainEditButton = new Button("Add Utterance"); cancelUttDomainEditButton = new Button("Close"); deleteUttDomainEditButton = new Button("Delete Utterance"); cancelEditSlotPopUpButton = new Button("Close"); editFilterAddSlotButton = new Button("Add Filter Value"); cancelAddSlotPopUpButton = new Button("Close"); addFilterSaveButton = new Button("Add Filter"); addFilterValueButton = new Button("Add Value"); sendFreeTextButton = new Button("Send"); addFreeTextButton = new Button("Add Free Text Element"); closeFreeTextButton = new Button("Close"); editFreeTextButton = new Button("Save Changes"); deleteFreeTextButton = new Button("Delete Element"); // HTML reportTable = new HTML(); reportHeadingTable = new HTML(); statusHtml = new HTML(); loggedInHtml = new HTML(); // RPC databaseAccessSvc = GWT.create(DatabaseAccess.class);
componentFactorySvc = GWT.create(ComponentFactory.class);
stephanschloegl/WebWOZ
webwozwizard/src/com/webwoz/wizard/client/SettingsASR.java
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // }
import com.webwoz.wizard.client.DatabaseAccess; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.VerticalPanel;
package com.webwoz.wizard.client; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class SettingsASR implements Screen { private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel settingsPanel = new VerticalPanel(); private HorizontalPanel asrPanel = new HorizontalPanel(); private CheckBox asrChk = new CheckBox("ASR"); private CheckBox textInChk = new CheckBox("Text "); private ListBox asrLangList = new ListBox(); private Label langLabel = new Label("Recognition Language"); private ListBox corrList = new ListBox(); private Label corrLabel = new Label("Correction Mode"); private int compID; // other variables private int expId; private int[][] components; private String mediapath; private String ssLang; private String mtSrc; private String mtTrg; private String mtoSrc; private String mtoTrg; private String asrLang; private int wiz; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
// Path: webwozwizard/src/com/webwoz/wizard/client/DatabaseAccess.java // @RemoteServiceRelativePath("databaseAccess") // public interface DatabaseAccess extends RemoteService { // // String storeData(String sql); // // String[][] retrieveData(String sql); // // String getTimeStamp(); // // void closeConnection(); // // } // Path: webwozwizard/src/com/webwoz/wizard/client/SettingsASR.java import com.webwoz.wizard.client.DatabaseAccess; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.VerticalPanel; package com.webwoz.wizard.client; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class SettingsASR implements Screen { private VerticalPanel layoutPanel = new VerticalPanel(); private VerticalPanel settingsPanel = new VerticalPanel(); private HorizontalPanel asrPanel = new HorizontalPanel(); private CheckBox asrChk = new CheckBox("ASR"); private CheckBox textInChk = new CheckBox("Text "); private ListBox asrLangList = new ListBox(); private Label langLabel = new Label("Recognition Language"); private ListBox corrList = new ListBox(); private Label corrLabel = new Label("Correction Mode"); private int compID; // other variables private int expId; private int[][] components; private String mediapath; private String ssLang; private String mtSrc; private String mtTrg; private String mtoSrc; private String mtoTrg; private String asrLang; private int wiz; // RPC private DatabaseAccessAsync databaseAccessSvc = GWT
.create(DatabaseAccess.class);
ieee8023/PDFViewer
src/org/ebookdroid/ui/library/adapters/BookShelfAdapter.java
// Path: src/org/ebookdroid/ui/library/adapters/BooksAdapter.java // public static class ViewHolder extends BaseViewHolder { // // ImageView imageView; // TextView textView; // // @Override // public void init(final View convertView) { // super.init(convertView); // this.imageView = (ImageView) convertView.findViewById(R.id.thumbnailImage); // this.textView = (TextView) convertView.findViewById(R.id.thumbnailText); // } // }
import org.ebookdroid.ui.library.IBrowserActivity; import org.ebookdroid.ui.library.adapters.BooksAdapter.ViewHolder; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import the.pdfviewer3.R; import java.util.ArrayList; import java.util.IdentityHashMap; import java.util.List; import org.emdev.ui.adapters.BaseViewHolder; import org.emdev.utils.FileUtils; import org.emdev.utils.StringUtils;
public final String mpath; final List<BookNode> nodes = new ArrayList<BookNode>(); public boolean measuring = false; public BookShelfAdapter(final IBrowserActivity base, final int index, final String name, final String path) { this.base = base; this.id = index; this.name = name; this.path = path; this.mpath = FileUtils.invertMountPrefix(path); } @Override public int getCount() { return nodes.size(); } @Override public Object getItem(final int position) { return nodes.get(position); } @Override public long getItemId(final int position) { return position; } @Override public View getView(final int position, final View view, final ViewGroup parent) {
// Path: src/org/ebookdroid/ui/library/adapters/BooksAdapter.java // public static class ViewHolder extends BaseViewHolder { // // ImageView imageView; // TextView textView; // // @Override // public void init(final View convertView) { // super.init(convertView); // this.imageView = (ImageView) convertView.findViewById(R.id.thumbnailImage); // this.textView = (TextView) convertView.findViewById(R.id.thumbnailText); // } // } // Path: src/org/ebookdroid/ui/library/adapters/BookShelfAdapter.java import org.ebookdroid.ui.library.IBrowserActivity; import org.ebookdroid.ui.library.adapters.BooksAdapter.ViewHolder; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import the.pdfviewer3.R; import java.util.ArrayList; import java.util.IdentityHashMap; import java.util.List; import org.emdev.ui.adapters.BaseViewHolder; import org.emdev.utils.FileUtils; import org.emdev.utils.StringUtils; public final String mpath; final List<BookNode> nodes = new ArrayList<BookNode>(); public boolean measuring = false; public BookShelfAdapter(final IBrowserActivity base, final int index, final String name, final String path) { this.base = base; this.id = index; this.name = name; this.path = path; this.mpath = FileUtils.invertMountPrefix(path); } @Override public int getCount() { return nodes.size(); } @Override public Object getItem(final int position) { return nodes.get(position); } @Override public long getItemId(final int position) { return position; } @Override public View getView(final int position, final View view, final ViewGroup parent) {
final ViewHolder holder = BaseViewHolder.getOrCreateViewHolder(ViewHolder.class, R.layout.thumbnail, view,
ieee8023/PDFViewer
src/org/ebookdroid/common/cache/ThumbnailFile.java
// Path: src/org/ebookdroid/common/cache/CacheManager.java // public static interface ICacheListener { // // void onThumbnailChanged(ThumbnailFile tf); // // }
import org.ebookdroid.common.bitmaps.BitmapManager; import org.ebookdroid.common.cache.CacheManager.ICacheListener; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; import the.pdfviewer3.R; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; import org.emdev.ui.tasks.AsyncTask; import org.emdev.ui.tasks.AsyncTaskExecutor;
listener = l; executor.execute(new LoadingTask()); } protected synchronized void onImageLoaded(final Bitmap result) { ref.set(result); if (listener != null) { listener.onImageLoaded(result); } } public Bitmap getRawImage() { Bitmap bitmap = ref.get(); if (bitmap == null || bitmap.isRecycled()) { try { bitmap = load(true); ref.set(bitmap); } catch (final OutOfMemoryError ex) { } } return bitmap; } public void setImage(final Bitmap image) { if (image != null) { ref.set(paint(image)); store(image); } else { this.delete(); }
// Path: src/org/ebookdroid/common/cache/CacheManager.java // public static interface ICacheListener { // // void onThumbnailChanged(ThumbnailFile tf); // // } // Path: src/org/ebookdroid/common/cache/ThumbnailFile.java import org.ebookdroid.common.bitmaps.BitmapManager; import org.ebookdroid.common.cache.CacheManager.ICacheListener; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; import the.pdfviewer3.R; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; import org.emdev.ui.tasks.AsyncTask; import org.emdev.ui.tasks.AsyncTaskExecutor; listener = l; executor.execute(new LoadingTask()); } protected synchronized void onImageLoaded(final Bitmap result) { ref.set(result); if (listener != null) { listener.onImageLoaded(result); } } public Bitmap getRawImage() { Bitmap bitmap = ref.get(); if (bitmap == null || bitmap.isRecycled()) { try { bitmap = load(true); ref.set(bitmap); } catch (final OutOfMemoryError ex) { } } return bitmap; } public void setImage(final Bitmap image) { if (image != null) { ref.set(paint(image)); store(image); } else { this.delete(); }
final ICacheListener l = CacheManager.listeners.getListener();
ieee8023/PDFViewer
src/org/ebookdroid/common/bitmaps/GLBitmaps.java
// Path: src/org/emdev/utils/MathUtils.java // public class MathUtils { // // public static int adjust(final int value, final int min, final int max) { // return Math.min(Math.max(min, value), max); // } // // public static float adjust(final float value, final float min, final float max) { // return Math.min(Math.max(min, value), max); // } // // public static Rect rect(final RectF rect) { // return new Rect((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom); // } // // public static Rect rect(final float left, final float top, final float right, final float bottom) { // return new Rect((int) left, (int) top, (int) right, (int) bottom); // } // // public static RectF zoom(final RectF rect, final float zoom) { // return new RectF(zoom * rect.left, zoom * rect.top, zoom * rect.right, zoom * rect.bottom); // } // // public static void zoom(final RectF rect, final float zoom, final RectF target) { // target.left = rect.left * zoom; // target.right = rect.right * zoom; // target.top = rect.top * zoom; // target.bottom = rect.bottom * zoom; // } // // public static RectF zoom(final Rect rect, final float zoom) { // return new RectF(zoom * rect.left, zoom * rect.top, zoom * rect.right, zoom * rect.bottom); // } // // public static Rect zoom(final float left, final float top, final float right, final float bottom, final float zoom) { // return new Rect((int) (zoom * left), (int) (zoom * top), (int) (zoom * right), (int) (zoom * bottom)); // } // // public static int min(final int... values) { // int min = Integer.MAX_VALUE; // for (final int v : values) { // min = Math.min(v, min); // } // return min; // } // // public static int max(final int... values) { // int max = Integer.MIN_VALUE; // for (final int v : values) { // max = Math.max(v, max); // } // return max; // } // // public static float fmin(final float... values) { // float min = Float.MAX_VALUE; // for (final float v : values) { // min = Math.min(v, min); // } // return min; // } // // public static float fmax(final float... values) { // float max = Float.MIN_VALUE; // for (final float v : values) { // max = Math.max(v, max); // } // return max; // } // // public static float round(final float value, final float share) { // return (float) Math.floor(value * share) / share; // } // // public static RectF round(final RectF rect, final float share) { // rect.left = (float) Math.floor(rect.left * share) / share; // rect.top = (float) Math.floor(rect.top * share) / share; // rect.right = (float) Math.floor(rect.right * share) / share; // rect.bottom = (float) Math.floor(rect.bottom * share) / share; // return rect; // } // // public static RectF floor(final RectF rect) { // rect.left = (float) Math.floor(rect.left); // rect.top = (float) Math.floor(rect.top); // rect.right = (float) Math.floor(rect.right); // rect.bottom = (float) Math.floor(rect.bottom); // return rect; // } // // public static RectF ceil(final RectF rect) { // rect.left = (float) Math.ceil(rect.left); // rect.top = (float) Math.ceil(rect.top); // rect.right = (float) Math.ceil(rect.right); // rect.bottom = (float) Math.ceil(rect.bottom); // return rect; // } // // public static RectF round(final RectF rect) { // rect.left = (float) Math.floor(rect.left); // rect.top = (float) Math.floor(rect.top); // rect.right = (float) Math.ceil(rect.right); // rect.bottom = (float) Math.ceil(rect.bottom); // return rect; // } // // public static int nextPowerOf2(int n) { // if (n <= 0 || n > (1 << 30)) { // throw new IllegalArgumentException(); // } // n -= 1; // n |= n >> 16; // n |= n >> 8; // n |= n >> 4; // n |= n >> 2; // n |= n >> 1; // return n + 1; // } // // public static int prevPowerOf2(final int n) { // if (n <= 0) { // throw new IllegalArgumentException(); // } // return Integer.highestOneBit(n); // } // // public static boolean isOpaque(final int color) { // return color >>> 24 == 0xFF; // } // }
import org.ebookdroid.core.PagePaint; import android.graphics.PointF; import android.graphics.RectF; import android.util.FloatMath; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.emdev.common.log.LogContext; import org.emdev.common.log.LogManager; import org.emdev.ui.gl.GLCanvas; import org.emdev.utils.MathUtils;
} } } } private static int getPartCount(final int size, final int partSize) { if (size % partSize == 0) { return size / partSize; } return (int) Math.ceil(size / (float) partSize); } public boolean drawGL(final GLCanvas canvas, final PagePaint paint, final PointF vb, final RectF tr, final RectF cr) { lock.writeLock().lock(); try { if (textures == null) { if (this.bitmaps == null) { return false; } textures = new ByteBufferTexture[columns * rows]; for (int i = 0; i < textures.length; i++) { textures[i] = new ByteBufferTexture(bitmaps[i]); } } if (LCTX.isDebugEnabled()) { LCTX.d(nodeId + ".drawGL(): >>>>"); } final RectF actual = new RectF(cr.left - vb.x, cr.top - vb.y, cr.right - vb.x, cr.bottom - vb.y);
// Path: src/org/emdev/utils/MathUtils.java // public class MathUtils { // // public static int adjust(final int value, final int min, final int max) { // return Math.min(Math.max(min, value), max); // } // // public static float adjust(final float value, final float min, final float max) { // return Math.min(Math.max(min, value), max); // } // // public static Rect rect(final RectF rect) { // return new Rect((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom); // } // // public static Rect rect(final float left, final float top, final float right, final float bottom) { // return new Rect((int) left, (int) top, (int) right, (int) bottom); // } // // public static RectF zoom(final RectF rect, final float zoom) { // return new RectF(zoom * rect.left, zoom * rect.top, zoom * rect.right, zoom * rect.bottom); // } // // public static void zoom(final RectF rect, final float zoom, final RectF target) { // target.left = rect.left * zoom; // target.right = rect.right * zoom; // target.top = rect.top * zoom; // target.bottom = rect.bottom * zoom; // } // // public static RectF zoom(final Rect rect, final float zoom) { // return new RectF(zoom * rect.left, zoom * rect.top, zoom * rect.right, zoom * rect.bottom); // } // // public static Rect zoom(final float left, final float top, final float right, final float bottom, final float zoom) { // return new Rect((int) (zoom * left), (int) (zoom * top), (int) (zoom * right), (int) (zoom * bottom)); // } // // public static int min(final int... values) { // int min = Integer.MAX_VALUE; // for (final int v : values) { // min = Math.min(v, min); // } // return min; // } // // public static int max(final int... values) { // int max = Integer.MIN_VALUE; // for (final int v : values) { // max = Math.max(v, max); // } // return max; // } // // public static float fmin(final float... values) { // float min = Float.MAX_VALUE; // for (final float v : values) { // min = Math.min(v, min); // } // return min; // } // // public static float fmax(final float... values) { // float max = Float.MIN_VALUE; // for (final float v : values) { // max = Math.max(v, max); // } // return max; // } // // public static float round(final float value, final float share) { // return (float) Math.floor(value * share) / share; // } // // public static RectF round(final RectF rect, final float share) { // rect.left = (float) Math.floor(rect.left * share) / share; // rect.top = (float) Math.floor(rect.top * share) / share; // rect.right = (float) Math.floor(rect.right * share) / share; // rect.bottom = (float) Math.floor(rect.bottom * share) / share; // return rect; // } // // public static RectF floor(final RectF rect) { // rect.left = (float) Math.floor(rect.left); // rect.top = (float) Math.floor(rect.top); // rect.right = (float) Math.floor(rect.right); // rect.bottom = (float) Math.floor(rect.bottom); // return rect; // } // // public static RectF ceil(final RectF rect) { // rect.left = (float) Math.ceil(rect.left); // rect.top = (float) Math.ceil(rect.top); // rect.right = (float) Math.ceil(rect.right); // rect.bottom = (float) Math.ceil(rect.bottom); // return rect; // } // // public static RectF round(final RectF rect) { // rect.left = (float) Math.floor(rect.left); // rect.top = (float) Math.floor(rect.top); // rect.right = (float) Math.ceil(rect.right); // rect.bottom = (float) Math.ceil(rect.bottom); // return rect; // } // // public static int nextPowerOf2(int n) { // if (n <= 0 || n > (1 << 30)) { // throw new IllegalArgumentException(); // } // n -= 1; // n |= n >> 16; // n |= n >> 8; // n |= n >> 4; // n |= n >> 2; // n |= n >> 1; // return n + 1; // } // // public static int prevPowerOf2(final int n) { // if (n <= 0) { // throw new IllegalArgumentException(); // } // return Integer.highestOneBit(n); // } // // public static boolean isOpaque(final int color) { // return color >>> 24 == 0xFF; // } // } // Path: src/org/ebookdroid/common/bitmaps/GLBitmaps.java import org.ebookdroid.core.PagePaint; import android.graphics.PointF; import android.graphics.RectF; import android.util.FloatMath; import java.util.concurrent.locks.ReentrantReadWriteLock; import org.emdev.common.log.LogContext; import org.emdev.common.log.LogManager; import org.emdev.ui.gl.GLCanvas; import org.emdev.utils.MathUtils; } } } } private static int getPartCount(final int size, final int partSize) { if (size % partSize == 0) { return size / partSize; } return (int) Math.ceil(size / (float) partSize); } public boolean drawGL(final GLCanvas canvas, final PagePaint paint, final PointF vb, final RectF tr, final RectF cr) { lock.writeLock().lock(); try { if (textures == null) { if (this.bitmaps == null) { return false; } textures = new ByteBufferTexture[columns * rows]; for (int i = 0; i < textures.length; i++) { textures[i] = new ByteBufferTexture(bitmaps[i]); } } if (LCTX.isDebugEnabled()) { LCTX.d(nodeId + ".drawGL(): >>>>"); } final RectF actual = new RectF(cr.left - vb.x, cr.top - vb.y, cr.right - vb.x, cr.bottom - vb.y);
MathUtils.round(actual);
ieee8023/PDFViewer
src/org/ebookdroid/core/curl/PageAnimationType.java
// Path: src/the/pdfviewer3/EBookDroidApp.java // public class EBookDroidApp extends BaseDroidApp implements IAppSettingsChangeListener, IBackupSettingsChangeListener, // ILibSettingsChangeListener { // // public static final Flag initialized = new Flag(); // // public static EBookDroidVersion version; // // private static EBookDroidApp instance; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // instance = this; // version = EBookDroidVersion.get(APP_VERSION_CODE); // // SettingsManager.init(this); // CacheManager.init(this); // MediaManager.init(this); // // initFonts(); // // preallocateHeap(AppSettings.current().heapPreallocate); // // SettingsManager.addListener(this); // onAppSettingsChanged(null, AppSettings.current(), null); // onBackupSettingsChanged(null, BackupSettings.current(), null); // // GLConfiguration.stencilRequired = !IS_EMULATOR; // // initialized.set(); // } // // public static void initFonts() { // FontManager.init(APP_STORAGE); // } // // @Override // public void onTerminate() { // SettingsManager.onTerminate(); // MediaManager.onTerminate(this); // } // // /** // * {@inheritDoc} // * // * @see android.app.Application#onLowMemory() // */ // @Override // public void onLowMemory() { // super.onLowMemory(); // BitmapManager.clear("on Low Memory: "); // ByteBufferManager.clear("on Low Memory: "); // } // // @Override // public void onAppSettingsChanged(final AppSettings oldSettings, final AppSettings newSettings, // final AppSettings.Diff diff) { // // ByteBufferManager.setPartSize(1 << newSettings.bitmapSize); // // setAppLocale(newSettings.lang); // } // // @Override // public void onBackupSettingsChanged(final BackupSettings oldSettings, final BackupSettings newSettings, // final BackupSettings.Diff diff) { // BackupManager.setMaxNumberOfAutoBackups(newSettings.maxNumberOfAutoBackups); // } // // @Override // public void onLibSettingsChanged(final LibSettings oldSettings, final LibSettings newSettings, final Diff diff) { // if (diff.isCacheLocationChanged()) { // CacheManager.setCacheLocation(newSettings.cacheLocation, !diff.isFirstTime()); // } // } // // public static void checkInstalledFonts(final Context context) { // // if (!FontManager.external.hasInstalled()) { // // if (!SettingsManager.isInitialFlagsSet(SettingsManager.INITIAL_FONTS)) { // // SettingsManager.setInitialFlags(SettingsManager.INITIAL_FONTS); // // // // final ActionDialogBuilder b = new ActionDialogBuilder(context, new ActionController<Context>(context)); // // final WebView view = new WebView(context); // // // // final String text = context.getResources().getString(R.string.font_reminder); // // final String content = "<html><body>" + text + "</body></html>"; // // // // view.loadDataWithBaseURL("file:///fake/not_used", content, "text/html", "UTF-8", ""); // // // // b.setTitle(R.string.font_reminder_title); // // b.setView(view); // // b.setPositiveButton(android.R.string.ok, R.id.actions_no_action); // // b.show(); // // } // // } // } // // public static void onActivityClose(final boolean finishing) { // if (finishing && !SettingsManager.hasOpenedBooks() && !RecentActivityController.working.get()) { // if (instance != null) { // instance.onTerminate(); // } // Log.i(APP_NAME, "Application finished"); // System.exit(0); // } // } // // /** // * Preallocate heap. // * // * @param size // * the size in megabytes // * @return the object // */ // private static Object preallocateHeap(final int size) { // if (size <= 0) { // Log.i(APP_NAME, "No heap preallocation"); // return null; // } // int i = size; // Log.i(APP_NAME, "Trying to preallocate " + size + "Mb"); // while (i > 0) { // try { // byte[] tmp = new byte[i * 1024 * 1024]; // tmp[size - 1] = (byte) size; // Log.i(APP_NAME, "Preallocated " + i + "Mb"); // tmp = null; // return tmp; // } catch (final OutOfMemoryError e) { // i--; // } catch (final IllegalArgumentException e) { // i--; // } // } // Log.i(APP_NAME, "Heap preallocation failed"); // return null; // } // // }
import org.ebookdroid.core.SinglePageController; import org.emdev.utils.enums.ResourceConstant; import the.pdfviewer3.EBookDroidApp; import the.pdfviewer3.R;
package org.ebookdroid.core.curl; public enum PageAnimationType implements ResourceConstant { NONE(R.string.pref_animation_type_none, true), CURLER(R.string.pref_animation_type_curler_simple, false), CURLER_DYNAMIC(R.string.pref_animation_type_curler_dynamic, false), SLIDER(R.string.pref_animation_type_slider, true), SLIDER2(R.string.pref_animation_type_slider2, true), FADER(R.string.pref_animation_type_fader, true), SQUEEZER(R.string.pref_animation_type_squeezer, true); /** The resource value. */ private final String resValue; private final boolean hardwareAccelSupported; /** * Instantiates a new page animation type. * * @param resValue * the res value */ private PageAnimationType(final int resId, final boolean hardwareAccelSupported) {
// Path: src/the/pdfviewer3/EBookDroidApp.java // public class EBookDroidApp extends BaseDroidApp implements IAppSettingsChangeListener, IBackupSettingsChangeListener, // ILibSettingsChangeListener { // // public static final Flag initialized = new Flag(); // // public static EBookDroidVersion version; // // private static EBookDroidApp instance; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // instance = this; // version = EBookDroidVersion.get(APP_VERSION_CODE); // // SettingsManager.init(this); // CacheManager.init(this); // MediaManager.init(this); // // initFonts(); // // preallocateHeap(AppSettings.current().heapPreallocate); // // SettingsManager.addListener(this); // onAppSettingsChanged(null, AppSettings.current(), null); // onBackupSettingsChanged(null, BackupSettings.current(), null); // // GLConfiguration.stencilRequired = !IS_EMULATOR; // // initialized.set(); // } // // public static void initFonts() { // FontManager.init(APP_STORAGE); // } // // @Override // public void onTerminate() { // SettingsManager.onTerminate(); // MediaManager.onTerminate(this); // } // // /** // * {@inheritDoc} // * // * @see android.app.Application#onLowMemory() // */ // @Override // public void onLowMemory() { // super.onLowMemory(); // BitmapManager.clear("on Low Memory: "); // ByteBufferManager.clear("on Low Memory: "); // } // // @Override // public void onAppSettingsChanged(final AppSettings oldSettings, final AppSettings newSettings, // final AppSettings.Diff diff) { // // ByteBufferManager.setPartSize(1 << newSettings.bitmapSize); // // setAppLocale(newSettings.lang); // } // // @Override // public void onBackupSettingsChanged(final BackupSettings oldSettings, final BackupSettings newSettings, // final BackupSettings.Diff diff) { // BackupManager.setMaxNumberOfAutoBackups(newSettings.maxNumberOfAutoBackups); // } // // @Override // public void onLibSettingsChanged(final LibSettings oldSettings, final LibSettings newSettings, final Diff diff) { // if (diff.isCacheLocationChanged()) { // CacheManager.setCacheLocation(newSettings.cacheLocation, !diff.isFirstTime()); // } // } // // public static void checkInstalledFonts(final Context context) { // // if (!FontManager.external.hasInstalled()) { // // if (!SettingsManager.isInitialFlagsSet(SettingsManager.INITIAL_FONTS)) { // // SettingsManager.setInitialFlags(SettingsManager.INITIAL_FONTS); // // // // final ActionDialogBuilder b = new ActionDialogBuilder(context, new ActionController<Context>(context)); // // final WebView view = new WebView(context); // // // // final String text = context.getResources().getString(R.string.font_reminder); // // final String content = "<html><body>" + text + "</body></html>"; // // // // view.loadDataWithBaseURL("file:///fake/not_used", content, "text/html", "UTF-8", ""); // // // // b.setTitle(R.string.font_reminder_title); // // b.setView(view); // // b.setPositiveButton(android.R.string.ok, R.id.actions_no_action); // // b.show(); // // } // // } // } // // public static void onActivityClose(final boolean finishing) { // if (finishing && !SettingsManager.hasOpenedBooks() && !RecentActivityController.working.get()) { // if (instance != null) { // instance.onTerminate(); // } // Log.i(APP_NAME, "Application finished"); // System.exit(0); // } // } // // /** // * Preallocate heap. // * // * @param size // * the size in megabytes // * @return the object // */ // private static Object preallocateHeap(final int size) { // if (size <= 0) { // Log.i(APP_NAME, "No heap preallocation"); // return null; // } // int i = size; // Log.i(APP_NAME, "Trying to preallocate " + size + "Mb"); // while (i > 0) { // try { // byte[] tmp = new byte[i * 1024 * 1024]; // tmp[size - 1] = (byte) size; // Log.i(APP_NAME, "Preallocated " + i + "Mb"); // tmp = null; // return tmp; // } catch (final OutOfMemoryError e) { // i--; // } catch (final IllegalArgumentException e) { // i--; // } // } // Log.i(APP_NAME, "Heap preallocation failed"); // return null; // } // // } // Path: src/org/ebookdroid/core/curl/PageAnimationType.java import org.ebookdroid.core.SinglePageController; import org.emdev.utils.enums.ResourceConstant; import the.pdfviewer3.EBookDroidApp; import the.pdfviewer3.R; package org.ebookdroid.core.curl; public enum PageAnimationType implements ResourceConstant { NONE(R.string.pref_animation_type_none, true), CURLER(R.string.pref_animation_type_curler_simple, false), CURLER_DYNAMIC(R.string.pref_animation_type_curler_dynamic, false), SLIDER(R.string.pref_animation_type_slider, true), SLIDER2(R.string.pref_animation_type_slider2, true), FADER(R.string.pref_animation_type_fader, true), SQUEEZER(R.string.pref_animation_type_squeezer, true); /** The resource value. */ private final String resValue; private final boolean hardwareAccelSupported; /** * Instantiates a new page animation type. * * @param resValue * the res value */ private PageAnimationType(final int resId, final boolean hardwareAccelSupported) {
this.resValue = EBookDroidApp.context.getString(resId);
ieee8023/PDFViewer
src/org/ebookdroid/common/notifications/ModernNotificationManager.java
// Path: src/org/emdev/BaseDroidApp.java // public class BaseDroidApp extends Application { // // public static Context context; // // public static int APP_VERSION_CODE; // // public static String APP_VERSION_NAME; // // public static String APP_PACKAGE; // // public static File EXT_STORAGE; // // public static File APP_STORAGE; // // public static Properties BUILD_PROPS; // // public static boolean IS_EMULATOR; // // public static String APP_NAME; // // public static Locale defLocale; // // private static Locale appLocale; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // this.init(); // // LogManager.init(this); // } // // protected void init() { // context = getApplicationContext(); // // final Configuration config = context.getResources().getConfiguration(); // appLocale = defLocale = config.locale; // // BUILD_PROPS = new Properties(); // try { // BUILD_PROPS.load(new FileInputStream("/system/build.prop")); // } catch (final Throwable th) { // } // // final PackageManager pm = getPackageManager(); // try { // final PackageInfo pi = pm.getPackageInfo(getPackageName(), 0); // APP_NAME = getString(pi.applicationInfo.labelRes); // APP_VERSION_CODE = pi.versionCode; // APP_VERSION_NAME = LengthUtils.safeString(pi.versionName, "DEV"); // APP_PACKAGE = pi.packageName; // EXT_STORAGE = Environment.getExternalStorageDirectory(); // APP_STORAGE = getAppStorage(APP_PACKAGE); // IS_EMULATOR = "sdk".equalsIgnoreCase(Build.MODEL); // // Log.i(APP_NAME, APP_NAME + " (" + APP_PACKAGE + ")" + " " + APP_VERSION_NAME + "(" + pi.versionCode + ")"); // // Log.i(APP_NAME, "Root dir: " + Environment.getRootDirectory()); // Log.i(APP_NAME, "Data dir: " + Environment.getDataDirectory()); // Log.i(APP_NAME, "External storage dir: " + EXT_STORAGE); // Log.i(APP_NAME, "App storage dir: " + APP_STORAGE); // Log.i(APP_NAME, "Files dir: " + FileUtils.getAbsolutePath(getFilesDir())); // Log.i(APP_NAME, "Cache dir: " + FileUtils.getAbsolutePath(getCacheDir())); // Log.i(APP_NAME, "System locale : " + defLocale); // // Log.i(APP_NAME, "VERSION : " + AndroidVersion.VERSION); // Log.i(APP_NAME, "BOARD : " + Build.BOARD); // Log.i(APP_NAME, "BRAND : " + Build.BRAND); // Log.i(APP_NAME, "CPU_ABI : " + BUILD_PROPS.getProperty("ro.product.cpu.abi")); // Log.i(APP_NAME, "CPU_ABI2 : " + BUILD_PROPS.getProperty("ro.product.cpu.abi2")); // Log.i(APP_NAME, "DEVICE : " + Build.DEVICE); // Log.i(APP_NAME, "DISPLAY : " + Build.DISPLAY); // Log.i(APP_NAME, "FINGERPRINT : " + Build.FINGERPRINT); // Log.i(APP_NAME, "ID : " + Build.ID); // Log.i(APP_NAME, "MANUFACTURER: " + BUILD_PROPS.getProperty("ro.product.manufacturer")); // Log.i(APP_NAME, "MODEL : " + Build.MODEL); // Log.i(APP_NAME, "PRODUCT : " + Build.PRODUCT); // } catch (final NameNotFoundException e) { // e.printStackTrace(); // } // } // // @Override // public void onConfigurationChanged(final Configuration newConfig) { // final Configuration oldConfig = getResources().getConfiguration(); // final int diff = oldConfig.diff(newConfig); // final Configuration target = diff == 0 ? oldConfig : newConfig; // // if (appLocale != null) { // setAppLocaleIntoConfiguration(target); // } // super.onConfigurationChanged(target); // } // // protected File getAppStorage(final String appPackage) { // File dir = EXT_STORAGE; // if (dir != null) { // final File appDir = new File(dir, "." + appPackage); // if (appDir.isDirectory() || appDir.mkdir()) { // dir = appDir; // } // } else { // dir = context.getFilesDir(); // } // dir.mkdirs(); // return dir.getAbsoluteFile(); // } // // public static void setAppLocale(final String lang) { // final Configuration config = context.getResources().getConfiguration(); // // if (LengthUtils.isNotEmpty(lang)){ // // if (lang.contains("-r")){ // // String[] loc = lang.split("-r"); // // if (loc.length == 2) // appLocale = new Locale(loc[0], loc[1]); // else // appLocale = defLocale; // // }else{ // // appLocale = new Locale(lang);; // } // }else{ // appLocale = defLocale; // } // // // setAppLocaleIntoConfiguration(config); // } // // protected static void setAppLocaleIntoConfiguration(final Configuration config) { // if (!config.locale.equals(appLocale)) { // Locale.setDefault(appLocale); // config.locale = appLocale; // context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); // } // Log.i(APP_NAME, "UI Locale: " + appLocale); // } // }
import android.annotation.TargetApi; import android.app.Notification; import android.content.Intent; import the.pdfviewer3.R; import org.emdev.BaseDroidApp;
package org.ebookdroid.common.notifications; @TargetApi(11) class ModernNotificationManager extends AbstractNotificationManager { @Override public int notify(final CharSequence title, final CharSequence message, final Intent intent) {
// Path: src/org/emdev/BaseDroidApp.java // public class BaseDroidApp extends Application { // // public static Context context; // // public static int APP_VERSION_CODE; // // public static String APP_VERSION_NAME; // // public static String APP_PACKAGE; // // public static File EXT_STORAGE; // // public static File APP_STORAGE; // // public static Properties BUILD_PROPS; // // public static boolean IS_EMULATOR; // // public static String APP_NAME; // // public static Locale defLocale; // // private static Locale appLocale; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // this.init(); // // LogManager.init(this); // } // // protected void init() { // context = getApplicationContext(); // // final Configuration config = context.getResources().getConfiguration(); // appLocale = defLocale = config.locale; // // BUILD_PROPS = new Properties(); // try { // BUILD_PROPS.load(new FileInputStream("/system/build.prop")); // } catch (final Throwable th) { // } // // final PackageManager pm = getPackageManager(); // try { // final PackageInfo pi = pm.getPackageInfo(getPackageName(), 0); // APP_NAME = getString(pi.applicationInfo.labelRes); // APP_VERSION_CODE = pi.versionCode; // APP_VERSION_NAME = LengthUtils.safeString(pi.versionName, "DEV"); // APP_PACKAGE = pi.packageName; // EXT_STORAGE = Environment.getExternalStorageDirectory(); // APP_STORAGE = getAppStorage(APP_PACKAGE); // IS_EMULATOR = "sdk".equalsIgnoreCase(Build.MODEL); // // Log.i(APP_NAME, APP_NAME + " (" + APP_PACKAGE + ")" + " " + APP_VERSION_NAME + "(" + pi.versionCode + ")"); // // Log.i(APP_NAME, "Root dir: " + Environment.getRootDirectory()); // Log.i(APP_NAME, "Data dir: " + Environment.getDataDirectory()); // Log.i(APP_NAME, "External storage dir: " + EXT_STORAGE); // Log.i(APP_NAME, "App storage dir: " + APP_STORAGE); // Log.i(APP_NAME, "Files dir: " + FileUtils.getAbsolutePath(getFilesDir())); // Log.i(APP_NAME, "Cache dir: " + FileUtils.getAbsolutePath(getCacheDir())); // Log.i(APP_NAME, "System locale : " + defLocale); // // Log.i(APP_NAME, "VERSION : " + AndroidVersion.VERSION); // Log.i(APP_NAME, "BOARD : " + Build.BOARD); // Log.i(APP_NAME, "BRAND : " + Build.BRAND); // Log.i(APP_NAME, "CPU_ABI : " + BUILD_PROPS.getProperty("ro.product.cpu.abi")); // Log.i(APP_NAME, "CPU_ABI2 : " + BUILD_PROPS.getProperty("ro.product.cpu.abi2")); // Log.i(APP_NAME, "DEVICE : " + Build.DEVICE); // Log.i(APP_NAME, "DISPLAY : " + Build.DISPLAY); // Log.i(APP_NAME, "FINGERPRINT : " + Build.FINGERPRINT); // Log.i(APP_NAME, "ID : " + Build.ID); // Log.i(APP_NAME, "MANUFACTURER: " + BUILD_PROPS.getProperty("ro.product.manufacturer")); // Log.i(APP_NAME, "MODEL : " + Build.MODEL); // Log.i(APP_NAME, "PRODUCT : " + Build.PRODUCT); // } catch (final NameNotFoundException e) { // e.printStackTrace(); // } // } // // @Override // public void onConfigurationChanged(final Configuration newConfig) { // final Configuration oldConfig = getResources().getConfiguration(); // final int diff = oldConfig.diff(newConfig); // final Configuration target = diff == 0 ? oldConfig : newConfig; // // if (appLocale != null) { // setAppLocaleIntoConfiguration(target); // } // super.onConfigurationChanged(target); // } // // protected File getAppStorage(final String appPackage) { // File dir = EXT_STORAGE; // if (dir != null) { // final File appDir = new File(dir, "." + appPackage); // if (appDir.isDirectory() || appDir.mkdir()) { // dir = appDir; // } // } else { // dir = context.getFilesDir(); // } // dir.mkdirs(); // return dir.getAbsoluteFile(); // } // // public static void setAppLocale(final String lang) { // final Configuration config = context.getResources().getConfiguration(); // // if (LengthUtils.isNotEmpty(lang)){ // // if (lang.contains("-r")){ // // String[] loc = lang.split("-r"); // // if (loc.length == 2) // appLocale = new Locale(loc[0], loc[1]); // else // appLocale = defLocale; // // }else{ // // appLocale = new Locale(lang);; // } // }else{ // appLocale = defLocale; // } // // // setAppLocaleIntoConfiguration(config); // } // // protected static void setAppLocaleIntoConfiguration(final Configuration config) { // if (!config.locale.equals(appLocale)) { // Locale.setDefault(appLocale); // config.locale = appLocale; // context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); // } // Log.i(APP_NAME, "UI Locale: " + appLocale); // } // } // Path: src/org/ebookdroid/common/notifications/ModernNotificationManager.java import android.annotation.TargetApi; import android.app.Notification; import android.content.Intent; import the.pdfviewer3.R; import org.emdev.BaseDroidApp; package org.ebookdroid.common.notifications; @TargetApi(11) class ModernNotificationManager extends AbstractNotificationManager { @Override public int notify(final CharSequence title, final CharSequence message, final Intent intent) {
final Notification.Builder nb = new Notification.Builder(BaseDroidApp.context);
ieee8023/PDFViewer
src/org/ebookdroid/ui/settings/SettingsUI.java
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // }
import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion;
package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) {
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // } // Path: src/org/ebookdroid/ui/settings/SettingsUI.java import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion; package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) {
final Intent intent = new Intent(context, BookSettingsActivity.class);
ieee8023/PDFViewer
src/org/ebookdroid/ui/settings/SettingsUI.java
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // }
import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion;
package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) { final Intent intent = new Intent(context, BookSettingsActivity.class); intent.setData(Uri.fromFile(new File(fileName))); context.startActivity(intent); } public static void showAppSettings(final Context context, final String fileName) {
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // } // Path: src/org/ebookdroid/ui/settings/SettingsUI.java import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion; package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) { final Intent intent = new Intent(context, BookSettingsActivity.class); intent.setData(Uri.fromFile(new File(fileName))); context.startActivity(intent); } public static void showAppSettings(final Context context, final String fileName) {
final Class<?> activityClass = AndroidVersion.lessThan3x ? SettingsActivity.class
ieee8023/PDFViewer
src/org/ebookdroid/ui/settings/SettingsUI.java
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // }
import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion;
package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) { final Intent intent = new Intent(context, BookSettingsActivity.class); intent.setData(Uri.fromFile(new File(fileName))); context.startActivity(intent); } public static void showAppSettings(final Context context, final String fileName) { final Class<?> activityClass = AndroidVersion.lessThan3x ? SettingsActivity.class
// Path: src/the/pdfviewer3/BookSettingsActivity.java // public class BookSettingsActivity extends BaseSettingsActivity { // // private BookSettings current; // // @SuppressWarnings("deprecation") // @Override // protected void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // final Uri uri = getIntent().getData(); // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // current = SettingsManager.getBookSettings(fileName); // if (current == null) { // finish(); // return; // } // // setRequestedOrientation(current.getOrientation(AppSettings.current())); // // SettingsManager.onBookSettingsActivityCreated(current); // // try { // addPreferencesFromResource(R.xml.fragment_book); // } catch (final ClassCastException e) { // LCTX.e("Book preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // PreferenceManager.setDefaultValues(this, R.xml.fragment_book, true); // addPreferencesFromResource(R.xml.fragment_book); // } // // decorator.decoratePreference(getRoot()); // decorator.decorateBooksSettings(current); // } // // @Override // protected void onPause() { // SettingsManager.onBookSettingsActivityClosed(current); // super.onPause(); // } // } // // Path: src/the/pdfviewer3/FragmentedSettingsActivity.java // @TargetApi(11) // public class FragmentedSettingsActivity extends SettingsActivity { // // @Override // protected void onCreate() { // } // // @Override // public void onBuildHeaders(final List<Header> target) { // loadHeadersFromResource(R.xml.preferences_headers, target); // } // // @Override // public boolean onIsMultiPane() { // final Configuration c = this.getResources().getConfiguration(); // if (0 != (Configuration.SCREENLAYOUT_SIZE_XLARGE & c.screenLayout)) { // return c.orientation == Configuration.ORIENTATION_LANDSCAPE; // } // return false; // } // } // // Path: src/the/pdfviewer3/SettingsActivity.java // public class SettingsActivity extends BaseSettingsActivity { // // @Override // protected final void onCreate(final Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // EBookDroidApp.initFonts(); // // final Uri uri = getIntent().getData(); // if (uri != null) { // final String fileName = PathFromUri.retrieve(getContentResolver(), uri); // BookSettings current = SettingsManager.getBookSettings(fileName); // if (current != null) { // setRequestedOrientation(current.getOrientation(AppSettings.current())); // } // } // // onCreate(); // } // // @Override // protected void onPause() { // SettingsManager.onSettingsChanged(); // super.onPause(); // } // // @SuppressWarnings("deprecation") // protected void onCreate() { // try { // setPreferenceScreen(createPreferences()); // } catch (final ClassCastException e) { // LCTX.e("Shared preferences are corrupt! Resetting to default values."); // // final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // final SharedPreferences.Editor editor = preferences.edit(); // editor.clear(); // editor.commit(); // // setPreferenceScreen(createPreferences()); // } // // decorator.decorateSettings(); // } // // @SuppressWarnings("deprecation") // PreferenceScreen createPreferences() { // final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); // // root.setTitle(R.string.menu_settings); // // loadPreferences(root, R.xml.fragment_ui); // loadPreferences(root, R.xml.fragment_scroll); // loadPreferences(root, R.xml.fragment_navigation); // loadPreferences(root, R.xml.fragment_performance); // loadPreferences(root, R.xml.fragment_render); // loadPreferences(root, R.xml.fragment_typespec); // loadPreferences(root, R.xml.fragment_browser); // loadPreferences(root, R.xml.fragment_opds); // // loadPreferences(root, R.xml.fragment_backup); // // return root; // } // // @SuppressWarnings("deprecation") // void loadPreferences(final PreferenceScreen root, final int... resourceIds) { // for (final int id : resourceIds) { // setPreferenceScreen(null); // addPreferencesFromResource(id); // root.addPreference(getPreferenceScreen()); // setPreferenceScreen(null); // } // } // // } // Path: src/org/ebookdroid/ui/settings/SettingsUI.java import android.content.Context; import android.content.Intent; import android.net.Uri; import the.pdfviewer3.BookSettingsActivity; import the.pdfviewer3.FragmentedSettingsActivity; import the.pdfviewer3.SettingsActivity; import java.io.File; import org.emdev.common.android.AndroidVersion; package org.ebookdroid.ui.settings; public class SettingsUI { public static void showBookSettings(final Context context, final String fileName) { final Intent intent = new Intent(context, BookSettingsActivity.class); intent.setData(Uri.fromFile(new File(fileName))); context.startActivity(intent); } public static void showAppSettings(final Context context, final String fileName) { final Class<?> activityClass = AndroidVersion.lessThan3x ? SettingsActivity.class
: FragmentedSettingsActivity.class;
ieee8023/PDFViewer
src/org/ebookdroid/common/settings/types/ToastPosition.java
// Path: src/the/pdfviewer3/EBookDroidApp.java // public class EBookDroidApp extends BaseDroidApp implements IAppSettingsChangeListener, IBackupSettingsChangeListener, // ILibSettingsChangeListener { // // public static final Flag initialized = new Flag(); // // public static EBookDroidVersion version; // // private static EBookDroidApp instance; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // instance = this; // version = EBookDroidVersion.get(APP_VERSION_CODE); // // SettingsManager.init(this); // CacheManager.init(this); // MediaManager.init(this); // // initFonts(); // // preallocateHeap(AppSettings.current().heapPreallocate); // // SettingsManager.addListener(this); // onAppSettingsChanged(null, AppSettings.current(), null); // onBackupSettingsChanged(null, BackupSettings.current(), null); // // GLConfiguration.stencilRequired = !IS_EMULATOR; // // initialized.set(); // } // // public static void initFonts() { // FontManager.init(APP_STORAGE); // } // // @Override // public void onTerminate() { // SettingsManager.onTerminate(); // MediaManager.onTerminate(this); // } // // /** // * {@inheritDoc} // * // * @see android.app.Application#onLowMemory() // */ // @Override // public void onLowMemory() { // super.onLowMemory(); // BitmapManager.clear("on Low Memory: "); // ByteBufferManager.clear("on Low Memory: "); // } // // @Override // public void onAppSettingsChanged(final AppSettings oldSettings, final AppSettings newSettings, // final AppSettings.Diff diff) { // // ByteBufferManager.setPartSize(1 << newSettings.bitmapSize); // // setAppLocale(newSettings.lang); // } // // @Override // public void onBackupSettingsChanged(final BackupSettings oldSettings, final BackupSettings newSettings, // final BackupSettings.Diff diff) { // BackupManager.setMaxNumberOfAutoBackups(newSettings.maxNumberOfAutoBackups); // } // // @Override // public void onLibSettingsChanged(final LibSettings oldSettings, final LibSettings newSettings, final Diff diff) { // if (diff.isCacheLocationChanged()) { // CacheManager.setCacheLocation(newSettings.cacheLocation, !diff.isFirstTime()); // } // } // // public static void checkInstalledFonts(final Context context) { // // if (!FontManager.external.hasInstalled()) { // // if (!SettingsManager.isInitialFlagsSet(SettingsManager.INITIAL_FONTS)) { // // SettingsManager.setInitialFlags(SettingsManager.INITIAL_FONTS); // // // // final ActionDialogBuilder b = new ActionDialogBuilder(context, new ActionController<Context>(context)); // // final WebView view = new WebView(context); // // // // final String text = context.getResources().getString(R.string.font_reminder); // // final String content = "<html><body>" + text + "</body></html>"; // // // // view.loadDataWithBaseURL("file:///fake/not_used", content, "text/html", "UTF-8", ""); // // // // b.setTitle(R.string.font_reminder_title); // // b.setView(view); // // b.setPositiveButton(android.R.string.ok, R.id.actions_no_action); // // b.show(); // // } // // } // } // // public static void onActivityClose(final boolean finishing) { // if (finishing && !SettingsManager.hasOpenedBooks() && !RecentActivityController.working.get()) { // if (instance != null) { // instance.onTerminate(); // } // Log.i(APP_NAME, "Application finished"); // System.exit(0); // } // } // // /** // * Preallocate heap. // * // * @param size // * the size in megabytes // * @return the object // */ // private static Object preallocateHeap(final int size) { // if (size <= 0) { // Log.i(APP_NAME, "No heap preallocation"); // return null; // } // int i = size; // Log.i(APP_NAME, "Trying to preallocate " + size + "Mb"); // while (i > 0) { // try { // byte[] tmp = new byte[i * 1024 * 1024]; // tmp[size - 1] = (byte) size; // Log.i(APP_NAME, "Preallocated " + i + "Mb"); // tmp = null; // return tmp; // } catch (final OutOfMemoryError e) { // i--; // } catch (final IllegalArgumentException e) { // i--; // } // } // Log.i(APP_NAME, "Heap preallocation failed"); // return null; // } // // }
import static android.view.Gravity.*; import static the.pdfviewer3.R.string.*; import org.emdev.utils.enums.ResourceConstant; import the.pdfviewer3.EBookDroidApp;
package org.ebookdroid.common.settings.types; public enum ToastPosition implements ResourceConstant { /** * */ Invisible(pref_toastposition_invisible, 0), /** * */ LeftTop(pref_toastposition_lefttop, LEFT | TOP), /** * */ RightTop(pref_toastposition_righttop, RIGHT | TOP), /** * */ LeftBottom(pref_toastposition_leftbottom, LEFT | BOTTOM), /** * */ Bottom(pref_toastposition_bottom, CENTER | BOTTOM), /** * */ RightBottom(pref_toastposition_righbottom, RIGHT | BOTTOM); public final int position; private final String resValue; private ToastPosition(int resId, int position) {
// Path: src/the/pdfviewer3/EBookDroidApp.java // public class EBookDroidApp extends BaseDroidApp implements IAppSettingsChangeListener, IBackupSettingsChangeListener, // ILibSettingsChangeListener { // // public static final Flag initialized = new Flag(); // // public static EBookDroidVersion version; // // private static EBookDroidApp instance; // // /** // * {@inheritDoc} // * // * @see android.app.Application#onCreate() // */ // @Override // public void onCreate() { // super.onCreate(); // // instance = this; // version = EBookDroidVersion.get(APP_VERSION_CODE); // // SettingsManager.init(this); // CacheManager.init(this); // MediaManager.init(this); // // initFonts(); // // preallocateHeap(AppSettings.current().heapPreallocate); // // SettingsManager.addListener(this); // onAppSettingsChanged(null, AppSettings.current(), null); // onBackupSettingsChanged(null, BackupSettings.current(), null); // // GLConfiguration.stencilRequired = !IS_EMULATOR; // // initialized.set(); // } // // public static void initFonts() { // FontManager.init(APP_STORAGE); // } // // @Override // public void onTerminate() { // SettingsManager.onTerminate(); // MediaManager.onTerminate(this); // } // // /** // * {@inheritDoc} // * // * @see android.app.Application#onLowMemory() // */ // @Override // public void onLowMemory() { // super.onLowMemory(); // BitmapManager.clear("on Low Memory: "); // ByteBufferManager.clear("on Low Memory: "); // } // // @Override // public void onAppSettingsChanged(final AppSettings oldSettings, final AppSettings newSettings, // final AppSettings.Diff diff) { // // ByteBufferManager.setPartSize(1 << newSettings.bitmapSize); // // setAppLocale(newSettings.lang); // } // // @Override // public void onBackupSettingsChanged(final BackupSettings oldSettings, final BackupSettings newSettings, // final BackupSettings.Diff diff) { // BackupManager.setMaxNumberOfAutoBackups(newSettings.maxNumberOfAutoBackups); // } // // @Override // public void onLibSettingsChanged(final LibSettings oldSettings, final LibSettings newSettings, final Diff diff) { // if (diff.isCacheLocationChanged()) { // CacheManager.setCacheLocation(newSettings.cacheLocation, !diff.isFirstTime()); // } // } // // public static void checkInstalledFonts(final Context context) { // // if (!FontManager.external.hasInstalled()) { // // if (!SettingsManager.isInitialFlagsSet(SettingsManager.INITIAL_FONTS)) { // // SettingsManager.setInitialFlags(SettingsManager.INITIAL_FONTS); // // // // final ActionDialogBuilder b = new ActionDialogBuilder(context, new ActionController<Context>(context)); // // final WebView view = new WebView(context); // // // // final String text = context.getResources().getString(R.string.font_reminder); // // final String content = "<html><body>" + text + "</body></html>"; // // // // view.loadDataWithBaseURL("file:///fake/not_used", content, "text/html", "UTF-8", ""); // // // // b.setTitle(R.string.font_reminder_title); // // b.setView(view); // // b.setPositiveButton(android.R.string.ok, R.id.actions_no_action); // // b.show(); // // } // // } // } // // public static void onActivityClose(final boolean finishing) { // if (finishing && !SettingsManager.hasOpenedBooks() && !RecentActivityController.working.get()) { // if (instance != null) { // instance.onTerminate(); // } // Log.i(APP_NAME, "Application finished"); // System.exit(0); // } // } // // /** // * Preallocate heap. // * // * @param size // * the size in megabytes // * @return the object // */ // private static Object preallocateHeap(final int size) { // if (size <= 0) { // Log.i(APP_NAME, "No heap preallocation"); // return null; // } // int i = size; // Log.i(APP_NAME, "Trying to preallocate " + size + "Mb"); // while (i > 0) { // try { // byte[] tmp = new byte[i * 1024 * 1024]; // tmp[size - 1] = (byte) size; // Log.i(APP_NAME, "Preallocated " + i + "Mb"); // tmp = null; // return tmp; // } catch (final OutOfMemoryError e) { // i--; // } catch (final IllegalArgumentException e) { // i--; // } // } // Log.i(APP_NAME, "Heap preallocation failed"); // return null; // } // // } // Path: src/org/ebookdroid/common/settings/types/ToastPosition.java import static android.view.Gravity.*; import static the.pdfviewer3.R.string.*; import org.emdev.utils.enums.ResourceConstant; import the.pdfviewer3.EBookDroidApp; package org.ebookdroid.common.settings.types; public enum ToastPosition implements ResourceConstant { /** * */ Invisible(pref_toastposition_invisible, 0), /** * */ LeftTop(pref_toastposition_lefttop, LEFT | TOP), /** * */ RightTop(pref_toastposition_righttop, RIGHT | TOP), /** * */ LeftBottom(pref_toastposition_leftbottom, LEFT | BOTTOM), /** * */ Bottom(pref_toastposition_bottom, CENTER | BOTTOM), /** * */ RightBottom(pref_toastposition_righbottom, RIGHT | BOTTOM); public final int position; private final String resValue; private ToastPosition(int resId, int position) {
this.resValue = EBookDroidApp.context.getString(resId);
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/ListGenerator.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // }
import java.io.IOException; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.text.TextUtils; import android.util.Log; import cn.yo2.aquarium.pocketvoa.parser.IListParser;
package cn.yo2.aquarium.pocketvoa; public class ListGenerator { private static final String CLASSTAG = ListGenerator.class .getSimpleName();
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/ListGenerator.java import java.io.IOException; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.text.TextUtils; import android.util.Log; import cn.yo2.aquarium.pocketvoa.parser.IListParser; package cn.yo2.aquarium.pocketvoa; public class ListGenerator { private static final String CLASSTAG = ListGenerator.class .getSimpleName();
IListParser mParser;
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/PageGenerator.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // }
import java.io.IOException; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.text.TextUtils; import android.util.Log; import cn.yo2.aquarium.pocketvoa.parser.IPageParser;
package cn.yo2.aquarium.pocketvoa; public class PageGenerator { private static final String CLASSTAG = PageGenerator.class .getSimpleName();
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/PageGenerator.java import java.io.IOException; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.text.TextUtils; import android.util.Log; import cn.yo2.aquarium.pocketvoa.parser.IPageParser; package cn.yo2.aquarium.pocketvoa; public class PageGenerator { private static final String CLASSTAG = PageGenerator.class .getSimpleName();
IPageParser mParser;
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/lyric/LyricView2.java
// Path: src/cn/yo2/aquarium/logutils/MyLog.java // public final class MyLog { // private static String TAG = "POCKET VOA"; // private static boolean LOG_ENABLE = true; // private static boolean DETAIL_ENABLE = true; // // private MyLog() { // } // // private static String buildMsg(String msg) { // StringBuilder buffer = new StringBuilder(); // // if (DETAIL_ENABLE) { // final StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[4]; // // buffer.append("[ "); // buffer.append(Thread.currentThread().getName()); // buffer.append(": "); // buffer.append(stackTraceElement.getFileName()); // buffer.append(": "); // buffer.append(stackTraceElement.getLineNumber()); // buffer.append(": "); // buffer.append(stackTraceElement.getMethodName()); // } // // buffer.append("() ] _____ "); // // buffer.append(msg); // // return buffer.toString(); // } // // // public static void v(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, buildMsg(msg)); // } // } // // // public static void d(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.DEBUG)) { // Log.d(TAG, buildMsg(msg)); // } // } // // // public static void i(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.INFO)) { // Log.i(TAG, buildMsg(msg)); // } // } // // // public static void w(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.WARN)) { // Log.w(TAG, buildMsg(msg)); // } // } // // // public static void w(String msg, Exception e) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.WARN)) { // Log.w(TAG, buildMsg(msg), e); // } // } // // // public static void e(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.ERROR)) { // Log.e(TAG, buildMsg(msg)); // } // } // // // public static void e(String msg, Exception e) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.ERROR)) { // Log.e(TAG, buildMsg(msg), e); // } // } // // public static void initLog(String tag, boolean logEnable, boolean detailEnable) { // TAG = tag; // LOG_ENABLE = logEnable; // DETAIL_ENABLE = detailEnable; // } // }
import java.io.InputStream; import java.util.ArrayList; import java.util.List; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Paint.FontMetricsInt; import android.os.Handler; import android.os.Message; import android.text.TextPaint; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; import android.widget.Scroller; import cn.yo2.aquarium.logutils.MyLog; import cn.yo2.aquarium.pocketvoa.R;
// The Lyric object private Lyric mLyric; private List<LineBreak> mLineBreaks; private String mErrorMessage; private boolean mLyricLoaded; private boolean mOnLayoutCalled; private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case WHAT_LYRIC_LOAD_OK: requestLayout(); break; default: break; } } }; public boolean loadLyric(String lyricText, int width) {
// Path: src/cn/yo2/aquarium/logutils/MyLog.java // public final class MyLog { // private static String TAG = "POCKET VOA"; // private static boolean LOG_ENABLE = true; // private static boolean DETAIL_ENABLE = true; // // private MyLog() { // } // // private static String buildMsg(String msg) { // StringBuilder buffer = new StringBuilder(); // // if (DETAIL_ENABLE) { // final StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[4]; // // buffer.append("[ "); // buffer.append(Thread.currentThread().getName()); // buffer.append(": "); // buffer.append(stackTraceElement.getFileName()); // buffer.append(": "); // buffer.append(stackTraceElement.getLineNumber()); // buffer.append(": "); // buffer.append(stackTraceElement.getMethodName()); // } // // buffer.append("() ] _____ "); // // buffer.append(msg); // // return buffer.toString(); // } // // // public static void v(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.VERBOSE)) { // Log.v(TAG, buildMsg(msg)); // } // } // // // public static void d(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.DEBUG)) { // Log.d(TAG, buildMsg(msg)); // } // } // // // public static void i(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.INFO)) { // Log.i(TAG, buildMsg(msg)); // } // } // // // public static void w(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.WARN)) { // Log.w(TAG, buildMsg(msg)); // } // } // // // public static void w(String msg, Exception e) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.WARN)) { // Log.w(TAG, buildMsg(msg), e); // } // } // // // public static void e(String msg) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.ERROR)) { // Log.e(TAG, buildMsg(msg)); // } // } // // // public static void e(String msg, Exception e) { // if (LOG_ENABLE && Log.isLoggable(TAG, Log.ERROR)) { // Log.e(TAG, buildMsg(msg), e); // } // } // // public static void initLog(String tag, boolean logEnable, boolean detailEnable) { // TAG = tag; // LOG_ENABLE = logEnable; // DETAIL_ENABLE = detailEnable; // } // } // Path: src/cn/yo2/aquarium/pocketvoa/lyric/LyricView2.java import java.io.InputStream; import java.util.ArrayList; import java.util.List; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Paint.FontMetricsInt; import android.os.Handler; import android.os.Message; import android.text.TextPaint; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; import android.widget.Scroller; import cn.yo2.aquarium.logutils.MyLog; import cn.yo2.aquarium.pocketvoa.R; // The Lyric object private Lyric mLyric; private List<LineBreak> mLineBreaks; private String mErrorMessage; private boolean mLyricLoaded; private boolean mOnLayoutCalled; private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case WHAT_LYRIC_LOAD_OK: requestLayout(); break; default: break; } } }; public boolean loadLyric(String lyricText, int width) {
MyLog.d("in loadLyric");
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/MainActivity.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // }
import java.io.IOException; import java.util.ArrayList; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.SimpleCursorAdapter.ViewBinder; import cn.yo2.aquarium.pocketvoa.parser.IDataSource;
package cn.yo2.aquarium.pocketvoa; public class MainActivity extends Activity { private static final String KEY_SAVED_ERROR = "key_saved_error"; private static final String KEY_SAVED_COMMAND = "key_saved_command"; private static final String KEY_SAVED_ARTICLE = "key_saved_article"; private static final String CLASSTAG = MainActivity.class.getSimpleName(); private static final int MENU_SETTINGS = Menu.FIRST; private static final int MENU_UPDATE = Menu.FIRST + 1; private static final int MENU_BACKUP = Menu.FIRST + 2; private static final int MENU_EXIT = Menu.FIRST + 3; private static final int DLG_ERROR = 0; private static final int DLG_PROGRESS = 1; private static final int DLG_MENU_LOCAL_LIST = 2; private static final int DLG_MENU_REMOTE_LIST = 3; private static final int DLG_CONFIRM_DELETE = 4; private static final int DLG_CONFIRM_DOWNLOAD = 5; private static final int DLG_INTERNET_STATUS_CONNECTED = 6; private static final int DLG_INTERNET_STATUS_DISCONNECTED = 7; private static final int DLG_CHANGE_LOG = 8; private static final int DLG_CONFIRM_EXIT = 9; private static final int WHAT_SUCCESS = 0; private static final int WHAT_FAIL_IO = 1; private static final int WHAT_FAIL_PARSE = 2; private static final int CMD_REFRESH_REMOTE_LIST = 0; private static final int CMD_REFRESH_LOCAL_LIST = 1; private static final int CMD_DOWNLOAD_ARTICLE = 2; private static final int CMD_SHOW_ARTICLE = 3;
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // Path: src/cn/yo2/aquarium/pocketvoa/MainActivity.java import java.io.IOException; import java.util.ArrayList; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.Spinner; import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.SimpleCursorAdapter.ViewBinder; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; package cn.yo2.aquarium.pocketvoa; public class MainActivity extends Activity { private static final String KEY_SAVED_ERROR = "key_saved_error"; private static final String KEY_SAVED_COMMAND = "key_saved_command"; private static final String KEY_SAVED_ARTICLE = "key_saved_article"; private static final String CLASSTAG = MainActivity.class.getSimpleName(); private static final int MENU_SETTINGS = Menu.FIRST; private static final int MENU_UPDATE = Menu.FIRST + 1; private static final int MENU_BACKUP = Menu.FIRST + 2; private static final int MENU_EXIT = Menu.FIRST + 3; private static final int DLG_ERROR = 0; private static final int DLG_PROGRESS = 1; private static final int DLG_MENU_LOCAL_LIST = 2; private static final int DLG_MENU_REMOTE_LIST = 3; private static final int DLG_CONFIRM_DELETE = 4; private static final int DLG_CONFIRM_DOWNLOAD = 5; private static final int DLG_INTERNET_STATUS_CONNECTED = 6; private static final int DLG_INTERNET_STATUS_DISCONNECTED = 7; private static final int DLG_CHANGE_LOG = 8; private static final int DLG_CONFIRM_EXIT = 9; private static final int WHAT_SUCCESS = 0; private static final int WHAT_FAIL_IO = 1; private static final int WHAT_FAIL_PARSE = 2; private static final int CMD_REFRESH_REMOTE_LIST = 0; private static final int CMD_REFRESH_LOCAL_LIST = 1; private static final int CMD_DOWNLOAD_ARTICLE = 2; private static final int CMD_SHOW_ARTICLE = 3;
private static final String[] TYPES_REMOTE = { IDataSource.STANDARD_ENGLISH,
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/parser/voa51/Voa51DataSource.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // }
import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser;
package cn.yo2.aquarium.pocketvoa.parser.voa51; public class Voa51DataSource implements IDataSource { private static final String SEPERATOR = "_"; static final String HOST = "http://www.51voa.com"; // standard English static final String URL_ENGLISH_NEWS = HOST + "/VOA_Standard_%d.html"; // special English static final String URL_TECHNOLOGY_REPORT = HOST + "/Technology_Report_%d.html"; static final String URL_THIS_IS_AMERICA = HOST + "/This_is_America_%d.html"; static final String URL_AGRICULTURE_REPORT = HOST + "/Agriculture_Report_%d.html"; static final String URL_SCIENCE_IN_THE_NEWS = HOST + "/Science_in_the_News_%d.html"; static final String URL_HEALTH_REPORT = HOST + "/Health_Report_%d.html"; static final String URL_EXPLORATIONS = HOST + "/Explorations_%d.html"; static final String URL_EDUCATION_REPORT = HOST + "/Education_Report_%d.html"; static final String URL_THE_MAKING_OF_A_NATION = HOST+ "/The_Making_of_a_Nation_%d.html"; static final String URL_ECONOMICS_REPORT = HOST + "/Economics_Report_%d.html"; static final String URL_AMERICAN_MOSAIC = HOST + "/American_Mosaic_%d.html"; static final String URL_IN_THE_NEWS = HOST + "/In_the_News_%d.html"; static final String URL_AMERICAN_STORIES = HOST + "/American_Stories_%d.html"; static final String URL_WORDS_AND_THEIR_STORIES = HOST + "/Words_And_Their_Stories_%d.html"; static final String URL_PEOPLE_IN_AMERICA = HOST + "/People_in_America_%d.html"; // English learning static final String URL_GO_ENGLISH = HOST + "/Go_English_%d.html"; static final String URL_WORD_MASTER = HOST + "/Word_Master_%d.html"; static final String URL_AMERICAN_CAFE = HOST + "/American_Cafe_%d.html"; static final String URL_POPULAR_AMERICAN = HOST + "/Popular_American_%d.html"; static final String URL_BUSINESS_ETIQUETTE = HOST + "/Business_Etiquette_%d.html"; static final String URL_SPORTS_ENGLISH = HOST + "/Sports_English_%d.html"; static final String URL_WORDS_AND_IDIOMS = HOST + "/Words_And_Idioms_%d.html"; // Article type_subtype -> private final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype ->
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/parser/voa51/Voa51DataSource.java import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser; package cn.yo2.aquarium.pocketvoa.parser.voa51; public class Voa51DataSource implements IDataSource { private static final String SEPERATOR = "_"; static final String HOST = "http://www.51voa.com"; // standard English static final String URL_ENGLISH_NEWS = HOST + "/VOA_Standard_%d.html"; // special English static final String URL_TECHNOLOGY_REPORT = HOST + "/Technology_Report_%d.html"; static final String URL_THIS_IS_AMERICA = HOST + "/This_is_America_%d.html"; static final String URL_AGRICULTURE_REPORT = HOST + "/Agriculture_Report_%d.html"; static final String URL_SCIENCE_IN_THE_NEWS = HOST + "/Science_in_the_News_%d.html"; static final String URL_HEALTH_REPORT = HOST + "/Health_Report_%d.html"; static final String URL_EXPLORATIONS = HOST + "/Explorations_%d.html"; static final String URL_EDUCATION_REPORT = HOST + "/Education_Report_%d.html"; static final String URL_THE_MAKING_OF_A_NATION = HOST+ "/The_Making_of_a_Nation_%d.html"; static final String URL_ECONOMICS_REPORT = HOST + "/Economics_Report_%d.html"; static final String URL_AMERICAN_MOSAIC = HOST + "/American_Mosaic_%d.html"; static final String URL_IN_THE_NEWS = HOST + "/In_the_News_%d.html"; static final String URL_AMERICAN_STORIES = HOST + "/American_Stories_%d.html"; static final String URL_WORDS_AND_THEIR_STORIES = HOST + "/Words_And_Their_Stories_%d.html"; static final String URL_PEOPLE_IN_AMERICA = HOST + "/People_in_America_%d.html"; // English learning static final String URL_GO_ENGLISH = HOST + "/Go_English_%d.html"; static final String URL_WORD_MASTER = HOST + "/Word_Master_%d.html"; static final String URL_AMERICAN_CAFE = HOST + "/American_Cafe_%d.html"; static final String URL_POPULAR_AMERICAN = HOST + "/Popular_American_%d.html"; static final String URL_BUSINESS_ETIQUETTE = HOST + "/Business_Etiquette_%d.html"; static final String URL_SPORTS_ENGLISH = HOST + "/Sports_English_%d.html"; static final String URL_WORDS_AND_IDIOMS = HOST + "/Words_And_Idioms_%d.html"; // Article type_subtype -> private final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype ->
private final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>();
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/parser/voa51/Voa51DataSource.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // }
import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser;
package cn.yo2.aquarium.pocketvoa.parser.voa51; public class Voa51DataSource implements IDataSource { private static final String SEPERATOR = "_"; static final String HOST = "http://www.51voa.com"; // standard English static final String URL_ENGLISH_NEWS = HOST + "/VOA_Standard_%d.html"; // special English static final String URL_TECHNOLOGY_REPORT = HOST + "/Technology_Report_%d.html"; static final String URL_THIS_IS_AMERICA = HOST + "/This_is_America_%d.html"; static final String URL_AGRICULTURE_REPORT = HOST + "/Agriculture_Report_%d.html"; static final String URL_SCIENCE_IN_THE_NEWS = HOST + "/Science_in_the_News_%d.html"; static final String URL_HEALTH_REPORT = HOST + "/Health_Report_%d.html"; static final String URL_EXPLORATIONS = HOST + "/Explorations_%d.html"; static final String URL_EDUCATION_REPORT = HOST + "/Education_Report_%d.html"; static final String URL_THE_MAKING_OF_A_NATION = HOST+ "/The_Making_of_a_Nation_%d.html"; static final String URL_ECONOMICS_REPORT = HOST + "/Economics_Report_%d.html"; static final String URL_AMERICAN_MOSAIC = HOST + "/American_Mosaic_%d.html"; static final String URL_IN_THE_NEWS = HOST + "/In_the_News_%d.html"; static final String URL_AMERICAN_STORIES = HOST + "/American_Stories_%d.html"; static final String URL_WORDS_AND_THEIR_STORIES = HOST + "/Words_And_Their_Stories_%d.html"; static final String URL_PEOPLE_IN_AMERICA = HOST + "/People_in_America_%d.html"; // English learning static final String URL_GO_ENGLISH = HOST + "/Go_English_%d.html"; static final String URL_WORD_MASTER = HOST + "/Word_Master_%d.html"; static final String URL_AMERICAN_CAFE = HOST + "/American_Cafe_%d.html"; static final String URL_POPULAR_AMERICAN = HOST + "/Popular_American_%d.html"; static final String URL_BUSINESS_ETIQUETTE = HOST + "/Business_Etiquette_%d.html"; static final String URL_SPORTS_ENGLISH = HOST + "/Sports_English_%d.html"; static final String URL_WORDS_AND_IDIOMS = HOST + "/Words_And_Idioms_%d.html"; // Article type_subtype -> private final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype -> private final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>(); // Article type_subtype ->
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/parser/voa51/Voa51DataSource.java import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser; package cn.yo2.aquarium.pocketvoa.parser.voa51; public class Voa51DataSource implements IDataSource { private static final String SEPERATOR = "_"; static final String HOST = "http://www.51voa.com"; // standard English static final String URL_ENGLISH_NEWS = HOST + "/VOA_Standard_%d.html"; // special English static final String URL_TECHNOLOGY_REPORT = HOST + "/Technology_Report_%d.html"; static final String URL_THIS_IS_AMERICA = HOST + "/This_is_America_%d.html"; static final String URL_AGRICULTURE_REPORT = HOST + "/Agriculture_Report_%d.html"; static final String URL_SCIENCE_IN_THE_NEWS = HOST + "/Science_in_the_News_%d.html"; static final String URL_HEALTH_REPORT = HOST + "/Health_Report_%d.html"; static final String URL_EXPLORATIONS = HOST + "/Explorations_%d.html"; static final String URL_EDUCATION_REPORT = HOST + "/Education_Report_%d.html"; static final String URL_THE_MAKING_OF_A_NATION = HOST+ "/The_Making_of_a_Nation_%d.html"; static final String URL_ECONOMICS_REPORT = HOST + "/Economics_Report_%d.html"; static final String URL_AMERICAN_MOSAIC = HOST + "/American_Mosaic_%d.html"; static final String URL_IN_THE_NEWS = HOST + "/In_the_News_%d.html"; static final String URL_AMERICAN_STORIES = HOST + "/American_Stories_%d.html"; static final String URL_WORDS_AND_THEIR_STORIES = HOST + "/Words_And_Their_Stories_%d.html"; static final String URL_PEOPLE_IN_AMERICA = HOST + "/People_in_America_%d.html"; // English learning static final String URL_GO_ENGLISH = HOST + "/Go_English_%d.html"; static final String URL_WORD_MASTER = HOST + "/Word_Master_%d.html"; static final String URL_AMERICAN_CAFE = HOST + "/American_Cafe_%d.html"; static final String URL_POPULAR_AMERICAN = HOST + "/Popular_American_%d.html"; static final String URL_BUSINESS_ETIQUETTE = HOST + "/Business_Etiquette_%d.html"; static final String URL_SPORTS_ENGLISH = HOST + "/Sports_English_%d.html"; static final String URL_WORDS_AND_IDIOMS = HOST + "/Words_And_Idioms_%d.html"; // Article type_subtype -> private final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype -> private final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>(); // Article type_subtype ->
private final HashMap<String, IPageParser> mPageParsers = new HashMap<String, IPageParser>();
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/parser/iciba/IcibaDataSource.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // }
import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser;
package cn.yo2.aquarium.pocketvoa.parser.iciba; public class IcibaDataSource implements IDataSource { static final String HOST = "http://news.iciba.com"; // standard English static final String ENGLISH_NEWS = HOST + "/1598/index_1.html"; // special English static final String DEVELOPMENT_REPORT = HOST + "/1575/index_1.html"; static final String THIS_IS_AMERICA = HOST + "/1574/index_1.html"; static final String AGRICULTURE_REPORT = HOST + "/1573/index_1.html"; static final String SCIENCE_IN_THE_NEWS = HOST + "/1572/index_1.html"; static final String HEALTH_REPORT = HOST + "/1571/index_1.html"; static final String EXPLORATIONS = HOST + "/1576/index_1.html"; static final String EDUCATION_REPORT = HOST + "/1577/index_1.html"; static final String THE_MAKING_OF_A_NATION = HOST + "/1584/index_1.html"; static final String ECONOMICS_REPORT = HOST + "/1578/index_1.html"; static final String AMERICAN_MOSAIC = HOST + "/1581/index_1.html"; static final String IN_THE_NEWS = HOST + "/1583/index_1.html"; static final String AMERICAN_STORIES = HOST + "/1582/index_1.html"; static final String WORDS_AND_THEIR_STORIES = HOST + "/1580/index_1.html"; static final String PEOPLE_IN_AMERICA = HOST + "/1579/index_1.html"; // English learning static final String POPULAR_AMERICAN = HOST + "/1603/index_1.html"; public String getName() { return "www.iciba.com"; } // Article type_subtype -> public final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype ->
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/parser/iciba/IcibaDataSource.java import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser; package cn.yo2.aquarium.pocketvoa.parser.iciba; public class IcibaDataSource implements IDataSource { static final String HOST = "http://news.iciba.com"; // standard English static final String ENGLISH_NEWS = HOST + "/1598/index_1.html"; // special English static final String DEVELOPMENT_REPORT = HOST + "/1575/index_1.html"; static final String THIS_IS_AMERICA = HOST + "/1574/index_1.html"; static final String AGRICULTURE_REPORT = HOST + "/1573/index_1.html"; static final String SCIENCE_IN_THE_NEWS = HOST + "/1572/index_1.html"; static final String HEALTH_REPORT = HOST + "/1571/index_1.html"; static final String EXPLORATIONS = HOST + "/1576/index_1.html"; static final String EDUCATION_REPORT = HOST + "/1577/index_1.html"; static final String THE_MAKING_OF_A_NATION = HOST + "/1584/index_1.html"; static final String ECONOMICS_REPORT = HOST + "/1578/index_1.html"; static final String AMERICAN_MOSAIC = HOST + "/1581/index_1.html"; static final String IN_THE_NEWS = HOST + "/1583/index_1.html"; static final String AMERICAN_STORIES = HOST + "/1582/index_1.html"; static final String WORDS_AND_THEIR_STORIES = HOST + "/1580/index_1.html"; static final String PEOPLE_IN_AMERICA = HOST + "/1579/index_1.html"; // English learning static final String POPULAR_AMERICAN = HOST + "/1603/index_1.html"; public String getName() { return "www.iciba.com"; } // Article type_subtype -> public final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype ->
public final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>();
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/parser/iciba/IcibaDataSource.java
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // }
import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser;
package cn.yo2.aquarium.pocketvoa.parser.iciba; public class IcibaDataSource implements IDataSource { static final String HOST = "http://news.iciba.com"; // standard English static final String ENGLISH_NEWS = HOST + "/1598/index_1.html"; // special English static final String DEVELOPMENT_REPORT = HOST + "/1575/index_1.html"; static final String THIS_IS_AMERICA = HOST + "/1574/index_1.html"; static final String AGRICULTURE_REPORT = HOST + "/1573/index_1.html"; static final String SCIENCE_IN_THE_NEWS = HOST + "/1572/index_1.html"; static final String HEALTH_REPORT = HOST + "/1571/index_1.html"; static final String EXPLORATIONS = HOST + "/1576/index_1.html"; static final String EDUCATION_REPORT = HOST + "/1577/index_1.html"; static final String THE_MAKING_OF_A_NATION = HOST + "/1584/index_1.html"; static final String ECONOMICS_REPORT = HOST + "/1578/index_1.html"; static final String AMERICAN_MOSAIC = HOST + "/1581/index_1.html"; static final String IN_THE_NEWS = HOST + "/1583/index_1.html"; static final String AMERICAN_STORIES = HOST + "/1582/index_1.html"; static final String WORDS_AND_THEIR_STORIES = HOST + "/1580/index_1.html"; static final String PEOPLE_IN_AMERICA = HOST + "/1579/index_1.html"; // English learning static final String POPULAR_AMERICAN = HOST + "/1603/index_1.html"; public String getName() { return "www.iciba.com"; } // Article type_subtype -> public final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype -> public final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>(); // Article type_subtype ->
// Path: src/cn/yo2/aquarium/pocketvoa/parser/IDataSource.java // public interface IDataSource { // // /*========================================================================= // * First category // ========================================================================*/ // public static final String STANDARD_ENGLISH = "Standard English"; // public static final String SPECIAL_ENGLISH = "Special English"; // public static final String ENGLISH_LEARNING = "English Learning"; // // /*========================================================================= // * Second category // ========================================================================*/ // /* // * Standard English // */ // public static final String ENGLISH_NEWS = "English News"; // /* // * Special English // */ // public static final String TECHNOLOGY_REPORT = "Technology Report"; // public static final String THIS_IS_AMERICA = "This is America"; // public static final String AGRICULTURE_REPORT = "Agriculture Report"; // public static final String SCIENCE_IN_THE_NEWS = "Science in the News"; // public static final String HEALTH_REPORT = "Health Report"; // public static final String EXPLORATIONS = "Explorations"; // public static final String EDUCATION_REPORT = "Education Report"; // public static final String THE_MAKING_OF_A_NATION = "The Making of a Nation"; // public static final String ECONOMICS_REPORT = "Economics Report"; // public static final String AMERICAN_MOSAIC = "American Mosaic"; // public static final String IN_THE_NEWS = "In the News"; // public static final String AMERICAN_STORIES = "American Stories"; // public static final String WORDS_AND_THEIR_STORIES = "Words And Their Stories"; // public static final String PEOPLE_IN_AMERICA = "People in America"; // /* // * English Learning // */ // public static final String GO_ENGLISH = "Go English"; // public static final String WORD_MASTER = "Word Master"; // public static final String AMERICAN_CAFE = "American Cafe"; // public static final String POPULAR_AMERICAN = "Popular American"; // public static final String BUSINESS_ETIQUETTE = "Business Etiquette"; // public static final String SPORTS_ENGLISH = "Sports English"; // public static final String WORDS_AND_IDIOMS = "Words And Idioms"; // // // public void init(int maxCount); // // public HashMap<String, String> getListUrls(); // public HashMap<String, IListParser> getListParsers(); // public HashMap<String, IPageParser> getPageParsers(); // public HashMap<String, IPageParser> getPageZhParsers(); // // public String getName(); // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IListParser.java // public interface IListParser { // public ArrayList<Article> parse(String body) throws IllegalContentFormatException; // public int parsePageCount(String body) throws IllegalContentFormatException; // } // // Path: src/cn/yo2/aquarium/pocketvoa/parser/IPageParser.java // public interface IPageParser { // public void parse(Article article, String body) throws IllegalContentFormatException; // } // Path: src/cn/yo2/aquarium/pocketvoa/parser/iciba/IcibaDataSource.java import java.util.HashMap; import cn.yo2.aquarium.pocketvoa.parser.IDataSource; import cn.yo2.aquarium.pocketvoa.parser.IListParser; import cn.yo2.aquarium.pocketvoa.parser.IPageParser; package cn.yo2.aquarium.pocketvoa.parser.iciba; public class IcibaDataSource implements IDataSource { static final String HOST = "http://news.iciba.com"; // standard English static final String ENGLISH_NEWS = HOST + "/1598/index_1.html"; // special English static final String DEVELOPMENT_REPORT = HOST + "/1575/index_1.html"; static final String THIS_IS_AMERICA = HOST + "/1574/index_1.html"; static final String AGRICULTURE_REPORT = HOST + "/1573/index_1.html"; static final String SCIENCE_IN_THE_NEWS = HOST + "/1572/index_1.html"; static final String HEALTH_REPORT = HOST + "/1571/index_1.html"; static final String EXPLORATIONS = HOST + "/1576/index_1.html"; static final String EDUCATION_REPORT = HOST + "/1577/index_1.html"; static final String THE_MAKING_OF_A_NATION = HOST + "/1584/index_1.html"; static final String ECONOMICS_REPORT = HOST + "/1578/index_1.html"; static final String AMERICAN_MOSAIC = HOST + "/1581/index_1.html"; static final String IN_THE_NEWS = HOST + "/1583/index_1.html"; static final String AMERICAN_STORIES = HOST + "/1582/index_1.html"; static final String WORDS_AND_THEIR_STORIES = HOST + "/1580/index_1.html"; static final String PEOPLE_IN_AMERICA = HOST + "/1579/index_1.html"; // English learning static final String POPULAR_AMERICAN = HOST + "/1603/index_1.html"; public String getName() { return "www.iciba.com"; } // Article type_subtype -> public final HashMap<String, String> mListUrls = new HashMap<String, String>(); // Article type_subtype -> public final HashMap<String, IListParser> mListParsers = new HashMap<String, IListParser>(); // Article type_subtype ->
public final HashMap<String, IPageParser> mPageParsers = new HashMap<String, IPageParser>();
shaobin0604/pocket-voa
src/cn/yo2/aquarium/pocketvoa/parser/AbstractListParser.java
// Path: src/cn/yo2/aquarium/pocketvoa/IllegalContentFormatException.java // public class IllegalContentFormatException extends Exception { // // /** // * // */ // private static final long serialVersionUID = 1L; // // public IllegalContentFormatException() { // super(); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(String detailMessage, // Throwable throwable) { // super(detailMessage, throwable); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(String detailMessage) { // super(detailMessage); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(Throwable throwable) { // super(throwable); // // TODO Auto-generated constructor stub // } // // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import android.util.Log; import cn.yo2.aquarium.pocketvoa.IllegalContentFormatException;
package cn.yo2.aquarium.pocketvoa.parser; public abstract class AbstractListParser implements IListParser { private static final String TAG = AbstractListParser.class.getSimpleName(); protected String mType; protected String mSubtype; public AbstractListParser(String type, String subtype) { super(); this.mType = type; this.mSubtype = subtype; } @Override
// Path: src/cn/yo2/aquarium/pocketvoa/IllegalContentFormatException.java // public class IllegalContentFormatException extends Exception { // // /** // * // */ // private static final long serialVersionUID = 1L; // // public IllegalContentFormatException() { // super(); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(String detailMessage, // Throwable throwable) { // super(detailMessage, throwable); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(String detailMessage) { // super(detailMessage); // // TODO Auto-generated constructor stub // } // // public IllegalContentFormatException(Throwable throwable) { // super(throwable); // // TODO Auto-generated constructor stub // } // // } // Path: src/cn/yo2/aquarium/pocketvoa/parser/AbstractListParser.java import java.util.regex.Matcher; import java.util.regex.Pattern; import android.util.Log; import cn.yo2.aquarium.pocketvoa.IllegalContentFormatException; package cn.yo2.aquarium.pocketvoa.parser; public abstract class AbstractListParser implements IListParser { private static final String TAG = AbstractListParser.class.getSimpleName(); protected String mType; protected String mSubtype; public AbstractListParser(String type, String subtype) { super(); this.mType = type; this.mSubtype = subtype; } @Override
public int parsePageCount(String body) throws IllegalContentFormatException {
6thsolution/EasyMVP
easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Observable;
package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * The presenter simply subscribes to {@link Observable} returned by the {@link #execute(Object)} method. * * @param <R> The response value emitted by the Observable. * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Observable */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final Observable.Transformer<? super R, ? extends R> schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Observable; package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * The presenter simply subscribes to {@link Observable} returned by the {@link #execute(Object)} method. * * @param <R> The response value emitted by the Observable. * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Observable */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final Observable.Transformer<? super R, ? extends R> schedulersTransformer;
public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Observable;
package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * The presenter simply subscribes to {@link Observable} returned by the {@link #execute(Object)} method. * * @param <R> The response value emitted by the Observable. * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Observable */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final Observable.Transformer<? super R, ? extends R> schedulersTransformer; public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Observable; package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * The presenter simply subscribes to {@link Observable} returned by the {@link #execute(Object)} method. * * @param <R> The response value emitted by the Observable. * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Observable */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final Observable.Transformer<? super R, ? extends R> schedulersTransformer; public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/ViewType.java // public enum ViewType { // // ACTIVITY, // SUPPORT_ACTIVITY, // FRAGMENT, // SUPPORT_FRAGMENT, // CUSTOM_VIEW, // CONDUCTOR_CONTROLLER // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public final class ClassNames { // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // public static final ClassName BUNDLE = ClassName.get("android.os", "Bundle"); // public static final ClassName WEAK_REFERENCE = ClassName.get("java.lang.ref", "WeakReference"); // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider"); // public static final ClassName APPCOMPAT_ACTIVITY_CLASS = // ClassName.get("android.support.v7.app", "AppCompatActivity"); // public static final ClassName CONTEXT_WRAPPER = // ClassName.get("android.content", "ContextWrapper"); // public static final ClassName VIEW_DELEGATE = // ClassName.get("easymvp.internal", "ViewDelegate"); // //loaders related class names // public static final ClassName LOADER = ClassName.get("android.content", "Loader"); // public static final ClassName SUPPORT_LOADER = // ClassName.get("android.support.v4.content", "Loader"); // public static final ClassName LOADER_MANAGER = ClassName.get("android.app", "LoaderManager"); // public static final ClassName SUPPORT_LOADER_MANAGER = // ClassName.get("android.support.v4.app", "LoaderManager"); // // public static final ClassName LOADER_CALLBACKS = // ClassName.get("android.app.LoaderManager", "LoaderCallbacks"); // // public static final ClassName SUPPORT_LOADER_CALLBACKS = // ClassName.get("android.support.v4.app.LoaderManager", "LoaderCallbacks"); // // public static final ClassName PRESENTER_LOADER = // ClassName.get("easymvp.loader", "PresenterLoader"); // public static final ClassName SUPPORT_PRESENTER_LOADER = // ClassName.get("easymvp.loader", "SupportPresenterLoader"); // // }
import com.squareup.javapoet.ClassName; import easymvp.compiler.ViewType; import static easymvp.compiler.util.ClassNames.*;
package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class AndroidLoaderUtils { static ClassName getLoader(boolean supportLibrary) { return get(supportLibrary, SUPPORT_LOADER, LOADER); }
// Path: easymvp-compiler/src/main/java/easymvp/compiler/ViewType.java // public enum ViewType { // // ACTIVITY, // SUPPORT_ACTIVITY, // FRAGMENT, // SUPPORT_FRAGMENT, // CUSTOM_VIEW, // CONDUCTOR_CONTROLLER // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public final class ClassNames { // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // public static final ClassName BUNDLE = ClassName.get("android.os", "Bundle"); // public static final ClassName WEAK_REFERENCE = ClassName.get("java.lang.ref", "WeakReference"); // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider"); // public static final ClassName APPCOMPAT_ACTIVITY_CLASS = // ClassName.get("android.support.v7.app", "AppCompatActivity"); // public static final ClassName CONTEXT_WRAPPER = // ClassName.get("android.content", "ContextWrapper"); // public static final ClassName VIEW_DELEGATE = // ClassName.get("easymvp.internal", "ViewDelegate"); // //loaders related class names // public static final ClassName LOADER = ClassName.get("android.content", "Loader"); // public static final ClassName SUPPORT_LOADER = // ClassName.get("android.support.v4.content", "Loader"); // public static final ClassName LOADER_MANAGER = ClassName.get("android.app", "LoaderManager"); // public static final ClassName SUPPORT_LOADER_MANAGER = // ClassName.get("android.support.v4.app", "LoaderManager"); // // public static final ClassName LOADER_CALLBACKS = // ClassName.get("android.app.LoaderManager", "LoaderCallbacks"); // // public static final ClassName SUPPORT_LOADER_CALLBACKS = // ClassName.get("android.support.v4.app.LoaderManager", "LoaderCallbacks"); // // public static final ClassName PRESENTER_LOADER = // ClassName.get("easymvp.loader", "PresenterLoader"); // public static final ClassName SUPPORT_PRESENTER_LOADER = // ClassName.get("easymvp.loader", "SupportPresenterLoader"); // // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java import com.squareup.javapoet.ClassName; import easymvp.compiler.ViewType; import static easymvp.compiler.util.ClassNames.*; package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class AndroidLoaderUtils { static ClassName getLoader(boolean supportLibrary) { return get(supportLibrary, SUPPORT_LOADER, LOADER); }
static ClassName getLoader(ViewType viewType) {
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider");
import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER;
package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public final class PresenterLoaderGenerator extends ClassGenerator { private static final String METHOD_GET_PRESENTER = "get"; private static final TypeName PRESENTER_FACTORY_FIELD =
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider"); // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER; package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public final class PresenterLoaderGenerator extends ClassGenerator { private static final String METHOD_GET_PRESENTER = "get"; private static final TypeName PRESENTER_FACTORY_FIELD =
ParameterizedTypeName.get(PROVIDER, TypeVariableName.get("P"));
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider");
import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER;
package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public final class PresenterLoaderGenerator extends ClassGenerator { private static final String METHOD_GET_PRESENTER = "get"; private static final TypeName PRESENTER_FACTORY_FIELD = ParameterizedTypeName.get(PROVIDER, TypeVariableName.get("P")); //All generated fields for our custom loader private static final String FIELD_PRESENTER = "presenter"; private static final String FIELD_PRESENTER_FACTORY = "presenterFactory"; //All methods that MUST be implemented private static final String METHOD_ON_START_LOADING = "onStartLoading"; private static final String METHOD_ON_FORCE_LOAD = "onForceLoad"; private static final String METHOD_ON_RESET = "onReset"; private boolean supportLibrary; public PresenterLoaderGenerator(boolean supportLibrary) { super(AndroidLoaderUtils.getPresenterLoader(supportLibrary).packageName(), AndroidLoaderUtils.getPresenterLoader(supportLibrary).simpleName()); this.supportLibrary = supportLibrary; } @Override public JavaFile build() { TypeSpec.Builder result = TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC)
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider"); // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER; package easymvp.compiler.generator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public final class PresenterLoaderGenerator extends ClassGenerator { private static final String METHOD_GET_PRESENTER = "get"; private static final TypeName PRESENTER_FACTORY_FIELD = ParameterizedTypeName.get(PROVIDER, TypeVariableName.get("P")); //All generated fields for our custom loader private static final String FIELD_PRESENTER = "presenter"; private static final String FIELD_PRESENTER_FACTORY = "presenterFactory"; //All methods that MUST be implemented private static final String METHOD_ON_START_LOADING = "onStartLoading"; private static final String METHOD_ON_FORCE_LOAD = "onForceLoad"; private static final String METHOD_ON_RESET = "onReset"; private boolean supportLibrary; public PresenterLoaderGenerator(boolean supportLibrary) { super(AndroidLoaderUtils.getPresenterLoader(supportLibrary).packageName(), AndroidLoaderUtils.getPresenterLoader(supportLibrary).simpleName()); this.supportLibrary = supportLibrary; } @Override public JavaFile build() { TypeSpec.Builder result = TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC)
.addTypeVariable(TypeVariableName.get("P", Presenter.class))
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider");
import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER;
private static final String FIELD_PRESENTER_FACTORY = "presenterFactory"; //All methods that MUST be implemented private static final String METHOD_ON_START_LOADING = "onStartLoading"; private static final String METHOD_ON_FORCE_LOAD = "onForceLoad"; private static final String METHOD_ON_RESET = "onReset"; private boolean supportLibrary; public PresenterLoaderGenerator(boolean supportLibrary) { super(AndroidLoaderUtils.getPresenterLoader(supportLibrary).packageName(), AndroidLoaderUtils.getPresenterLoader(supportLibrary).simpleName()); this.supportLibrary = supportLibrary; } @Override public JavaFile build() { TypeSpec.Builder result = TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) .addTypeVariable(TypeVariableName.get("P", Presenter.class)) .superclass(ParameterizedTypeName.get(AndroidLoaderUtils.getLoader(supportLibrary), TypeVariableName.get("P"))); addConstructor(result); addFields(result); addMethods(result); return JavaFile.builder(getPackageName(), result.build()) .addFileComment("Generated class from EasyMVP. Do not modify!").build(); } private void addConstructor(TypeSpec.Builder result) { result.addMethod(MethodSpec.constructorBuilder()
// Path: easymvp-api/src/main/java/easymvp/Presenter.java // public interface Presenter<V> { // // /** // * Called when the view attached to the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStart()}, {@link android.app.Fragment#onResume()} // * and {@link android.view.View#onAttachedToWindow()}. // * @param view the view that the presenter interacts with // */ // void onViewAttached(V view); // // /** // * Called when the view detached from the screen. // * <p> // * This method will be invoked during {@link android.app.Activity#onStop()}, {@link android.app.Fragment#onPause()} // * and {@link android.view.View#onDetachedFromWindow()}. // */ // void onViewDetached(); // // /** // * Called when a user leaves the view completely. After the invocation of this method, presenter instance will be destroyed. // * <p> // * Note that on configuration changes like rotation, presenter instance will be alive. // */ // void onDestroyed(); // // /** // * @return Returns true if the view is currently attached to the presenter, otherwise returns false. // **/ // boolean isViewAttached(); // // /** // * @return Returns the attached view. If view is already detached, null will be returned. // */ // @Nullable // V getView(); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName CONTEXT = ClassName.get("android.content", "Context"); // // Path: easymvp-compiler/src/main/java/easymvp/compiler/util/ClassNames.java // public static final ClassName PROVIDER = ClassName.get("javax.inject", "Provider"); // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/PresenterLoaderGenerator.java import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import com.squareup.javapoet.TypeVariableName; import javax.lang.model.element.Modifier; import easymvp.Presenter; import static easymvp.compiler.util.ClassNames.CONTEXT; import static easymvp.compiler.util.ClassNames.PROVIDER; private static final String FIELD_PRESENTER_FACTORY = "presenterFactory"; //All methods that MUST be implemented private static final String METHOD_ON_START_LOADING = "onStartLoading"; private static final String METHOD_ON_FORCE_LOAD = "onForceLoad"; private static final String METHOD_ON_RESET = "onReset"; private boolean supportLibrary; public PresenterLoaderGenerator(boolean supportLibrary) { super(AndroidLoaderUtils.getPresenterLoader(supportLibrary).packageName(), AndroidLoaderUtils.getPresenterLoader(supportLibrary).simpleName()); this.supportLibrary = supportLibrary; } @Override public JavaFile build() { TypeSpec.Builder result = TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) .addTypeVariable(TypeVariableName.get("P", Presenter.class)) .superclass(ParameterizedTypeName.get(AndroidLoaderUtils.getLoader(supportLibrary), TypeVariableName.get("P"))); addConstructor(result); addFields(result); addMethods(result); return JavaFile.builder(getPackageName(), result.build()) .addFileComment("Generated class from EasyMVP. Do not modify!").build(); } private void addConstructor(TypeSpec.Builder result) { result.addMethod(MethodSpec.constructorBuilder()
.addParameter(CONTEXT, "context")
6thsolution/EasyMVP
easymvp-test/src/main/java/com/sixthsolution/easymvp/test/SimpleCustomViewWithDagger.java
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java // @Singleton // @Component // public interface ActivityComponent { // // CustomViewComponent.Builder customViewComponent(); // // void injectTo(AppCompatActivityWithMultiViewsWithDagger activity); // } // // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomViewComponent.java // @CustomScope // @Subcomponent(modules = CustomModule.class) // public interface CustomViewComponent { // // void injectTo(SimpleCustomViewWithDagger simpleCustomViewWithDagger); // // @Subcomponent.Builder // interface Builder { // CustomViewComponent build(); // } // }
import android.content.Context; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.View; import com.sixthsolution.easymvp.test.di.ActivityComponent; import com.sixthsolution.easymvp.test.di.CustomViewComponent; import javax.inject.Inject; import easymvp.annotation.CustomView; import easymvp.annotation.Presenter; import easymvp.annotation.PresenterId; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue;
package com.sixthsolution.easymvp.test; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ @CustomView(presenter = TestPresenter.class) public class SimpleCustomViewWithDagger extends View implements View1 { @Inject @Presenter TestPresenter testPresenter; @PresenterId int presenterId = 1_000; public SimpleCustomViewWithDagger(Context context) { super(context); } public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java // @Singleton // @Component // public interface ActivityComponent { // // CustomViewComponent.Builder customViewComponent(); // // void injectTo(AppCompatActivityWithMultiViewsWithDagger activity); // } // // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomViewComponent.java // @CustomScope // @Subcomponent(modules = CustomModule.class) // public interface CustomViewComponent { // // void injectTo(SimpleCustomViewWithDagger simpleCustomViewWithDagger); // // @Subcomponent.Builder // interface Builder { // CustomViewComponent build(); // } // } // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/SimpleCustomViewWithDagger.java import android.content.Context; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.View; import com.sixthsolution.easymvp.test.di.ActivityComponent; import com.sixthsolution.easymvp.test.di.CustomViewComponent; import javax.inject.Inject; import easymvp.annotation.CustomView; import easymvp.annotation.Presenter; import easymvp.annotation.PresenterId; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; package com.sixthsolution.easymvp.test; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ @CustomView(presenter = TestPresenter.class) public class SimpleCustomViewWithDagger extends View implements View1 { @Inject @Presenter TestPresenter testPresenter; @PresenterId int presenterId = 1_000; public SimpleCustomViewWithDagger(Context context) { super(context); } public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
public SimpleCustomViewWithDagger(Context context, int counter, ActivityComponent component) {
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/FlowableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Flowable; import io.reactivex.FlowableTransformer;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class FlowableUseCase<R, Q> extends UseCase<Flowable, Q> { private final FlowableTransformer<? super R, ? extends R> schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/FlowableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Flowable; import io.reactivex.FlowableTransformer; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class FlowableUseCase<R, Q> extends UseCase<Flowable, Q> { private final FlowableTransformer<? super R, ? extends R> schedulersTransformer;
public FlowableUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/FlowableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Flowable; import io.reactivex.FlowableTransformer;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class FlowableUseCase<R, Q> extends UseCase<Flowable, Q> { private final FlowableTransformer<? super R, ? extends R> schedulersTransformer; public FlowableUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/FlowableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Flowable; import io.reactivex.FlowableTransformer; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class FlowableUseCase<R, Q> extends UseCase<Flowable, Q> { private final FlowableTransformer<? super R, ? extends R> schedulersTransformer; public FlowableUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()")
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()")
.returns(getSupportLoaderManager())
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() {
return getSupportPresenterLoader();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
return getSupportLoaderCallbacks();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getSupportLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportActivityDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportActivityDecorator extends ActivityDecorator { public SupportActivityDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getSupportLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getSupportLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
return getSupportLoader();
6thsolution/EasyMVP
easymvp-rx-api/src/main/java/easymvp/usecase/UseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Scheduler;
package easymvp.usecase; /** * Each {@code UseCase} of the system orchestrate the flow of data to and from the entities. * <p> * Outer layers of system can execute use cases by calling {@link #execute(Object)}} method. Also * you can use {@link #useCaseExecutor} to execute the job in a background thread and {@link * #postExecutionThread} to post the result to another thread(usually UI thread). * * @param <P> The response type of a use case. * @param <Q> The request type of a use case. * @author Saeed Masoumi (saeed@6thsolution.com) */ public abstract class UseCase<P, Q> { private final UseCaseExecutor useCaseExecutor;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx-api/src/main/java/easymvp/usecase/UseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Scheduler; package easymvp.usecase; /** * Each {@code UseCase} of the system orchestrate the flow of data to and from the entities. * <p> * Outer layers of system can execute use cases by calling {@link #execute(Object)}} method. Also * you can use {@link #useCaseExecutor} to execute the job in a background thread and {@link * #postExecutionThread} to post the result to another thread(usually UI thread). * * @param <P> The response type of a use case. * @param <Q> The request type of a use case. * @author Saeed Masoumi (saeed@6thsolution.com) */ public abstract class UseCase<P, Q> { private final UseCaseExecutor useCaseExecutor;
private final PostExecutionThread postExecutionThread;
6thsolution/EasyMVP
easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomViewComponent.java
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/SimpleCustomViewWithDagger.java // @CustomView(presenter = TestPresenter.class) // public class SimpleCustomViewWithDagger extends View implements View1 { // // @Inject // @Presenter // TestPresenter testPresenter; // // @PresenterId // int presenterId = 1_000; // // // public SimpleCustomViewWithDagger(Context context) { // super(context); // } // // public SimpleCustomViewWithDagger(Context context, // @Nullable AttributeSet attrs) { // super(context, attrs); // } // // public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // public SimpleCustomViewWithDagger(Context context, int counter, ActivityComponent component) { // super(context); // presenterId += counter; // component.customViewComponent().build().injectTo(this); // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // assertNotNull(testPresenter); // assertTrue(testPresenter.isOnViewAttachedCalled()); // } // }
import com.sixthsolution.easymvp.test.SimpleCustomViewWithDagger; import dagger.Subcomponent;
package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @CustomScope @Subcomponent(modules = CustomModule.class) public interface CustomViewComponent {
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/SimpleCustomViewWithDagger.java // @CustomView(presenter = TestPresenter.class) // public class SimpleCustomViewWithDagger extends View implements View1 { // // @Inject // @Presenter // TestPresenter testPresenter; // // @PresenterId // int presenterId = 1_000; // // // public SimpleCustomViewWithDagger(Context context) { // super(context); // } // // public SimpleCustomViewWithDagger(Context context, // @Nullable AttributeSet attrs) { // super(context, attrs); // } // // public SimpleCustomViewWithDagger(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // public SimpleCustomViewWithDagger(Context context, int counter, ActivityComponent component) { // super(context); // presenterId += counter; // component.customViewComponent().build().injectTo(this); // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // assertNotNull(testPresenter); // assertTrue(testPresenter.isOnViewAttachedCalled()); // } // } // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomViewComponent.java import com.sixthsolution.easymvp.test.SimpleCustomViewWithDagger; import dagger.Subcomponent; package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @CustomScope @Subcomponent(modules = CustomModule.class) public interface CustomViewComponent {
void injectTo(SimpleCustomViewWithDagger simpleCustomViewWithDagger);
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()")
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()")
.returns(getSupportLoaderManager())
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() {
return getSupportPresenterLoader();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
return getSupportLoaderCallbacks();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getSupportLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoader() { // return SUPPORT_LOADER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderCallbacks() { // return SUPPORT_LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportLoaderManager() { // return SUPPORT_LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getSupportPresenterLoader() { // return SUPPORT_PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/SupportFragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getSupportPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class SupportFragmentDecorator extends BaseDecorator { public SupportFragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getSupportLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getSupportPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getSupportLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
return getSupportLoader();
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/UseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Scheduler; import javax.annotation.Nullable;
package easymvp.usecase; /** * Each {@code UseCase} of the system orchestrate the flow of data to and from the entities. * <p> * Outer layers of system can execute use cases by calling {@link #execute(Object)}} method. Also * you can use {@link #useCaseExecutor} to execute the job in a background thread and {@link * #postExecutionThread} to post the result to another thread(usually UI thread). * * @param <P> The response type of a use case. * @param <Q> The request type of a use case. * Created by megrez on 2017/3/12. */ public abstract class UseCase<P,Q> { private final UseCaseExecutor useCaseExecutor;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/UseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Scheduler; import javax.annotation.Nullable; package easymvp.usecase; /** * Each {@code UseCase} of the system orchestrate the flow of data to and from the entities. * <p> * Outer layers of system can execute use cases by calling {@link #execute(Object)}} method. Also * you can use {@link #useCaseExecutor} to execute the job in a background thread and {@link * #postExecutionThread} to post the result to another thread(usually UI thread). * * @param <P> The response type of a use case. * @param <Q> The request type of a use case. * Created by megrez on 2017/3/12. */ public abstract class UseCase<P,Q> { private final UseCaseExecutor useCaseExecutor;
private final PostExecutionThread postExecutionThread;
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()")
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()")
.returns(getLoaderManager())
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() {
return getPresenterLoader();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() {
return getLoaderCallbacks();
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class FragmentDecorator extends BaseDecorator { public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getLoaderManager()") .returns(getLoaderManager()) .build(); } @Override public String createContextField(String viewField) { return "final $T context = " + viewField + ".getActivity().getApplicationContext()"; } @Override protected void implementInitializer(MethodSpec.Builder method) { } @Override protected ClassName getPresenterLoaderClass() { return getPresenterLoader(); } @Override protected ClassName getLoaderCallbacksClass() { return getLoaderCallbacks(); } @Override protected ClassName getLoaderClass() {
return getLoader();
6thsolution/EasyMVP
easymvp-rx-api/src/main/java/easymvp/usecase/CompletableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Completable;
package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * It's useful for use-cases without any response value. * * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Completable */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final Completable.Transformer schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx-api/src/main/java/easymvp/usecase/CompletableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Completable; package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * It's useful for use-cases without any response value. * * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Completable */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final Completable.Transformer schedulersTransformer;
public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx-api/src/main/java/easymvp/usecase/CompletableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Completable;
package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * It's useful for use-cases without any response value. * * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Completable */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final Completable.Transformer schedulersTransformer; public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx-api/src/main/java/easymvp/usecase/CompletableUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Completable; package easymvp.usecase; /** * Reactive version of a {@link UseCase}. * <p> * It's useful for use-cases without any response value. * * @param <Q> The request value. * @author Saeed Masoumi (saeed@6thsolution.com) * @see Completable */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final Completable.Transformer schedulersTransformer; public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-test/src/test/java/com/sixthsolution/easymvp/test/usecase/UseCaseTest.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import org.junit.Before; import org.junit.Test; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Scheduler; import rx.observers.TestSubscriber; import rx.schedulers.Schedulers;
package com.sixthsolution.easymvp.test.usecase; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class UseCaseTest { private UseCaseExecutor useCaseExecutor;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-test/src/test/java/com/sixthsolution/easymvp/test/usecase/UseCaseTest.java import org.junit.Before; import org.junit.Test; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import rx.Scheduler; import rx.observers.TestSubscriber; import rx.schedulers.Schedulers; package com.sixthsolution.easymvp.test.usecase; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class UseCaseTest { private UseCaseExecutor useCaseExecutor;
private PostExecutionThread postExecutionThread;
6thsolution/EasyMVP
easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomModule.java
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/TestPresenter.java // public class TestPresenter extends AbstractPresenter<View1> { // // private boolean isOnViewAttachedCalled = false; // private boolean isOnViewDetachedCalled = false; // private static int counter = 0; // public int count = counter++; // // @Override // public void onViewAttached(View1 view) { // super.onViewAttached(view); // isOnViewAttachedCalled = true; // Log.d("TestPresenter","onViewAttached Called"); // // } // // @Override // public void onViewDetached() { // super.onViewDetached(); // isOnViewDetachedCalled = true; // Log.d("TestPresenter","onViewDetached Called"); // } // // @Override // public void onDestroyed() { // super.onDestroyed(); // Log.d("TestPresenter","OnDestroyed Called"); // } // // public boolean isOnViewAttachedCalled() { // return isOnViewAttachedCalled; // } // // public boolean isOnViewDetachedCalled() { // return isOnViewDetachedCalled; // } // // // }
import com.sixthsolution.easymvp.test.TestPresenter; import dagger.Module; import dagger.Provides;
package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @Module public class CustomModule { @CustomScope @Provides
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/TestPresenter.java // public class TestPresenter extends AbstractPresenter<View1> { // // private boolean isOnViewAttachedCalled = false; // private boolean isOnViewDetachedCalled = false; // private static int counter = 0; // public int count = counter++; // // @Override // public void onViewAttached(View1 view) { // super.onViewAttached(view); // isOnViewAttachedCalled = true; // Log.d("TestPresenter","onViewAttached Called"); // // } // // @Override // public void onViewDetached() { // super.onViewDetached(); // isOnViewDetachedCalled = true; // Log.d("TestPresenter","onViewDetached Called"); // } // // @Override // public void onDestroyed() { // super.onDestroyed(); // Log.d("TestPresenter","OnDestroyed Called"); // } // // public boolean isOnViewAttachedCalled() { // return isOnViewAttachedCalled; // } // // public boolean isOnViewDetachedCalled() { // return isOnViewDetachedCalled; // } // // // } // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/CustomModule.java import com.sixthsolution.easymvp.test.TestPresenter; import dagger.Module; import dagger.Provides; package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @Module public class CustomModule { @CustomScope @Provides
public TestPresenter providePresenter() {
6thsolution/EasyMVP
easymvp-test/src/main/java/com/sixthsolution/easymvp/test/AppCompatActivityWithMultiViewsWithDagger.java
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java // @Singleton // @Component // public interface ActivityComponent { // // CustomViewComponent.Builder customViewComponent(); // // void injectTo(AppCompatActivityWithMultiViewsWithDagger activity); // }
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.LinearLayout; import com.sixthsolution.easymvp.test.di.ActivityComponent; import com.sixthsolution.easymvp.test.di.DaggerActivityComponent; import java.util.HashSet; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import easymvp.annotation.ActivityView; import easymvp.annotation.Presenter; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat;
package com.sixthsolution.easymvp.test; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @ActivityView(presenter = TestPresenter.class, layout = R.layout.activity_multi_views) public class AppCompatActivityWithMultiViewsWithDagger extends AppCompatActivity implements View1 { @Presenter TestPresenter testPresenter; @BindView(R.id.container) LinearLayout container; @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java // @Singleton // @Component // public interface ActivityComponent { // // CustomViewComponent.Builder customViewComponent(); // // void injectTo(AppCompatActivityWithMultiViewsWithDagger activity); // } // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/AppCompatActivityWithMultiViewsWithDagger.java import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.LinearLayout; import com.sixthsolution.easymvp.test.di.ActivityComponent; import com.sixthsolution.easymvp.test.di.DaggerActivityComponent; import java.util.HashSet; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import easymvp.annotation.ActivityView; import easymvp.annotation.Presenter; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; package com.sixthsolution.easymvp.test; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @ActivityView(presenter = TestPresenter.class, layout = R.layout.activity_multi_views) public class AppCompatActivityWithMultiViewsWithDagger extends AppCompatActivity implements View1 { @Presenter TestPresenter testPresenter; @BindView(R.id.container) LinearLayout container; @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
ActivityComponent component =
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/ObservableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Observable; import io.reactivex.ObservableTransformer; import javax.annotation.Nullable;
package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final ObservableTransformer<? super R, ? extends R> schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/ObservableUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Observable; import io.reactivex.ObservableTransformer; import javax.annotation.Nullable; package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final ObservableTransformer<? super R, ? extends R> schedulersTransformer;
public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/ObservableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Observable; import io.reactivex.ObservableTransformer; import javax.annotation.Nullable;
package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final ObservableTransformer<? super R, ? extends R> schedulersTransformer; public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/ObservableUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Observable; import io.reactivex.ObservableTransformer; import javax.annotation.Nullable; package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { private final ObservableTransformer<? super R, ? extends R> schedulersTransformer; public ObservableUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // }
import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector;
AfterSuper(classInjector, onAttachedToWindow, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE); // afterSuperWithReturnType(classInjector, onDetachedFromWindow, STATEMENT_CALL_DETACH); } private void injectDelegateLifeCycleIntoConductorController(CtClass ctClass, ClassInjector classInjector) throws Exception { CtMethod onCreateView = findBestMethod(ctClass, "onCreateView", LAYOUT_INFLATER_CLASS, VIEW_GROUP_CLASS); CtMethod onAttach = findBestMethod(ctClass, "onAttach", VIEW_CLASS); CtMethod onDetach = findBestMethod(ctClass, "onDetach", VIEW_CLASS); CtMethod onDestroy = findBestMethod(ctClass, "onDestroy"); boolean applied = dagger2Extension.apply(ctClass); afterSuperWithReturnType(classInjector, onCreateView, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE, true); AfterSuper(classInjector, onAttach, STATEMENT_CALL_ATTACH); beforeSuper(classInjector, onDetach, STATEMENT_CALL_DETACH); beforeSuper(classInjector, onDestroy, STATEMENT_CALL_DESTROY); } /** * It is possible that aspectj already manipulated this method, so in this case we should inject * our code into {@code methodName_aroundBodyX()} which X is the lowest number of all similar * methods to {@code methodName_aroundBody}. */ private CtMethod findBestMethod(CtClass ctClass, String methodName, String... params) throws NotFoundException { CtMethod baseMethod = null; try {
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // } // Path: easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector; AfterSuper(classInjector, onAttachedToWindow, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE); // afterSuperWithReturnType(classInjector, onDetachedFromWindow, STATEMENT_CALL_DETACH); } private void injectDelegateLifeCycleIntoConductorController(CtClass ctClass, ClassInjector classInjector) throws Exception { CtMethod onCreateView = findBestMethod(ctClass, "onCreateView", LAYOUT_INFLATER_CLASS, VIEW_GROUP_CLASS); CtMethod onAttach = findBestMethod(ctClass, "onAttach", VIEW_CLASS); CtMethod onDetach = findBestMethod(ctClass, "onDetach", VIEW_CLASS); CtMethod onDestroy = findBestMethod(ctClass, "onDestroy"); boolean applied = dagger2Extension.apply(ctClass); afterSuperWithReturnType(classInjector, onCreateView, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE, true); AfterSuper(classInjector, onAttach, STATEMENT_CALL_ATTACH); beforeSuper(classInjector, onDetach, STATEMENT_CALL_DETACH); beforeSuper(classInjector, onDestroy, STATEMENT_CALL_DESTROY); } /** * It is possible that aspectj already manipulated this method, so in this case we should inject * our code into {@code methodName_aroundBodyX()} which X is the lowest number of all similar * methods to {@code methodName_aroundBody}. */ private CtMethod findBestMethod(CtClass ctClass, String methodName, String... params) throws NotFoundException { CtMethod baseMethod = null; try {
baseMethod = ctClass.getDeclaredMethod(methodName, stringToCtClass(pool, params));
6thsolution/EasyMVP
easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // }
import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector;
} private void injectDelegateLifeCycleIntoConductorController(CtClass ctClass, ClassInjector classInjector) throws Exception { CtMethod onCreateView = findBestMethod(ctClass, "onCreateView", LAYOUT_INFLATER_CLASS, VIEW_GROUP_CLASS); CtMethod onAttach = findBestMethod(ctClass, "onAttach", VIEW_CLASS); CtMethod onDetach = findBestMethod(ctClass, "onDetach", VIEW_CLASS); CtMethod onDestroy = findBestMethod(ctClass, "onDestroy"); boolean applied = dagger2Extension.apply(ctClass); afterSuperWithReturnType(classInjector, onCreateView, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE, true); AfterSuper(classInjector, onAttach, STATEMENT_CALL_ATTACH); beforeSuper(classInjector, onDetach, STATEMENT_CALL_DETACH); beforeSuper(classInjector, onDestroy, STATEMENT_CALL_DESTROY); } /** * It is possible that aspectj already manipulated this method, so in this case we should inject * our code into {@code methodName_aroundBodyX()} which X is the lowest number of all similar * methods to {@code methodName_aroundBody}. */ private CtMethod findBestMethod(CtClass ctClass, String methodName, String... params) throws NotFoundException { CtMethod baseMethod = null; try { baseMethod = ctClass.getDeclaredMethod(methodName, stringToCtClass(pool, params)); } catch (NotFoundException e) { for (CtMethod ctMethod : ctClass.getMethods()) {
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // } // Path: easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector; } private void injectDelegateLifeCycleIntoConductorController(CtClass ctClass, ClassInjector classInjector) throws Exception { CtMethod onCreateView = findBestMethod(ctClass, "onCreateView", LAYOUT_INFLATER_CLASS, VIEW_GROUP_CLASS); CtMethod onAttach = findBestMethod(ctClass, "onAttach", VIEW_CLASS); CtMethod onDetach = findBestMethod(ctClass, "onDetach", VIEW_CLASS); CtMethod onDestroy = findBestMethod(ctClass, "onDestroy"); boolean applied = dagger2Extension.apply(ctClass); afterSuperWithReturnType(classInjector, onCreateView, applied ? STATEMENT_CALL_INITIALIZE_WITH_FACTORY : STATEMENT_CALL_INITIALIZE, true); AfterSuper(classInjector, onAttach, STATEMENT_CALL_ATTACH); beforeSuper(classInjector, onDetach, STATEMENT_CALL_DETACH); beforeSuper(classInjector, onDestroy, STATEMENT_CALL_DESTROY); } /** * It is possible that aspectj already manipulated this method, so in this case we should inject * our code into {@code methodName_aroundBodyX()} which X is the lowest number of all similar * methods to {@code methodName_aroundBody}. */ private CtMethod findBestMethod(CtClass ctClass, String methodName, String... params) throws NotFoundException { CtMethod baseMethod = null; try { baseMethod = ctClass.getDeclaredMethod(methodName, stringToCtClass(pool, params)); } catch (NotFoundException e) { for (CtMethod ctMethod : ctClass.getMethods()) {
if (ctMethod.getName().equals(methodName) && sameSignature(Arrays.asList(params),
6thsolution/EasyMVP
easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // }
import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector;
for (int i = 1; i < aspectMethodParams.length - 1; i++) { areSame = baseMethodParams[i - 1].getName().equals(aspectMethodParams[i].getName()); } return areSame; } return false; } private CtMethod getLowerNumberOfAspectJMethods(CtMethod best, CtMethod candidate) { if (best == null) { return candidate; } int bestNum = getAspectJMethodNumber(best.getName()); int candidateNum = getAspectJMethodNumber(candidate.getName()); return bestNum < candidateNum ? best : candidate; } private int getAspectJMethodNumber(String methodName) { String num = methodName.substring( methodName.indexOf(ASPECTJ_GEN_METHOD) + ASPECTJ_GEN_METHOD.length()); return Integer.valueOf(num); } private void AfterSuper(ClassInjector classInjector, CtMethod method, String statement) throws Exception { if (method.getName().contains(ASPECTJ_GEN_METHOD)) { statement = statement.replaceAll("\\$s", "\\ajc\\$this"); String methodName = method.getName().substring(0, method.getName().indexOf(ASPECTJ_GEN_METHOD)); classInjector.insertMethod(method.getName(),
// Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static String[] ctClassToString(CtClass[] params) { // String[] strings = new String[params.length]; // for (int i = 0; i < params.length; i++) { // strings[i] = params[i].getName(); // } // return strings; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static boolean sameSignature(List<String> parameters, CtMethod method) // throws NotFoundException { // CtClass[] methodParameters = method.getParameterTypes(); // if (methodParameters.length == 0 && parameters.size() == 0) return true; // if (methodParameters.length != 0 && parameters.size() == 0) return false; // if (methodParameters.length == 0 && parameters.size() != 0) return false; // for (CtClass clazz : method.getParameterTypes()) { // if (!parameters.contains(clazz.getName())) return false; // } // return true; // } // // Path: easymvp-weaver/src/main/java/easymvp/weaver/JavassistUtils.java // static CtClass[] stringToCtClass(ClassPool pool, String[] params) // throws NotFoundException { // CtClass[] ctClasses = new CtClass[params.length]; // for (int i = 0; i < params.length; i++) { // ctClasses[i] = pool.get(params[i]); // } // return ctClasses; // } // Path: easymvp-weaver/src/main/java/easymvp/weaver/ViewDelegateBinder.java import weaver.processor.WeaverProcessor; import static easymvp.weaver.JavassistUtils.ctClassToString; import static easymvp.weaver.JavassistUtils.sameSignature; import static easymvp.weaver.JavassistUtils.stringToCtClass; import easymvp.annotation.ActivityView; import easymvp.annotation.CustomView; import easymvp.annotation.FragmentView; import easymvp.annotation.conductor.ConductorController; import java.util.Arrays; import java.util.Set; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import weaver.common.WeaveEnvironment; import weaver.instrumentation.injection.ClassInjector; for (int i = 1; i < aspectMethodParams.length - 1; i++) { areSame = baseMethodParams[i - 1].getName().equals(aspectMethodParams[i].getName()); } return areSame; } return false; } private CtMethod getLowerNumberOfAspectJMethods(CtMethod best, CtMethod candidate) { if (best == null) { return candidate; } int bestNum = getAspectJMethodNumber(best.getName()); int candidateNum = getAspectJMethodNumber(candidate.getName()); return bestNum < candidateNum ? best : candidate; } private int getAspectJMethodNumber(String methodName) { String num = methodName.substring( methodName.indexOf(ASPECTJ_GEN_METHOD) + ASPECTJ_GEN_METHOD.length()); return Integer.valueOf(num); } private void AfterSuper(ClassInjector classInjector, CtMethod method, String statement) throws Exception { if (method.getName().contains(ASPECTJ_GEN_METHOD)) { statement = statement.replaceAll("\\$s", "\\ajc\\$this"); String methodName = method.getName().substring(0, method.getName().indexOf(ASPECTJ_GEN_METHOD)); classInjector.insertMethod(method.getName(),
ctClassToString(method.getParameterTypes()))
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/CompletableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Completable; import io.reactivex.CompletableTransformer; import javax.annotation.Nullable;
package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final CompletableTransformer schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/CompletableUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Completable; import io.reactivex.CompletableTransformer; import javax.annotation.Nullable; package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final CompletableTransformer schedulersTransformer;
public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/CompletableUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Completable; import io.reactivex.CompletableTransformer; import javax.annotation.Nullable;
package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final CompletableTransformer schedulersTransformer; public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/CompletableUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Completable; import io.reactivex.CompletableTransformer; import javax.annotation.Nullable; package easymvp.usecase; /** * Created by megrez on 2017/3/12. */ public abstract class CompletableUseCase<Q> extends UseCase<Completable, Q> { private final CompletableTransformer schedulersTransformer; public CompletableUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/AppCompatActivityWithMultiViewsWithDagger.java // @ActivityView(presenter = TestPresenter.class, layout = R.layout.activity_multi_views) // public class AppCompatActivityWithMultiViewsWithDagger extends AppCompatActivity implements View1 { // // @Presenter // TestPresenter testPresenter; // // @BindView(R.id.container) // LinearLayout container; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // ActivityComponent component = // DaggerActivityComponent.builder().build(); // component.injectTo(this); // super.onCreate(savedInstanceState); // ButterKnife.bind(this); // assertNotNull(container); // for (int i = 0; i < 10; i++) { // View view = new SimpleCustomViewWithDagger(this, i, component); // container.addView(view); // } // } // // // @Override // protected void onPause() { // super.onPause(); // Set<Integer> ids = new HashSet<>(); // for (int i = 0; i < container.getChildCount(); i++) { // SimpleCustomViewWithDagger childView = // (SimpleCustomViewWithDagger) container.getChildAt(i); // ids.add(childView.testPresenter.count); // } // assertThat(ids.size(), is(10)); // Set<TestPresenter> presenters = new HashSet<>(); // for (int i = 0; i < container.getChildCount(); i++) { // SimpleCustomViewWithDagger childView = // (SimpleCustomViewWithDagger) container.getChildAt(i); // presenters.add(childView.testPresenter); // } // assertThat(presenters.size(), is(10)); // } // // @Override // protected void onStart() { // super.onStart(); // assertNotNull(testPresenter); // assertTrue(testPresenter.isOnViewAttachedCalled()); // } // // @Override // protected void onStop() { // super.onStop(); // assertTrue(testPresenter.isOnViewDetachedCalled()); // assertFalse(testPresenter.isViewAttached()); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // assertNull(testPresenter); // } // }
import com.sixthsolution.easymvp.test.AppCompatActivityWithMultiViewsWithDagger; import javax.inject.Singleton; import dagger.Component;
package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @Singleton @Component public interface ActivityComponent { CustomViewComponent.Builder customViewComponent();
// Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/AppCompatActivityWithMultiViewsWithDagger.java // @ActivityView(presenter = TestPresenter.class, layout = R.layout.activity_multi_views) // public class AppCompatActivityWithMultiViewsWithDagger extends AppCompatActivity implements View1 { // // @Presenter // TestPresenter testPresenter; // // @BindView(R.id.container) // LinearLayout container; // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // ActivityComponent component = // DaggerActivityComponent.builder().build(); // component.injectTo(this); // super.onCreate(savedInstanceState); // ButterKnife.bind(this); // assertNotNull(container); // for (int i = 0; i < 10; i++) { // View view = new SimpleCustomViewWithDagger(this, i, component); // container.addView(view); // } // } // // // @Override // protected void onPause() { // super.onPause(); // Set<Integer> ids = new HashSet<>(); // for (int i = 0; i < container.getChildCount(); i++) { // SimpleCustomViewWithDagger childView = // (SimpleCustomViewWithDagger) container.getChildAt(i); // ids.add(childView.testPresenter.count); // } // assertThat(ids.size(), is(10)); // Set<TestPresenter> presenters = new HashSet<>(); // for (int i = 0; i < container.getChildCount(); i++) { // SimpleCustomViewWithDagger childView = // (SimpleCustomViewWithDagger) container.getChildAt(i); // presenters.add(childView.testPresenter); // } // assertThat(presenters.size(), is(10)); // } // // @Override // protected void onStart() { // super.onStart(); // assertNotNull(testPresenter); // assertTrue(testPresenter.isOnViewAttachedCalled()); // } // // @Override // protected void onStop() { // super.onStop(); // assertTrue(testPresenter.isOnViewDetachedCalled()); // assertFalse(testPresenter.isViewAttached()); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // assertNull(testPresenter); // } // } // Path: easymvp-test/src/main/java/com/sixthsolution/easymvp/test/di/ActivityComponent.java import com.sixthsolution.easymvp.test.AppCompatActivityWithMultiViewsWithDagger; import javax.inject.Singleton; import dagger.Component; package com.sixthsolution.easymvp.test.di; /** * @author Saeed Masoumi (s-masoumi@live.com) */ @Singleton @Component public interface ActivityComponent { CustomViewComponent.Builder customViewComponent();
void injectTo(AppCompatActivityWithMultiViewsWithDagger activity);
6thsolution/EasyMVP
easymvp-test/src/test/java/com/sixthsolution/easymvp/test/usecase/IsNumberOdd.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java // public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { // // private final Observable.Transformer<? super R, ? extends R> schedulersTransformer; // // public ObservableUseCase(final UseCaseExecutor useCaseExecutor, // final PostExecutionThread postExecutionThread) { // super(useCaseExecutor, postExecutionThread); // schedulersTransformer = new Observable.Transformer<R, R>() { // @Override // public Observable<R> call(Observable<R> rObservable) { // return rObservable.subscribeOn(useCaseExecutor.getScheduler()) // .observeOn(postExecutionThread.getScheduler()); // } // }; // } // // @Override // public Observable<R> execute(@Nullable Q param) { // return interact(param).compose(getSchedulersTransformer()); // } // // @Override // protected abstract Observable<R> interact(@Nullable Q param); // // private Observable.Transformer<? super R, ? extends R> getSchedulersTransformer() { // return schedulersTransformer; // } // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import easymvp.usecase.ObservableUseCase; import rx.Observable; import rx.functions.Func0;
package com.sixthsolution.easymvp.test.usecase; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class IsNumberOdd extends ObservableUseCase<Boolean, Integer> { public IsNumberOdd(UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/usecase/ObservableUseCase.java // public abstract class ObservableUseCase<R, Q> extends UseCase<Observable, Q> { // // private final Observable.Transformer<? super R, ? extends R> schedulersTransformer; // // public ObservableUseCase(final UseCaseExecutor useCaseExecutor, // final PostExecutionThread postExecutionThread) { // super(useCaseExecutor, postExecutionThread); // schedulersTransformer = new Observable.Transformer<R, R>() { // @Override // public Observable<R> call(Observable<R> rObservable) { // return rObservable.subscribeOn(useCaseExecutor.getScheduler()) // .observeOn(postExecutionThread.getScheduler()); // } // }; // } // // @Override // public Observable<R> execute(@Nullable Q param) { // return interact(param).compose(getSchedulersTransformer()); // } // // @Override // protected abstract Observable<R> interact(@Nullable Q param); // // private Observable.Transformer<? super R, ? extends R> getSchedulersTransformer() { // return schedulersTransformer; // } // } // Path: easymvp-test/src/test/java/com/sixthsolution/easymvp/test/usecase/IsNumberOdd.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import easymvp.usecase.ObservableUseCase; import rx.Observable; import rx.functions.Func0; package com.sixthsolution.easymvp.test.usecase; /** * @author Saeed Masoumi (saeed@6thsolution.com) */ public class IsNumberOdd extends ObservableUseCase<Boolean, Integer> { public IsNumberOdd(UseCaseExecutor useCaseExecutor,
PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/SingleUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Single; import io.reactivex.SingleTransformer; import io.reactivex.annotations.Nullable;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class SingleUseCase<R, Q> extends UseCase<Single, Q> { private final SingleTransformer<? super R, ? extends R> schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/SingleUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Single; import io.reactivex.SingleTransformer; import io.reactivex.annotations.Nullable; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class SingleUseCase<R, Q> extends UseCase<Single, Q> { private final SingleTransformer<? super R, ? extends R> schedulersTransformer;
public SingleUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/SingleUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Single; import io.reactivex.SingleTransformer; import io.reactivex.annotations.Nullable;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class SingleUseCase<R, Q> extends UseCase<Single, Q> { private final SingleTransformer<? super R, ? extends R> schedulersTransformer; public SingleUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/SingleUseCase.java import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Single; import io.reactivex.SingleTransformer; import io.reactivex.annotations.Nullable; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class SingleUseCase<R, Q> extends UseCase<Single, Q> { private final SingleTransformer<? super R, ? extends R> schedulersTransformer; public SingleUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/MaybeUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Maybe; import io.reactivex.MaybeTransformer;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class MaybeUseCase<R, Q> extends UseCase<Maybe, Q> { private final MaybeTransformer<? super R, ? extends R> schedulersTransformer;
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/MaybeUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Maybe; import io.reactivex.MaybeTransformer; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class MaybeUseCase<R, Q> extends UseCase<Maybe, Q> { private final MaybeTransformer<? super R, ? extends R> schedulersTransformer;
public MaybeUseCase(final UseCaseExecutor useCaseExecutor,
6thsolution/EasyMVP
easymvp-rx2-api/src/main/java/easymvp/usecase/MaybeUseCase.java
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // }
import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Maybe; import io.reactivex.MaybeTransformer;
package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class MaybeUseCase<R, Q> extends UseCase<Maybe, Q> { private final MaybeTransformer<? super R, ? extends R> schedulersTransformer; public MaybeUseCase(final UseCaseExecutor useCaseExecutor,
// Path: easymvp-rx2-api/src/main/java/easymvp/executer/PostExecutionThread.java // public interface PostExecutionThread { // Scheduler getScheduler(); // } // // Path: easymvp-rx-api/src/main/java/easymvp/executer/UseCaseExecutor.java // public interface UseCaseExecutor { // Scheduler getScheduler(); // } // Path: easymvp-rx2-api/src/main/java/easymvp/usecase/MaybeUseCase.java import javax.annotation.Nullable; import easymvp.executer.PostExecutionThread; import easymvp.executer.UseCaseExecutor; import io.reactivex.Maybe; import io.reactivex.MaybeTransformer; package easymvp.usecase; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public abstract class MaybeUseCase<R, Q> extends UseCase<Maybe, Q> { private final MaybeTransformer<? super R, ? extends R> schedulersTransformer; public MaybeUseCase(final UseCaseExecutor useCaseExecutor,
final PostExecutionThread postExecutionThread) {
6thsolution/EasyMVP
easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/ConductorControllerDecorator.java
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // }
import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public class ConductorControllerDecorator extends BaseDecorator { public ConductorControllerDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getActivity().getLoaderManager()")
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java // public class DelegateClassGenerator extends ClassGenerator { // private final ClassName viewClass; // private ClassName presenterClass; // private ViewType viewType; // private int resourceID = -1; // private String presenterFieldNameInView = ""; // private String presenterViewQualifiedName; // private boolean injectablePresenterInView = false; // private ClassName presenterTypeInView; // private BaseDecorator decorator; // // private String presenterId = ""; // // public String getPresenterId() { // return presenterId; // } // // public DelegateClassGenerator(String packageName, String className, ClassName viewClass) { // super(packageName, className); // this.viewClass = viewClass; // } // // public ClassName getViewClass() { // return viewClass; // } // // public String getPresenterViewQualifiedName() { // return presenterViewQualifiedName; // } // // public void setPresenterViewQualifiedName(String presenterViewQualifiedName) { // this.presenterViewQualifiedName = presenterViewQualifiedName; // } // // public void setViewType(ViewType viewType) { // this.viewType = viewType; // switch (viewType) { // case ACTIVITY: // decorator = new ActivityDecorator(this); // break; // case SUPPORT_ACTIVITY: // decorator = new SupportActivityDecorator(this); // break; // case FRAGMENT: // decorator = new FragmentDecorator(this); // break; // case SUPPORT_FRAGMENT: // decorator = new SupportFragmentDecorator(this); // break; // case CUSTOM_VIEW: // decorator = new CustomViewDecorator(this); // break; // case CONDUCTOR_CONTROLLER: // decorator = new ConductorControllerDecorator(this); // break; // } // } // // public void setResourceID(int resourceID) { // this.resourceID = resourceID; // } // // public void setPresenter(ClassName presenter) { // this.presenterClass = presenter; // } // // public void setViewPresenterField(String fieldName) { // presenterFieldNameInView = fieldName; // } // // @Override // public JavaFile build() { // TypeSpec.Builder result = // TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC) // .addSuperinterface( // ParameterizedTypeName.get(VIEW_DELEGATE, viewClass, // getPresenterFactoryTypeName())); // decorator.build(result); // return JavaFile.builder(getPackageName(), result.build()) // .addFileComment("Generated class from EasyMVP. Do not modify!").build(); // } // // // public void injectablePresenterInView(boolean injectable) { // this.injectablePresenterInView = injectable; // } // // private TypeName getPresenterFactoryTypeName() { // return ParameterizedTypeName.get(PROVIDER, presenterClass); // } // // public ClassName getPresenterClass() { // return presenterClass; // } // // public boolean isInjectablePresenterInView() { // return injectablePresenterInView; // } // // public ClassName getPresenterTypeInView() { // return presenterTypeInView; // } // // public void setPresenterTypeInView(String presenterTypeInView) { // this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView); // } // // public String getPresenterFieldNameInView() { // return presenterFieldNameInView; // } // // public int getResourceID() { // return resourceID; // } // // public void setPresenterId(String presenterId) { // this.presenterId = presenterId; // } // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // static ClassName getLoader(boolean supportLibrary) { // return get(supportLibrary, SUPPORT_LOADER, LOADER); // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderCallbacks() { // return LOADER_CALLBACKS; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getLoaderManager() { // return LOADER_MANAGER; // } // // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java // public static ClassName getPresenterLoader() { // return PRESENTER_LOADER; // } // Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/ConductorControllerDecorator.java import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; import easymvp.compiler.generator.DelegateClassGenerator; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks; import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager; import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader; package easymvp.compiler.generator.decorator; /** * @author Saeed Masoumi (s-masoumi@live.com) */ public class ConductorControllerDecorator extends BaseDecorator { public ConductorControllerDecorator(DelegateClassGenerator delegateClassGenerator) { super(delegateClassGenerator); } @Override public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) { return methodSignature.addStatement("return view.getActivity().getLoaderManager()")
.returns(getLoaderManager())