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 |
|---|---|---|---|---|---|---|
evant/redux | sample-android/src/main/java/com/example/sample_android/reducer/AddReducer.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
| import com.example.sample_android.action.Add;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.state.TodoList;
import java.util.ArrayList;
import java.util.List;
import me.tatarka.redux.Reducer; | package com.example.sample_android.reducer;
public class AddReducer implements Reducer<Add, TodoList> {
@Override
public TodoList reduce(Add action, TodoList state) { | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
// Path: sample-android/src/main/java/com/example/sample_android/reducer/AddReducer.java
import com.example.sample_android.action.Add;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.state.TodoList;
import java.util.ArrayList;
import java.util.List;
import me.tatarka.redux.Reducer;
package com.example.sample_android.reducer;
public class AddReducer implements Reducer<Add, TodoList> {
@Override
public TodoList reduce(Add action, TodoList state) { | List<TodoItem> items = new ArrayList<>(state.items()); |
evant/redux | redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue; | package me.tatarka.redux.rx;
@RunWith(JUnit4.class)
public class ObservableDispatcherTest {
@Test
public void subscription_receives_initial_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>(); | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
// Path: redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue;
package me.tatarka.redux.rx;
@RunWith(JUnit4.class)
public class ObservableDispatcherTest {
@Test
public void subscription_receives_initial_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>(); | SimpleStore<String> store = new SimpleStore<>("test1"); |
evant/redux | redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue; | testSubscriber.assertValue("test1");
}
@Test
public void subscription_receives_updated_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber);
store.setState("test2");
testSubscriber.assertValues("test1", "test2");
}
@Test
public void canceled_subscription_no_longer_receives_updates() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber).unsubscribe();
store.setState("test2");
testSubscriber.assertValue("test1");
}
@Test
public void multithreaded_dispatch_to_subscription_does_not_lose_messages() throws InterruptedException {
final int JOB_COUNT = 100;
ExecutorService exec = Executors.newFixedThreadPool(JOB_COUNT);
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
final SimpleStore<String> store = new SimpleStore<>("test"); | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
// Path: redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue;
testSubscriber.assertValue("test1");
}
@Test
public void subscription_receives_updated_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber);
store.setState("test2");
testSubscriber.assertValues("test1", "test2");
}
@Test
public void canceled_subscription_no_longer_receives_updates() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber).unsubscribe();
store.setState("test2");
testSubscriber.assertValue("test1");
}
@Test
public void multithreaded_dispatch_to_subscription_does_not_lose_messages() throws InterruptedException {
final int JOB_COUNT = 100;
ExecutorService exec = Executors.newFixedThreadPool(JOB_COUNT);
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
final SimpleStore<String> store = new SimpleStore<>("test"); | final Dispatcher<String, String> dispatcher = Dispatcher.forStore(store, new Reducer<String, String>() { |
evant/redux | redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue; | testSubscriber.assertValue("test1");
}
@Test
public void subscription_receives_updated_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber);
store.setState("test2");
testSubscriber.assertValues("test1", "test2");
}
@Test
public void canceled_subscription_no_longer_receives_updates() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber).unsubscribe();
store.setState("test2");
testSubscriber.assertValue("test1");
}
@Test
public void multithreaded_dispatch_to_subscription_does_not_lose_messages() throws InterruptedException {
final int JOB_COUNT = 100;
ExecutorService exec = Executors.newFixedThreadPool(JOB_COUNT);
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
final SimpleStore<String> store = new SimpleStore<>("test"); | // Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
//
// /**
// * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
// * run the action through the reducer and update the store with the resulting state.
// *
// * @param <S> The type of state in the store.
// * @param <A> The type of action.
// * @return the action dispatched.
// */
// public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
// if (store == null) {
// throw new NullPointerException("store==null");
// }
// if (reducer == null) {
// throw new NullPointerException("reducer==null");
// }
// return new Dispatcher<A, A>() {
// @Override
// public A dispatch(A action) {
// store.setState(reducer.reduce(action, store.getState()));
// return action;
// }
// };
// }
//
// /**
// * Dispatches the given action.
// */
// public abstract R dispatch(A action);
//
// /**
// * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
// if (middleware == null) {
// throw new NullPointerException("middleware==null");
// }
// return new Dispatcher<A, R>() {
// @Override
// public R dispatch(A action) {
// return middleware.dispatch(new Middleware.Next<A, R>() {
// @Override
// public R next(A action) {
// return Dispatcher.this.dispatch(action);
// }
// }, action);
// }
// };
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
// return chain(middleware.iterator());
// }
//
// /**
// * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
// */
// @SafeVarargs
// public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
// return chain(Arrays.asList(middleware));
// }
//
// private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
// if (!itr.hasNext()) {
// return this;
// }
// return chain(itr.next()).chain(itr);
// }
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
// S reduce(A action, S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
//
// private volatile S state;
// private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
//
// public SimpleStore(S initialState) {
// setState(initialState);
// }
//
// @Override
// public S getState() {
// return state;
// }
//
// @Override
// public void setState(S newState) {
// if (!equals(state, newState)) {
// state = newState;
// for (Listener<S> listener : listeners) {
// listener.onNewState(state);
// }
// }
// }
//
// /**
// * Registers as listener to receive state changes. The current state will be delivered
// * immediately.
// */
// public void addListener(Listener<S> listener) {
// listeners.add(listener);
// listener.onNewState(state);
// }
//
// /**
// * Removes the listener so it no longer receives state changes.
// */
// public void removeListener(Listener<S> listener) {
// listeners.remove(listener);
// }
//
// public interface Listener<S> {
// /**
// * Called when a new state is set. This is called on the same thread as or {@link #setState(Object)}.
// */
// void onNewState(S state);
// }
//
// private static boolean equals(Object var0, Object var1) {
// return var0 == var1 || var0 != null && var0.equals(var1);
// }
// }
// Path: redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue;
testSubscriber.assertValue("test1");
}
@Test
public void subscription_receives_updated_state() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber);
store.setState("test2");
testSubscriber.assertValues("test1", "test2");
}
@Test
public void canceled_subscription_no_longer_receives_updates() {
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
SimpleStore<String> store = new SimpleStore<>("test1");
ObservableAdapter.observable(store).subscribe(testSubscriber).unsubscribe();
store.setState("test2");
testSubscriber.assertValue("test1");
}
@Test
public void multithreaded_dispatch_to_subscription_does_not_lose_messages() throws InterruptedException {
final int JOB_COUNT = 100;
ExecutorService exec = Executors.newFixedThreadPool(JOB_COUNT);
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
final SimpleStore<String> store = new SimpleStore<>("test"); | final Dispatcher<String, String> dispatcher = Dispatcher.forStore(store, new Reducer<String, String>() { |
evant/redux | sample/src/main/java/me/tatarka/redux/sample/CounterSample.java | // Path: redux-rx/src/main/java/me/tatarka/redux/rx/ObservableAdapter.java
// public class ObservableAdapter {
//
// public static <S> Observable<S> observable(final SimpleStore<S> store) {
// return Observable.fromEmitter(new Action1<Emitter<S>>() {
// @Override
// public void call(Emitter<S> emitter) {
// store.addListener(new EmitterListener<>(emitter, store));
// }
// }, Emitter.BackpressureMode.LATEST);
// }
//
// private static class EmitterListener<S> implements SimpleStore.Listener<S>, Cancellable {
// final SimpleStore<S> store;
// final Observer<S> observer;
//
// EmitterListener(Emitter<S> emitter, SimpleStore<S> store) {
// this.observer = new SerializedObserver<>(emitter);
// this.store = store;
// emitter.setCancellation(this);
// }
//
// @Override
// public void onNewState(S state) {
// observer.onNext(state);
// }
//
// @Override
// public void cancel() throws Exception {
// store.removeListener(this);
// }
// }
// }
| import me.tatarka.redux.*;
import me.tatarka.redux.rx.ObservableAdapter; | package me.tatarka.redux.sample;
public class CounterSample {
// reducers
static final Reducer<Increment, Integer> increment = (action, state) -> state + 1;
static final Reducer<Add, Integer> add = (action, state) -> state + action.value;
static final Reducer<Action, Integer> counter = Reducers.<Action, Integer>matchClass()
.when(Increment.class, increment)
.when(Add.class, add);
// actions
interface Action {}
static class Increment implements Action {
@Override
public String toString() {
return "Increment";
}
}
static class Add implements Action {
final int value;
Add(int value) {
this.value = value;
}
@Override
public String toString() {
return "Add(" + value + ")";
}
}
public static void main(String[] args) {
SimpleStore<Integer> store = new SimpleStore<>(0);
Dispatcher<Action, Action> dispatcher = Dispatcher.forStore(store, counter)
.chain(new LogMiddleware<>(store)); | // Path: redux-rx/src/main/java/me/tatarka/redux/rx/ObservableAdapter.java
// public class ObservableAdapter {
//
// public static <S> Observable<S> observable(final SimpleStore<S> store) {
// return Observable.fromEmitter(new Action1<Emitter<S>>() {
// @Override
// public void call(Emitter<S> emitter) {
// store.addListener(new EmitterListener<>(emitter, store));
// }
// }, Emitter.BackpressureMode.LATEST);
// }
//
// private static class EmitterListener<S> implements SimpleStore.Listener<S>, Cancellable {
// final SimpleStore<S> store;
// final Observer<S> observer;
//
// EmitterListener(Emitter<S> emitter, SimpleStore<S> store) {
// this.observer = new SerializedObserver<>(emitter);
// this.store = store;
// emitter.setCancellation(this);
// }
//
// @Override
// public void onNewState(S state) {
// observer.onNext(state);
// }
//
// @Override
// public void cancel() throws Exception {
// store.removeListener(this);
// }
// }
// }
// Path: sample/src/main/java/me/tatarka/redux/sample/CounterSample.java
import me.tatarka.redux.*;
import me.tatarka.redux.rx.ObservableAdapter;
package me.tatarka.redux.sample;
public class CounterSample {
// reducers
static final Reducer<Increment, Integer> increment = (action, state) -> state + 1;
static final Reducer<Add, Integer> add = (action, state) -> state + action.value;
static final Reducer<Action, Integer> counter = Reducers.<Action, Integer>matchClass()
.when(Increment.class, increment)
.when(Add.class, add);
// actions
interface Action {}
static class Increment implements Action {
@Override
public String toString() {
return "Increment";
}
}
static class Add implements Action {
final int value;
Add(int value) {
this.value = value;
}
@Override
public String toString() {
return "Add(" + value + ")";
}
}
public static void main(String[] args) {
SimpleStore<Integer> store = new SimpleStore<>(0);
Dispatcher<Action, Action> dispatcher = Dispatcher.forStore(store, counter)
.chain(new LogMiddleware<>(store)); | ObservableAdapter.observable(store).subscribe(count -> System.out.println("state: " + count)); |
evant/redux | sample/src/main/java/me/tatarka/redux/sample/CompositeStateSample.java | // Path: redux-rx/src/main/java/me/tatarka/redux/rx/ObservableAdapter.java
// public class ObservableAdapter {
//
// public static <S> Observable<S> observable(final SimpleStore<S> store) {
// return Observable.fromEmitter(new Action1<Emitter<S>>() {
// @Override
// public void call(Emitter<S> emitter) {
// store.addListener(new EmitterListener<>(emitter, store));
// }
// }, Emitter.BackpressureMode.LATEST);
// }
//
// private static class EmitterListener<S> implements SimpleStore.Listener<S>, Cancellable {
// final SimpleStore<S> store;
// final Observer<S> observer;
//
// EmitterListener(Emitter<S> emitter, SimpleStore<S> store) {
// this.observer = new SerializedObserver<>(emitter);
// this.store = store;
// emitter.setCancellation(this);
// }
//
// @Override
// public void onNewState(S state) {
// observer.onNext(state);
// }
//
// @Override
// public void cancel() throws Exception {
// store.removeListener(this);
// }
// }
// }
| import me.tatarka.redux.*;
import me.tatarka.redux.rx.ObservableAdapter; | static class ChangeName implements Replace<String> {
final String newName;
ChangeName(String newName) {
this.newName = newName;
}
@Override
public String toString() {
return "ChangeName(" + newName + ")";
}
@Override
public String newValue() {
return newName;
}
}
static class IncrementAge implements Increment {
@Override
public String toString() {
return "IncrementAge";
}
}
public static void main(String[] args) {
SimpleStore<Person> store = new SimpleStore<>(new Person("nobody", 0));
Dispatcher<Action, Action> dispatcher = Dispatcher.forStore(store, updatePerson)
.chain(new LogMiddleware<>(store)); | // Path: redux-rx/src/main/java/me/tatarka/redux/rx/ObservableAdapter.java
// public class ObservableAdapter {
//
// public static <S> Observable<S> observable(final SimpleStore<S> store) {
// return Observable.fromEmitter(new Action1<Emitter<S>>() {
// @Override
// public void call(Emitter<S> emitter) {
// store.addListener(new EmitterListener<>(emitter, store));
// }
// }, Emitter.BackpressureMode.LATEST);
// }
//
// private static class EmitterListener<S> implements SimpleStore.Listener<S>, Cancellable {
// final SimpleStore<S> store;
// final Observer<S> observer;
//
// EmitterListener(Emitter<S> emitter, SimpleStore<S> store) {
// this.observer = new SerializedObserver<>(emitter);
// this.store = store;
// emitter.setCancellation(this);
// }
//
// @Override
// public void onNewState(S state) {
// observer.onNext(state);
// }
//
// @Override
// public void cancel() throws Exception {
// store.removeListener(this);
// }
// }
// }
// Path: sample/src/main/java/me/tatarka/redux/sample/CompositeStateSample.java
import me.tatarka.redux.*;
import me.tatarka.redux.rx.ObservableAdapter;
static class ChangeName implements Replace<String> {
final String newName;
ChangeName(String newName) {
this.newName = newName;
}
@Override
public String toString() {
return "ChangeName(" + newName + ")";
}
@Override
public String newValue() {
return newName;
}
}
static class IncrementAge implements Increment {
@Override
public String toString() {
return "IncrementAge";
}
}
public static void main(String[] args) {
SimpleStore<Person> store = new SimpleStore<>(new Person("nobody", 0));
Dispatcher<Action, Action> dispatcher = Dispatcher.forStore(store, updatePerson)
.chain(new LogMiddleware<>(store)); | ObservableAdapter.observable(store).subscribe(person -> System.out.println("state: " + person)); |
evant/redux | sample-android/src/main/java/com/example/sample_android/middleware/PersistenceMiddleware.java | // Path: sample-android/src/main/java/com/example/sample_android/Datastore.java
// public class Datastore {
//
// // poor-man's persistence
// private SharedPreferences prefs;
//
// public Datastore(Context context) {
// prefs = context.getSharedPreferences("datastore", Context.MODE_PRIVATE);
// }
//
// public void store(List<TodoItem> items) {
// StringBuilder data = new StringBuilder();
// for (Iterator<TodoItem> iterator = items.iterator(); iterator.hasNext(); ) {
// TodoItem item = iterator.next();
// data.append(item.id()).append(":").append(item.text()).append(":").append(item.done());
// if (iterator.hasNext()) {
// data.append(",");
// }
// }
// prefs.edit()
// .putString("data", data.toString())
// .apply();
// }
//
// public void get(final Callback callback) {
// // Yeah you can get them pretty fast, but let's pretend it's slow.
// new AsyncTask<Void, Void, List<TodoItem>>() {
// @Override
// protected List<TodoItem> doInBackground(Void... params) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// return null;
// }
// String[] data = prefs.getString("data", "").split(",");
// List<TodoItem> items = new ArrayList<>(data.length);
// for (String s : data) {
// String[] fields = s.split(":");
// if (fields.length == 3) {
// int id = Integer.parseInt(fields[0]);
// String text = fields[1];
// boolean done = Boolean.parseBoolean(fields[2]);
// items.add(TodoItem.create(id, text, done));
// }
// }
// return items;
// }
//
// @Override
// protected void onPostExecute(List<TodoItem> todoItems) {
// callback.onList(todoItems);
// }
// }.execute();
// }
//
// public interface Callback {
// void onList(List<TodoItem> items);
// }
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Store.java
// public interface Store<S> {
//
// /**
// * Returns the current state of the store.
// */
// S getState();
//
// /**
// * Sets the state of the store. Warning! You should not call this in normal application code,
// * instead preferring to update it through dispatching an action. It is however, useful for
// * tests.
// */
// void setState(S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/middleware/Middleware.java
// public interface Middleware<A, R> {
//
// /**
// * Called when an action is dispatched.
// *
// * @param next Dispatch to the next middleware or actually update the state if there is none.
// * You can chose to call this anywhere to see the state before and after it has
// * changed or not at all to drop the action.
// * @param action This action that was dispatched.
// */
// R dispatch(Next<A, R> next, A action);
//
// interface Next<A, R> {
// R next(A action);
// }
// }
| import com.example.sample_android.Datastore;
import com.example.sample_android.state.TodoList;
import me.tatarka.redux.Store;
import me.tatarka.redux.middleware.Middleware; | package com.example.sample_android.middleware;
public class PersistenceMiddleware<A, R> implements Middleware<A, R> {
private final Store<TodoList> store; | // Path: sample-android/src/main/java/com/example/sample_android/Datastore.java
// public class Datastore {
//
// // poor-man's persistence
// private SharedPreferences prefs;
//
// public Datastore(Context context) {
// prefs = context.getSharedPreferences("datastore", Context.MODE_PRIVATE);
// }
//
// public void store(List<TodoItem> items) {
// StringBuilder data = new StringBuilder();
// for (Iterator<TodoItem> iterator = items.iterator(); iterator.hasNext(); ) {
// TodoItem item = iterator.next();
// data.append(item.id()).append(":").append(item.text()).append(":").append(item.done());
// if (iterator.hasNext()) {
// data.append(",");
// }
// }
// prefs.edit()
// .putString("data", data.toString())
// .apply();
// }
//
// public void get(final Callback callback) {
// // Yeah you can get them pretty fast, but let's pretend it's slow.
// new AsyncTask<Void, Void, List<TodoItem>>() {
// @Override
// protected List<TodoItem> doInBackground(Void... params) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// return null;
// }
// String[] data = prefs.getString("data", "").split(",");
// List<TodoItem> items = new ArrayList<>(data.length);
// for (String s : data) {
// String[] fields = s.split(":");
// if (fields.length == 3) {
// int id = Integer.parseInt(fields[0]);
// String text = fields[1];
// boolean done = Boolean.parseBoolean(fields[2]);
// items.add(TodoItem.create(id, text, done));
// }
// }
// return items;
// }
//
// @Override
// protected void onPostExecute(List<TodoItem> todoItems) {
// callback.onList(todoItems);
// }
// }.execute();
// }
//
// public interface Callback {
// void onList(List<TodoItem> items);
// }
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/Store.java
// public interface Store<S> {
//
// /**
// * Returns the current state of the store.
// */
// S getState();
//
// /**
// * Sets the state of the store. Warning! You should not call this in normal application code,
// * instead preferring to update it through dispatching an action. It is however, useful for
// * tests.
// */
// void setState(S state);
// }
//
// Path: redux-core/src/main/java/me/tatarka/redux/middleware/Middleware.java
// public interface Middleware<A, R> {
//
// /**
// * Called when an action is dispatched.
// *
// * @param next Dispatch to the next middleware or actually update the state if there is none.
// * You can chose to call this anywhere to see the state before and after it has
// * changed or not at all to drop the action.
// * @param action This action that was dispatched.
// */
// R dispatch(Next<A, R> next, A action);
//
// interface Next<A, R> {
// R next(A action);
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/middleware/PersistenceMiddleware.java
import com.example.sample_android.Datastore;
import com.example.sample_android.state.TodoList;
import me.tatarka.redux.Store;
import me.tatarka.redux.middleware.Middleware;
package com.example.sample_android.middleware;
public class PersistenceMiddleware<A, R> implements Middleware<A, R> {
private final Store<TodoList> store; | private final Datastore datastore; |
evant/redux | sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore; | package com.example.sample_android;
public class TodoItemDialogFragment extends DialogFragment {
public static TodoItemDialogFragment newInstance() {
return newInstance(-1);
}
public static TodoItemDialogFragment newInstance(int id) {
Bundle args = new Bundle();
args.putInt("id", id);
TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
| // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore;
package com.example.sample_android;
public class TodoItemDialogFragment extends DialogFragment {
public static TodoItemDialogFragment newInstance() {
return newInstance(-1);
}
public static TodoItemDialogFragment newInstance(int id) {
Bundle args = new Bundle();
args.putInt("id", id);
TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
| MainStore store; |
evant/redux | sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore; | package com.example.sample_android;
public class TodoItemDialogFragment extends DialogFragment {
public static TodoItemDialogFragment newInstance() {
return newInstance(-1);
}
public static TodoItemDialogFragment newInstance(int id) {
Bundle args = new Bundle();
args.putInt("id", id);
TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
MainStore store;
int id;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null; | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore;
package com.example.sample_android;
public class TodoItemDialogFragment extends DialogFragment {
public static TodoItemDialogFragment newInstance() {
return newInstance(-1);
}
public static TodoItemDialogFragment newInstance(int id) {
Bundle args = new Bundle();
args.putInt("id", id);
TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
MainStore store;
int id;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null; | for (TodoItem todoItem : store.getState().items()) { |
evant/redux | sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore; | TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
MainStore store;
int id;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null;
for (TodoItem todoItem : store.getState().items()) {
if (todoItem.id() == id) {
text = todoItem.text();
break;
}
}
textView.setText(text);
return new AlertDialog.Builder(getContext(), getTheme()) | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore;
TodoItemDialogFragment fragment = new TodoItemDialogFragment();
fragment.setArguments(args);
return fragment;
}
MainStore store;
int id;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null;
for (TodoItem todoItem : store.getState().items()) {
if (todoItem.id() == id) {
text = todoItem.text();
break;
}
}
textView.setText(text);
return new AlertDialog.Builder(getContext(), getTheme()) | .setTitle(id >= 0 ? "Edit" : "New") |
evant/redux | sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore; | public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null;
for (TodoItem todoItem : store.getState().items()) {
if (todoItem.id() == id) {
text = todoItem.text();
break;
}
}
textView.setText(text);
return new AlertDialog.Builder(getContext(), getTheme())
.setTitle(id >= 0 ? "Edit" : "New")
.setView(view)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = TextUtils.isEmpty(textView.getText()) ? "Item" : textView.getText().toString();
if (id >= 0) {
store.dispatch(Edit.create(id, text));
} else { | // Path: sample-android/src/main/java/com/example/sample_android/action/Add.java
// @AutoValue
// public abstract class Add implements Action {
//
// public static Add create(String text) {
// return new AutoValue_Add(text);
// }
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/action/Edit.java
// @AutoValue
// public abstract class Edit implements UpdateItem {
//
// public static Edit create(int id, String text) {
// return new AutoValue_Edit(id, text);
// }
//
// public abstract int id();
//
// public abstract String text();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoItem.java
// @AutoValue
// public abstract class TodoItem {
//
// public static TodoItem create(int id, String text, boolean done) {
// return new AutoValue_TodoItem(id, text, done);
// }
//
// public abstract int id();
//
// public abstract String text();
//
// public abstract boolean done();
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/store/MainStore.java
// public class MainStore extends SimpleStore<TodoList> {
//
// private final Dispatcher<Action, Action> dispatcher;
// private final Dispatcher<Thunk<Action, Action>, Void> thunkDispatcher;
// private final ReplayMiddleware<TodoList, Action, Action> replayMiddleware;
// private final MonitorMiddleware<TodoList, Action, Action> monitorMiddleware;
//
// public MainStore(Context context) {
// super(TodoList.initial());
// Reducer<Action, TodoList> reducer = TodoListReducers.reducer();
// replayMiddleware = new ReplayMiddleware<>(this, reducer);
// monitorMiddleware = new MonitorMiddleware<>(this, new MonitorMiddleware.Config("10.0.2.2", 8000));
// dispatcher = Dispatcher.forStore(this, reducer)
// .chain(new LogMiddleware<Action, Action>("ACTION"),
// replayMiddleware,
// monitorMiddleware,
// new PersistenceMiddleware<Action, Action>(this, new Datastore(context)));
// thunkDispatcher = new ThunkDispatcher<>(dispatcher)
// .chain(new LogMiddleware<Thunk<Action, Action>, Void>("THUNK_ACTION"));
// }
//
// public Action dispatch(Action action) {
// return dispatcher.dispatch(action);
// }
//
// public void dispatch(Thunk<Action, Action> thunk) {
// thunkDispatcher.dispatch(thunk);
// }
//
// public ReplayMiddleware<TodoList, Action, Action> getReplayMiddleware() {
// return replayMiddleware;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/TodoItemDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.example.sample_android.action.Add;
import com.example.sample_android.action.Edit;
import com.example.sample_android.state.TodoItem;
import com.example.sample_android.store.MainStore;
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
store = ViewModelProviders.of(getActivity()).get(TodoViewModel.class).getStore();
id = getArguments().getInt("id", -1);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.item_dialog, null);
final TextView textView = (TextView) view.findViewById(R.id.text);
String text = null;
for (TodoItem todoItem : store.getState().items()) {
if (todoItem.id() == id) {
text = todoItem.text();
break;
}
}
textView.setText(text);
return new AlertDialog.Builder(getContext(), getTheme())
.setTitle(id >= 0 ? "Edit" : "New")
.setView(view)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = TextUtils.isEmpty(textView.getText()) ? "Item" : textView.getText().toString();
if (id >= 0) {
store.dispatch(Edit.create(id, text));
} else { | store.dispatch(Add.create(text)); |
evant/redux | redux-core/src/test/java/me/tatarka/redux/TestMiddlewareTest.java | // Path: redux-core/src/main/java/me/tatarka/redux/middleware/TestMiddleware.java
// public class TestMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final Store<S> store;
// private final List<A> actions = new ArrayList<>();
// private final List<S> states = new ArrayList<>();
//
// public TestMiddleware(Store<S> store) {
// this.store = store;
// states.add(store.getState());
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// actions.add(action);
// R result = next.next(action);
// states.add(store.getState());
// return result;
// }
//
// /**
// * Returns all actions that have been dispatched.
// */
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// /**
// * Returns all states. The first state is before any action has been dispatched. Each
// * subsequent
// * state is the state after each action.
// */
// public List<S> states() {
// return Collections.unmodifiableList(states);
// }
//
// /**
// * Resets the middleware to only contain the current state and no actions.
// */
// public void reset() {
// states.subList(0, states.size() - 1).clear();
// actions.clear();
// }
// }
| import me.tatarka.redux.middleware.TestMiddleware;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.assertEquals; | package me.tatarka.redux;
@RunWith(JUnit4.class)
public class TestMiddlewareTest {
@Test
public void states_includes_initial_state() {
SimpleStore<String> simpleStore = new SimpleStore<>("test"); | // Path: redux-core/src/main/java/me/tatarka/redux/middleware/TestMiddleware.java
// public class TestMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final Store<S> store;
// private final List<A> actions = new ArrayList<>();
// private final List<S> states = new ArrayList<>();
//
// public TestMiddleware(Store<S> store) {
// this.store = store;
// states.add(store.getState());
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// actions.add(action);
// R result = next.next(action);
// states.add(store.getState());
// return result;
// }
//
// /**
// * Returns all actions that have been dispatched.
// */
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// /**
// * Returns all states. The first state is before any action has been dispatched. Each
// * subsequent
// * state is the state after each action.
// */
// public List<S> states() {
// return Collections.unmodifiableList(states);
// }
//
// /**
// * Resets the middleware to only contain the current state and no actions.
// */
// public void reset() {
// states.subList(0, states.size() - 1).clear();
// actions.clear();
// }
// }
// Path: redux-core/src/test/java/me/tatarka/redux/TestMiddlewareTest.java
import me.tatarka.redux.middleware.TestMiddleware;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.assertEquals;
package me.tatarka.redux;
@RunWith(JUnit4.class)
public class TestMiddlewareTest {
@Test
public void states_includes_initial_state() {
SimpleStore<String> simpleStore = new SimpleStore<>("test"); | TestMiddleware<String, String, String> testMiddleware = new TestMiddleware<>(simpleStore); |
evant/redux | redux-core/src/main/java/me/tatarka/redux/Dispatcher.java | // Path: redux-core/src/main/java/me/tatarka/redux/middleware/Middleware.java
// public interface Middleware<A, R> {
//
// /**
// * Called when an action is dispatched.
// *
// * @param next Dispatch to the next middleware or actually update the state if there is none.
// * You can chose to call this anywhere to see the state before and after it has
// * changed or not at all to drop the action.
// * @param action This action that was dispatched.
// */
// R dispatch(Next<A, R> next, A action);
//
// interface Next<A, R> {
// R next(A action);
// }
// }
| import me.tatarka.redux.middleware.Middleware;
import java.util.Arrays;
import java.util.Iterator; | package me.tatarka.redux;
/**
* Dispatches actions with {@link Reducer}s and updates the state in the {@link Store}. You can chain {@link Middleware}
* to implement cross-cutting concerns.
*
* @param <A> The action type.
* @param <R> The return type of the dispatcher. This is implementation-defined.
*/
public abstract class Dispatcher<A, R> {
/**
* Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
* run the action through the reducer and update the store with the resulting state.
*
* @param <S> The type of state in the store.
* @param <A> The type of action.
* @return the action dispatched.
*/
public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
if (store == null) {
throw new NullPointerException("store==null");
}
if (reducer == null) {
throw new NullPointerException("reducer==null");
}
return new Dispatcher<A, A>() {
@Override
public A dispatch(A action) {
store.setState(reducer.reduce(action, store.getState()));
return action;
}
};
}
/**
* Dispatches the given action.
*/
public abstract R dispatch(A action);
/**
* Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
*/ | // Path: redux-core/src/main/java/me/tatarka/redux/middleware/Middleware.java
// public interface Middleware<A, R> {
//
// /**
// * Called when an action is dispatched.
// *
// * @param next Dispatch to the next middleware or actually update the state if there is none.
// * You can chose to call this anywhere to see the state before and after it has
// * changed or not at all to drop the action.
// * @param action This action that was dispatched.
// */
// R dispatch(Next<A, R> next, A action);
//
// interface Next<A, R> {
// R next(A action);
// }
// }
// Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
import me.tatarka.redux.middleware.Middleware;
import java.util.Arrays;
import java.util.Iterator;
package me.tatarka.redux;
/**
* Dispatches actions with {@link Reducer}s and updates the state in the {@link Store}. You can chain {@link Middleware}
* to implement cross-cutting concerns.
*
* @param <A> The action type.
* @param <R> The return type of the dispatcher. This is implementation-defined.
*/
public abstract class Dispatcher<A, R> {
/**
* Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
* run the action through the reducer and update the store with the resulting state.
*
* @param <S> The type of state in the store.
* @param <A> The type of action.
* @return the action dispatched.
*/
public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
if (store == null) {
throw new NullPointerException("store==null");
}
if (reducer == null) {
throw new NullPointerException("reducer==null");
}
return new Dispatcher<A, A>() {
@Override
public A dispatch(A action) {
store.setState(reducer.reduce(action, store.getState()));
return action;
}
};
}
/**
* Dispatches the given action.
*/
public abstract R dispatch(A action);
/**
* Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
*/ | public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) { |
evant/redux | sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware; | package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware;
package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| ReplayMiddleware<TodoList, Action, Action> middleware; |
evant/redux | sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware; | package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware;
package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| ReplayMiddleware<TodoList, Action, Action> middleware; |
evant/redux | sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java | // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
| import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware; | package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| // Path: sample-android/src/main/java/com/example/sample_android/action/Action.java
// public interface Action {
// }
//
// Path: sample-android/src/main/java/com/example/sample_android/state/TodoList.java
// @AutoValue
// public abstract class TodoList {
//
// public static TodoList initial() {
// return new AutoValue_TodoList(true, Collections.<TodoItem>emptyList());
// }
//
// public static TodoList create(boolean loading, List<TodoItem> items) {
// return new AutoValue_TodoList(loading, Collections.unmodifiableList(items));
// }
//
// public abstract boolean loading();
//
// public abstract List<TodoItem> items();
// }
//
// Path: redux-replay/src/main/java/me/tatarka/redux/ReplayMiddleware.java
// public class ReplayMiddleware<S, A, R> implements Middleware<A, R> {
//
// private final S initialState;
// private final Store<S> store;
// private final Dispatcher<A, A> dispatcher;
// private final ArrayList<A> actions = new ArrayList<>();
// private final Set<Integer> disabled = new HashSet<>();
// private boolean runningActions;
//
// public ReplayMiddleware(Store<S> store, Reducer<A, S> reducer) {
// this.initialState = store.getState();
// this.store = store;
// this.dispatcher = Dispatcher.forStore(store, reducer);
// }
//
// @Override
// public R dispatch(Next<A, R> next, A action) {
// if (!runningActions) {
// actions.add(action);
// }
// return next.next(action);
// }
//
// public List<A> actions() {
// return Collections.unmodifiableList(actions);
// }
//
// public boolean isDisabled(int index) {
// return disabled.contains(index);
// }
//
// public void disable(int index) {
// disabled.add(index);
// rerunActions();
// }
//
// public void enable(int index) {
// disabled.remove(index);
// rerunActions();
// }
//
// public void replace(int index, A newAction) {
// actions.set(index, newAction);
// rerunActions();
// }
//
// public void remove(int index) {
// actions.remove(index);
// disabled.remove(index);
// rerunActions();
// }
//
// private void rerunActions() {
// store.setState(initialState);
// runningActions = true;
// for (int i = 0; i < actions.size(); i++) {
// if (!disabled.contains(i)) {
// A action = actions.get(i);
// dispatcher.dispatch(action);
// }
// }
// runningActions = false;
// }
// }
// Path: sample-android/src/main/java/com/example/sample_android/EditActionDialogFragment.java
import android.app.Dialog;
import androidx.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.sample_android.action.Action;
import com.example.sample_android.state.TodoList;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import me.tatarka.redux.ReplayMiddleware;
package com.example.sample_android;
public class EditActionDialogFragment extends DialogFragment {
private static final String TAG = "EditActionDialogFragmen";
private static final UnsafeAllocator unsafe = UnsafeAllocator.create();
public static EditActionDialogFragment newInstance(int index) {
Bundle args = new Bundle();
args.putInt("index", index);
EditActionDialogFragment fragment = new EditActionDialogFragment();
fragment.setArguments(args);
return fragment;
}
| ReplayMiddleware<TodoList, Action, Action> middleware; |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/network/api/CexChartAPI.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/CexCharItem.java
// public class CexCharItem {
// private String tmsp;
// private String price;
//
// /**
// *
// * @return
// */
// public String getTmsp() {
// return tmsp;
// }
//
// /**
// *
// * @return
// */
// public String getPrice() {
// return price;
// }
// }
| import android.os.AsyncTask;
import com.bytetobyte.xwallet.network.api.models.CexCharItem;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;
import okio.GzipSource;
import okio.Okio; | try {
Response response = client.newCall(request).execute();
ResponseBody body = response.body();
if (isZipped(response)) {
content = unzip(body);
} else {
content = body.string();
}
body.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//System.out.println("CexChartApi result : " + s);
try {
Gson gson = new Gson(); | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/CexCharItem.java
// public class CexCharItem {
// private String tmsp;
// private String price;
//
// /**
// *
// * @return
// */
// public String getTmsp() {
// return tmsp;
// }
//
// /**
// *
// * @return
// */
// public String getPrice() {
// return price;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/CexChartAPI.java
import android.os.AsyncTask;
import com.bytetobyte.xwallet.network.api.models.CexCharItem;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;
import okio.GzipSource;
import okio.Okio;
try {
Response response = client.newCall(request).execute();
ResponseBody body = response.body();
if (isZipped(response)) {
content = unzip(body);
} else {
content = body.string();
}
body.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//System.out.println("CexChartApi result : " + s);
try {
Gson gson = new Gson(); | Type listType = new TypeToken<List<CexCharItem>>(){}.getType(); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/ui/fragment/view/BackupFragmentView.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/MnemonicSeedBackup.java
// public class MnemonicSeedBackup {
// private Date _creationDate;
// private String _mnemonicSeed;
//
// /**
// *
// * @param seed
// * @param creationDate
// */
// public MnemonicSeedBackup(String seed, Date creationDate) {
// this._creationDate = creationDate;
// this._mnemonicSeed = seed;
// }
//
// /**
// *
// * @return
// */
// public Date getCreationDate() {
// return _creationDate;
// }
//
// /**
// *
// * @return
// */
// public String getMnemonicSeed() {
// return _mnemonicSeed;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/BackupFragmentViewContract.java
// public interface BackupFragmentViewContract extends ViewContract {
//
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/BackupFragment.java
// public class BackupFragment extends BaseDialogFragment {
//
// private BackupFragmentView _backupView;
//
// /**
// *
// * @param inflater
// * @param container
// * @param savedInstanceState
// * @return
// */
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.fragment_wallet_backup, container, false);
// _backupView = new BackupFragmentView(this);
//
// return rootView;
// }
//
// /**
// *
// * @param view
// * @param savedInstanceState
// */
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// _backupView.initViews();
// }
//
// /**
// *
// */
// @Override
// public void onResume() {
// super.onResume();
// getBaseActivity().requestMnemonic(CoinManagerFactory.BITCOIN);
// }
//
// /**
// *
// * @param seedBackup
// */
// @Override
// public void onMnemonicSeedBackup(MnemonicSeedBackup seedBackup) {
// _backupView.displayBackup(seedBackup);
// }
//
// /**
// *
// */
// @Override
// public void onServiceReady() {
// super.onServiceReady();
// }
//
// /**
// *
// * @param text
// */
// public void copyToClipboard(CharSequence text) {
// ClipboardManager clipboard = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData addData = ClipData.newPlainText("mnemonic_copied", text);
// clipboard.setPrimaryClip(addData);
//
// Toast.makeText(getBaseActivity(), "Added to clipboard!", Toast.LENGTH_SHORT).show();
// }
// }
| import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.service.ipcmodel.MnemonicSeedBackup;
import com.bytetobyte.xwallet.ui.BackupFragmentViewContract;
import com.bytetobyte.xwallet.ui.fragment.BackupFragment; | package com.bytetobyte.xwallet.ui.fragment.view;
/**
* Created by bruno on 27.04.17.
*/
public class BackupFragmentView implements BackupFragmentViewContract, View.OnClickListener {
private final BackupFragment _backupFrag;
//
private TextView _backupText;
private ImageView _copyImg;
/**
*
* @param backupFragment
*/
public BackupFragmentView(BackupFragment backupFragment) {
this._backupFrag = backupFragment;
}
/**
*
*/
@Override
public void initViews() {
View v = _backupFrag.getView();
if (v == null) return;
_backupText = (TextView) v.findViewById(R.id.backup_seed_ouput);
_copyImg = (ImageView) v.findViewById(R.id.backup_copy_seed);
_copyImg.setOnClickListener(this);
}
/**
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.backup_copy_seed:
_backupFrag.copyToClipboard(_backupText.getText());
break;
default:
break;
}
}
/**
*
* @param seedBackup
*/ | // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/MnemonicSeedBackup.java
// public class MnemonicSeedBackup {
// private Date _creationDate;
// private String _mnemonicSeed;
//
// /**
// *
// * @param seed
// * @param creationDate
// */
// public MnemonicSeedBackup(String seed, Date creationDate) {
// this._creationDate = creationDate;
// this._mnemonicSeed = seed;
// }
//
// /**
// *
// * @return
// */
// public Date getCreationDate() {
// return _creationDate;
// }
//
// /**
// *
// * @return
// */
// public String getMnemonicSeed() {
// return _mnemonicSeed;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/BackupFragmentViewContract.java
// public interface BackupFragmentViewContract extends ViewContract {
//
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/BackupFragment.java
// public class BackupFragment extends BaseDialogFragment {
//
// private BackupFragmentView _backupView;
//
// /**
// *
// * @param inflater
// * @param container
// * @param savedInstanceState
// * @return
// */
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.fragment_wallet_backup, container, false);
// _backupView = new BackupFragmentView(this);
//
// return rootView;
// }
//
// /**
// *
// * @param view
// * @param savedInstanceState
// */
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// _backupView.initViews();
// }
//
// /**
// *
// */
// @Override
// public void onResume() {
// super.onResume();
// getBaseActivity().requestMnemonic(CoinManagerFactory.BITCOIN);
// }
//
// /**
// *
// * @param seedBackup
// */
// @Override
// public void onMnemonicSeedBackup(MnemonicSeedBackup seedBackup) {
// _backupView.displayBackup(seedBackup);
// }
//
// /**
// *
// */
// @Override
// public void onServiceReady() {
// super.onServiceReady();
// }
//
// /**
// *
// * @param text
// */
// public void copyToClipboard(CharSequence text) {
// ClipboardManager clipboard = (ClipboardManager) getBaseActivity().getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData addData = ClipData.newPlainText("mnemonic_copied", text);
// clipboard.setPrimaryClip(addData);
//
// Toast.makeText(getBaseActivity(), "Added to clipboard!", Toast.LENGTH_SHORT).show();
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/view/BackupFragmentView.java
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.service.ipcmodel.MnemonicSeedBackup;
import com.bytetobyte.xwallet.ui.BackupFragmentViewContract;
import com.bytetobyte.xwallet.ui.fragment.BackupFragment;
package com.bytetobyte.xwallet.ui.fragment.view;
/**
* Created by bruno on 27.04.17.
*/
public class BackupFragmentView implements BackupFragmentViewContract, View.OnClickListener {
private final BackupFragment _backupFrag;
//
private TextView _backupText;
private ImageView _copyImg;
/**
*
* @param backupFragment
*/
public BackupFragmentView(BackupFragment backupFragment) {
this._backupFrag = backupFragment;
}
/**
*
*/
@Override
public void initViews() {
View v = _backupFrag.getView();
if (v == null) return;
_backupText = (TextView) v.findViewById(R.id.backup_seed_ouput);
_copyImg = (ImageView) v.findViewById(R.id.backup_copy_seed);
_copyImg.setOnClickListener(this);
}
/**
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.backup_copy_seed:
_backupFrag.copyToClipboard(_backupText.getText());
break;
default:
break;
}
}
/**
*
* @param seedBackup
*/ | public void displayBackup(MnemonicSeedBackup seedBackup) { |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/Bitcoin.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManagerFactory.java
// public abstract class CoinManagerFactory {
//
// /**
// *
// */
// public final static int BITCOIN = 0x1;
//
// /**
// *
// * @param coinInt
// * @return
// */
// public static CoinManager getCoinManagerBy(Context context, int coinInt) {
//
// CoinManager selected = null;
// File dataDir = null;
//
// /**
// *
// */
// switch (coinInt) {
// case BITCOIN:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
//
// default:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
// }
//
// return selected;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CurrencyCoin.java
// public interface CurrencyCoin<W> {
//
// public int getIconId();
//
// public int getCoinId();
//
// public String getCoinSymbol();
//
// /**
// * Where to store data files, such as the blockchain files
// * @return
// */
// public File getDataDir();
//
// /**
// *
// * @param wallet
// */
// public void setWalletManager(W wallet);
// public W getWalletManager();
// }
| import com.bytetobyte.xwallet.service.coin.CoinManagerFactory;
import com.bytetobyte.xwallet.service.coin.CurrencyCoin;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.wallet.Wallet;
import java.io.File; | package com.bytetobyte.xwallet.service.coin.bitcoin;
/**
* Created by bruno on 22.03.17.
*/
public class Bitcoin implements CurrencyCoin<WalletAppKit> {
/**
*
*/
private File _dataDir = null;
public static final String BITCOIN_DATA_DIR_NAME = "bitcoinDataDir";
private WalletAppKit _walletKit;
private Class<WalletAppKit> _walletKitClassType;
/**
*
* @param dataDir
*/
public Bitcoin(File dataDir) {
_dataDir = dataDir;
}
/**
*
* @return
*/
@Override
public int getIconId() { | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManagerFactory.java
// public abstract class CoinManagerFactory {
//
// /**
// *
// */
// public final static int BITCOIN = 0x1;
//
// /**
// *
// * @param coinInt
// * @return
// */
// public static CoinManager getCoinManagerBy(Context context, int coinInt) {
//
// CoinManager selected = null;
// File dataDir = null;
//
// /**
// *
// */
// switch (coinInt) {
// case BITCOIN:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
//
// default:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
// }
//
// return selected;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CurrencyCoin.java
// public interface CurrencyCoin<W> {
//
// public int getIconId();
//
// public int getCoinId();
//
// public String getCoinSymbol();
//
// /**
// * Where to store data files, such as the blockchain files
// * @return
// */
// public File getDataDir();
//
// /**
// *
// * @param wallet
// */
// public void setWalletManager(W wallet);
// public W getWalletManager();
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/Bitcoin.java
import com.bytetobyte.xwallet.service.coin.CoinManagerFactory;
import com.bytetobyte.xwallet.service.coin.CurrencyCoin;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.wallet.Wallet;
import java.io.File;
package com.bytetobyte.xwallet.service.coin.bitcoin;
/**
* Created by bruno on 22.03.17.
*/
public class Bitcoin implements CurrencyCoin<WalletAppKit> {
/**
*
*/
private File _dataDir = null;
public static final String BITCOIN_DATA_DIR_NAME = "bitcoinDataDir";
private WalletAppKit _walletKit;
private Class<WalletAppKit> _walletKitClassType;
/**
*
* @param dataDir
*/
public Bitcoin(File dataDir) {
_dataDir = dataDir;
}
/**
*
* @return
*/
@Override
public int getIconId() { | return CoinManagerFactory.BITCOIN; |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List; | package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext; | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List;
package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext; | private List<TwitterSearchResult> mDataset; |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List; | package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext;
private List<TwitterSearchResult> mDataset;
/**
*
*/
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextView;
public ImageView mImageView;
public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.news_row_text_body);
// mImageView = (ImageView) v.findViewById(R.id.news_row_image);
}
}
// Provide a suitable constructor (depends on the kind of dataset)
public NewsAdapter(Context context, List<TwitterSearchResult> myDataset) {
mDataset = myDataset;
mContext = context;
}
// Create new views (invoked by the layout manager)
@Override
public NewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.news_row_layout, parent, false);
// set the view's size, margins, paddings and layout parameters
return new ViewHolder(view);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
TwitterSearchResult searchResult = mDataset.get(position);
holder.mTextView.setText(searchResult.getText());
| // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List;
package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext;
private List<TwitterSearchResult> mDataset;
/**
*
*/
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextView;
public ImageView mImageView;
public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.news_row_text_body);
// mImageView = (ImageView) v.findViewById(R.id.news_row_image);
}
}
// Provide a suitable constructor (depends on the kind of dataset)
public NewsAdapter(Context context, List<TwitterSearchResult> myDataset) {
mDataset = myDataset;
mContext = context;
}
// Create new views (invoked by the layout manager)
@Override
public NewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.news_row_layout, parent, false);
// set the view's size, margins, paddings and layout parameters
return new ViewHolder(view);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
TwitterSearchResult searchResult = mDataset.get(position);
holder.mTextView.setText(searchResult.getText());
| TwitterEntities entities = searchResult.getEntities(); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List; | package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext;
private List<TwitterSearchResult> mDataset;
/**
*
*/
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextView;
public ImageView mImageView;
public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.news_row_text_body);
// mImageView = (ImageView) v.findViewById(R.id.news_row_image);
}
}
// Provide a suitable constructor (depends on the kind of dataset)
public NewsAdapter(Context context, List<TwitterSearchResult> myDataset) {
mDataset = myDataset;
mContext = context;
}
// Create new views (invoked by the layout manager)
@Override
public NewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.news_row_layout, parent, false);
// set the view's size, margins, paddings and layout parameters
return new ViewHolder(view);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
TwitterSearchResult searchResult = mDataset.get(position);
holder.mTextView.setText(searchResult.getText());
TwitterEntities entities = searchResult.getEntities();
// System.out.println("entities : " + entities);
if (entities == null) return;
| // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterEntities.java
// public class TwitterEntities {
// private List<TwitterUrl> urls;
// private List<TwitterMedia> media;
//
// public List<TwitterMedia> getMedia() {
// return media;
// }
//
// /**
// *
// * @return
// */
// public TwitterMedia findPhoto() {
// TwitterMedia result = null;
//
// if (media != null) {
// for (TwitterMedia m : media) {
// if (m.getType().equalsIgnoreCase("photo")) {
// result = m;
// //break;
// }
// }
// }
//
// return result;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterMedia.java
// public class TwitterMedia {
// private String media_url;
// //
// private String media_url_https;
// //
// private String type;
//
// private String url;
//
// /**
// *
// * @return
// */
// public String getMediaUrl() {
// return media_url;
// }
//
// /**
// *
// * @return
// */
// public String getUrl() {
// return url;
// }
//
// /**
// *
// * @return
// */
// public String getMediaUrlHttps() {
// return media_url_https;
// }
//
// /**
// *
// * @return
// */
// public String getType() {
// return type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/adapters/NewsAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.network.api.models.TwitterEntities;
import com.bytetobyte.xwallet.network.api.models.TwitterMedia;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import java.util.List;
package com.bytetobyte.xwallet.ui.adapters;
/**
* Created by bruno on 13.04.17.
*/
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
private final Context mContext;
private List<TwitterSearchResult> mDataset;
/**
*
*/
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextView;
public ImageView mImageView;
public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.news_row_text_body);
// mImageView = (ImageView) v.findViewById(R.id.news_row_image);
}
}
// Provide a suitable constructor (depends on the kind of dataset)
public NewsAdapter(Context context, List<TwitterSearchResult> myDataset) {
mDataset = myDataset;
mContext = context;
}
// Create new views (invoked by the layout manager)
@Override
public NewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.news_row_layout, parent, false);
// set the view's size, margins, paddings and layout parameters
return new ViewHolder(view);
}
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
TwitterSearchResult searchResult = mDataset.get(position);
holder.mTextView.setText(searchResult.getText());
TwitterEntities entities = searchResult.getEntities();
// System.out.println("entities : " + entities);
if (entities == null) return;
| TwitterMedia photo = entities.findPhoto(); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/ui/fragment/ReceiveFragment.java | // Path: app/src/main/java/com/bytetobyte/xwallet/BaseDialogFragment.java
// public class BaseDialogFragment extends DialogFragment implements BlockchainClientListener {
//
// private MainActivity _baseActivity;
//
// /**
// *
// * @param context
// */
// @Override
// public void onAttach(Context context) {
// super.onAttach(context);
//
// _baseActivity = (MainActivity) context;
// }
//
// /**
// *
// * @return
// */
// public MainActivity getBaseActivity() {
// return _baseActivity;
// }
//
// @Override
// public void onServiceReady() {
//
// }
//
// @Override
// public void onSyncReady(SyncedMessage syncedMessage) {
//
// }
//
// @Override
// public void onBlockDownloaded(BlockDownloaded block) {
//
// }
//
// @Override
// public void onFeeCalculated(SpentValueMessage feeSpentcal) {
//
// }
//
// @Override
// public void onTransactions(List<CoinTransaction> txs) {
//
// }
//
// @Override
// public void onMnemonicSeedBackup(MnemonicSeedBackup seedBackup) {
//
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/view/ReceiveFragmentView.java
// public class ReceiveFragmentView implements ReceiveFragmentViewContract, TextWatcher {
// private final ReceiveFragment _receiveFragment;
//
// private ImageView _qrImg;
// private TextView _addrText;
// private EditText _amountText;
//
// /**
// *
// * @param receiveFragment
// */
// public ReceiveFragmentView(ReceiveFragment receiveFragment) {
// this._receiveFragment = receiveFragment;
// }
//
// /**
// *
// */
// @Override
// public void initViews() {
// View fragView = _receiveFragment.getView();
// if (fragView == null) return;
//
// _qrImg = (ImageView) fragView.findViewById(R.id.receive_id_qr_code_img);
// _addrText = (TextView) fragView.findViewById(R.id.receive_addr_text);
// _amountText = (EditText) fragView.findViewById(R.id.receive_amount_edittext);
//
// _amountText.addTextChangedListener(this);
// }
//
// public ImageView getQrImg() {
// return _qrImg;
// }
//
// public TextView getAddrText() {
// return _addrText;
// }
//
// public EditText getAmountText() {
// return _amountText;
// }
//
// @Override
// public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
// }
//
// @Override
// public void onTextChanged(CharSequence s, int start, int before, int count) {
// _receiveFragment.generateQRCode(s.toString());
// }
//
// @Override
// public void afterTextChanged(Editable s) {
//
// }
// }
| import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bytetobyte.xwallet.BaseDialogFragment;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.ui.fragment.view.ReceiveFragmentView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter; | package com.bytetobyte.xwallet.ui.fragment;
/**
* Created by bruno on 21.04.17.
*/
public class ReceiveFragment extends BaseDialogFragment {
public static final String DATA_KEY_ADDR = "DATA_KEY_ADDR";
private String _addr;
/**
*
*/ | // Path: app/src/main/java/com/bytetobyte/xwallet/BaseDialogFragment.java
// public class BaseDialogFragment extends DialogFragment implements BlockchainClientListener {
//
// private MainActivity _baseActivity;
//
// /**
// *
// * @param context
// */
// @Override
// public void onAttach(Context context) {
// super.onAttach(context);
//
// _baseActivity = (MainActivity) context;
// }
//
// /**
// *
// * @return
// */
// public MainActivity getBaseActivity() {
// return _baseActivity;
// }
//
// @Override
// public void onServiceReady() {
//
// }
//
// @Override
// public void onSyncReady(SyncedMessage syncedMessage) {
//
// }
//
// @Override
// public void onBlockDownloaded(BlockDownloaded block) {
//
// }
//
// @Override
// public void onFeeCalculated(SpentValueMessage feeSpentcal) {
//
// }
//
// @Override
// public void onTransactions(List<CoinTransaction> txs) {
//
// }
//
// @Override
// public void onMnemonicSeedBackup(MnemonicSeedBackup seedBackup) {
//
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/view/ReceiveFragmentView.java
// public class ReceiveFragmentView implements ReceiveFragmentViewContract, TextWatcher {
// private final ReceiveFragment _receiveFragment;
//
// private ImageView _qrImg;
// private TextView _addrText;
// private EditText _amountText;
//
// /**
// *
// * @param receiveFragment
// */
// public ReceiveFragmentView(ReceiveFragment receiveFragment) {
// this._receiveFragment = receiveFragment;
// }
//
// /**
// *
// */
// @Override
// public void initViews() {
// View fragView = _receiveFragment.getView();
// if (fragView == null) return;
//
// _qrImg = (ImageView) fragView.findViewById(R.id.receive_id_qr_code_img);
// _addrText = (TextView) fragView.findViewById(R.id.receive_addr_text);
// _amountText = (EditText) fragView.findViewById(R.id.receive_amount_edittext);
//
// _amountText.addTextChangedListener(this);
// }
//
// public ImageView getQrImg() {
// return _qrImg;
// }
//
// public TextView getAddrText() {
// return _addrText;
// }
//
// public EditText getAmountText() {
// return _amountText;
// }
//
// @Override
// public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
// }
//
// @Override
// public void onTextChanged(CharSequence s, int start, int before, int count) {
// _receiveFragment.generateQRCode(s.toString());
// }
//
// @Override
// public void afterTextChanged(Editable s) {
//
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/ui/fragment/ReceiveFragment.java
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bytetobyte.xwallet.BaseDialogFragment;
import com.bytetobyte.xwallet.R;
import com.bytetobyte.xwallet.ui.fragment.view.ReceiveFragmentView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
package com.bytetobyte.xwallet.ui.fragment;
/**
* Created by bruno on 21.04.17.
*/
public class ReceiveFragment extends BaseDialogFragment {
public static final String DATA_KEY_ADDR = "DATA_KEY_ADDR";
private String _addr;
/**
*
*/ | private ReceiveFragmentView _receiveFragmentView; |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/BlockDownloaded.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CurrencyCoin.java
// public interface CurrencyCoin<W> {
//
// public int getIconId();
//
// public int getCoinId();
//
// public String getCoinSymbol();
//
// /**
// * Where to store data files, such as the blockchain files
// * @return
// */
// public File getDataDir();
//
// /**
// *
// * @param wallet
// */
// public void setWalletManager(W wallet);
// public W getWalletManager();
// }
| import com.bytetobyte.xwallet.service.coin.CurrencyCoin;
import java.util.Date; | package com.bytetobyte.xwallet.service.ipcmodel;
/**
* Created by bruno on 10.04.17.
*/
public class BlockDownloaded {
private final int _coin;
private final double _pct;
private final int _blocksLeft;
private final Date _lastBlockDate;
/**
*
* @param coin
* @param pct
* @param blocksSoFar
* @param date
*/ | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CurrencyCoin.java
// public interface CurrencyCoin<W> {
//
// public int getIconId();
//
// public int getCoinId();
//
// public String getCoinSymbol();
//
// /**
// * Where to store data files, such as the blockchain files
// * @return
// */
// public File getDataDir();
//
// /**
// *
// * @param wallet
// */
// public void setWalletManager(W wallet);
// public W getWalletManager();
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/BlockDownloaded.java
import com.bytetobyte.xwallet.service.coin.CurrencyCoin;
import java.util.Date;
package com.bytetobyte.xwallet.service.ipcmodel;
/**
* Created by bruno on 10.04.17.
*/
public class BlockDownloaded {
private final int _coin;
private final double _pct;
private final int _blocksLeft;
private final Date _lastBlockDate;
/**
*
* @param coin
* @param pct
* @param blocksSoFar
* @param date
*/ | public BlockDownloaded(CurrencyCoin coin, double pct, int blocksSoFar, Date date) { |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SyncedMessage.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManagerFactory.java
// public abstract class CoinManagerFactory {
//
// /**
// *
// */
// public final static int BITCOIN = 0x1;
//
// /**
// *
// * @param coinInt
// * @return
// */
// public static CoinManager getCoinManagerBy(Context context, int coinInt) {
//
// CoinManager selected = null;
// File dataDir = null;
//
// /**
// *
// */
// switch (coinInt) {
// case BITCOIN:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
//
// default:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
// }
//
// return selected;
// }
// }
| import com.bytetobyte.xwallet.service.coin.CoinManagerFactory;
import java.util.List; | package com.bytetobyte.xwallet.service.ipcmodel;
/**
* Created by bruno on 29.03.17.
*/
public class SyncedMessage {
private int _coinId;
private String amount;
private List<String> addresses;
/**
*
* @param amount
* @param addresses
*/
public SyncedMessage(int coinId, String amount, List<String> addresses) {
this._coinId = coinId;
this.amount = amount;
this.addresses = addresses;
}
public int getCoinId() {
return _coinId;
}
public String getAmount() {
return amount;
}
public List<String> getAddresses() {
return addresses;
}
/**
*
* @return
*/
public String getCoinName() {
String name = "N/A";
switch (_coinId) { | // Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManagerFactory.java
// public abstract class CoinManagerFactory {
//
// /**
// *
// */
// public final static int BITCOIN = 0x1;
//
// /**
// *
// * @param coinInt
// * @return
// */
// public static CoinManager getCoinManagerBy(Context context, int coinInt) {
//
// CoinManager selected = null;
// File dataDir = null;
//
// /**
// *
// */
// switch (coinInt) {
// case BITCOIN:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
//
// default:
// dataDir = context.getDir(Bitcoin.BITCOIN_DATA_DIR_NAME, Context.MODE_PRIVATE);
// selected = new BitcoinManager(new Bitcoin(dataDir));
// break;
// }
//
// return selected;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SyncedMessage.java
import com.bytetobyte.xwallet.service.coin.CoinManagerFactory;
import java.util.List;
package com.bytetobyte.xwallet.service.ipcmodel;
/**
* Created by bruno on 29.03.17.
*/
public class SyncedMessage {
private int _coinId;
private String amount;
private List<String> addresses;
/**
*
* @param amount
* @param addresses
*/
public SyncedMessage(int coinId, String amount, List<String> addresses) {
this._coinId = coinId;
this.amount = amount;
this.addresses = addresses;
}
public int getCoinId() {
return _coinId;
}
public String getAmount() {
return amount;
}
public List<String> getAddresses() {
return addresses;
}
/**
*
* @return
*/
public String getCoinName() {
String name = "N/A";
switch (_coinId) { | case CoinManagerFactory.BITCOIN: |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/network/api/TwitterAuthApi.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterAuthToken.java
// public class TwitterAuthToken {
// private String token_type;
// private String access_token;
//
// public String getAccessToken() {
// return access_token;
// }
//
// public String getTokenType() {
// return token_type;
// }
// }
| import android.os.AsyncTask;
import android.util.Base64;
import com.bytetobyte.xwallet.network.api.models.TwitterAuthToken;
import com.google.gson.Gson;
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import okio.GzipSource;
import okio.Okio; | * @return
*/
private boolean isZipped(Response response) {
return "gzip".equalsIgnoreCase(response.header("Content-Encoding"));
}
/**
*
* @param body
* @return
*/
private String unzip(ResponseBody body) {
try {
GzipSource responseBody = new GzipSource(body.source());
return Okio.buffer(responseBody).readUtf8();
} catch (IOException e) {
return null;
}
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
Gson gson = new Gson(); | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterAuthToken.java
// public class TwitterAuthToken {
// private String token_type;
// private String access_token;
//
// public String getAccessToken() {
// return access_token;
// }
//
// public String getTokenType() {
// return token_type;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/TwitterAuthApi.java
import android.os.AsyncTask;
import android.util.Base64;
import com.bytetobyte.xwallet.network.api.models.TwitterAuthToken;
import com.google.gson.Gson;
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import okio.GzipSource;
import okio.Okio;
* @return
*/
private boolean isZipped(Response response) {
return "gzip".equalsIgnoreCase(response.header("Content-Encoding"));
}
/**
*
* @param body
* @return
*/
private String unzip(ResponseBody body) {
try {
GzipSource responseBody = new GzipSource(body.source());
return Okio.buffer(responseBody).readUtf8();
} catch (IOException e) {
return null;
}
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
Gson gson = new Gson(); | TwitterAuthToken authResponse = gson.fromJson(s, TwitterAuthToken.class); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManager.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/CoinTransaction.java
// public class CoinTransaction implements Comparable<CoinTransaction> {
//
// private String _txFee;
// private String _txHash;
// private String _txAmount;
// private String _confirmations;
// private Date _txUpdate;
//
// /**
// *
// * @param fee
// * @param hash
// * @param amount
// */
// public CoinTransaction(String fee, String hash, String amount, String confirmations, Date updateTime) {
// this._txFee = fee;
// this._txHash = hash;
// this._txAmount = amount;
// this._txUpdate = updateTime;
// this._confirmations = confirmations;
// }
//
// public Date getTxUpdate() {
// return _txUpdate;
// }
//
// /**
// *
// * @return
// */
// public String getConfirmations() {
// return _confirmations;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
//
// /**
// *
// * @return
// */
// public String getTxAmount() {
// return _txAmount;
// }
//
// /**
// *
// * @return
// */
// public String getTxHash() {
// return _txHash;
// }
//
// /**
// *
// * @param o
// * @return
// */
// @Override
// public int compareTo(CoinTransaction o) {
// return _txUpdate.compareTo(o.getTxUpdate());
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SpentValueMessage.java
// public class SpentValueMessage {
//
// private String _address;
// private String _amount;
// private String _txFee;
//
// /**
// *
// * @param address
// * @param amount
// */
// public SpentValueMessage(String address, String amount) {
// this._address = address;
// this._amount = amount;
// this._txFee = null;
// }
//
// /**
// *
// * @param txFee
// */
// public void setTxFee(String txFee) {
// this._txFee = txFee;
// }
//
// /**
// *
// * @param amount
// */
// public void setAmount(String amount) {
// this._amount = amount;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
// /**
// * '
// * @return
// */
// public String getAddress() {
// return _address;
// }
//
// /**
// *
// * @return
// */
// public String getAmount() {
// return _amount;
// }
// }
| import com.bytetobyte.xwallet.service.ipcmodel.CoinTransaction;
import com.bytetobyte.xwallet.service.ipcmodel.SpentValueMessage;
import java.util.Date;
import java.util.List;
import java.util.Map; | package com.bytetobyte.xwallet.service.coin;
/**
* Created by bruno on 21.03.17.
*/
public interface CoinManager {
void setup(CoinAction.CoinActionCallback callback);
void sendCoins(String address, String amount, CoinAction.CoinActionCallback callback);
void onCoinsReceived();
void onReady();
| // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/CoinTransaction.java
// public class CoinTransaction implements Comparable<CoinTransaction> {
//
// private String _txFee;
// private String _txHash;
// private String _txAmount;
// private String _confirmations;
// private Date _txUpdate;
//
// /**
// *
// * @param fee
// * @param hash
// * @param amount
// */
// public CoinTransaction(String fee, String hash, String amount, String confirmations, Date updateTime) {
// this._txFee = fee;
// this._txHash = hash;
// this._txAmount = amount;
// this._txUpdate = updateTime;
// this._confirmations = confirmations;
// }
//
// public Date getTxUpdate() {
// return _txUpdate;
// }
//
// /**
// *
// * @return
// */
// public String getConfirmations() {
// return _confirmations;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
//
// /**
// *
// * @return
// */
// public String getTxAmount() {
// return _txAmount;
// }
//
// /**
// *
// * @return
// */
// public String getTxHash() {
// return _txHash;
// }
//
// /**
// *
// * @param o
// * @return
// */
// @Override
// public int compareTo(CoinTransaction o) {
// return _txUpdate.compareTo(o.getTxUpdate());
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SpentValueMessage.java
// public class SpentValueMessage {
//
// private String _address;
// private String _amount;
// private String _txFee;
//
// /**
// *
// * @param address
// * @param amount
// */
// public SpentValueMessage(String address, String amount) {
// this._address = address;
// this._amount = amount;
// this._txFee = null;
// }
//
// /**
// *
// * @param txFee
// */
// public void setTxFee(String txFee) {
// this._txFee = txFee;
// }
//
// /**
// *
// * @param amount
// */
// public void setAmount(String amount) {
// this._amount = amount;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
// /**
// * '
// * @return
// */
// public String getAddress() {
// return _address;
// }
//
// /**
// *
// * @return
// */
// public String getAmount() {
// return _amount;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManager.java
import com.bytetobyte.xwallet.service.ipcmodel.CoinTransaction;
import com.bytetobyte.xwallet.service.ipcmodel.SpentValueMessage;
import java.util.Date;
import java.util.List;
import java.util.Map;
package com.bytetobyte.xwallet.service.coin;
/**
* Created by bruno on 21.03.17.
*/
public interface CoinManager {
void setup(CoinAction.CoinActionCallback callback);
void sendCoins(String address, String amount, CoinAction.CoinActionCallback callback);
void onCoinsReceived();
void onReady();
| List<CoinTransaction> getTransactionList(); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManager.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/CoinTransaction.java
// public class CoinTransaction implements Comparable<CoinTransaction> {
//
// private String _txFee;
// private String _txHash;
// private String _txAmount;
// private String _confirmations;
// private Date _txUpdate;
//
// /**
// *
// * @param fee
// * @param hash
// * @param amount
// */
// public CoinTransaction(String fee, String hash, String amount, String confirmations, Date updateTime) {
// this._txFee = fee;
// this._txHash = hash;
// this._txAmount = amount;
// this._txUpdate = updateTime;
// this._confirmations = confirmations;
// }
//
// public Date getTxUpdate() {
// return _txUpdate;
// }
//
// /**
// *
// * @return
// */
// public String getConfirmations() {
// return _confirmations;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
//
// /**
// *
// * @return
// */
// public String getTxAmount() {
// return _txAmount;
// }
//
// /**
// *
// * @return
// */
// public String getTxHash() {
// return _txHash;
// }
//
// /**
// *
// * @param o
// * @return
// */
// @Override
// public int compareTo(CoinTransaction o) {
// return _txUpdate.compareTo(o.getTxUpdate());
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SpentValueMessage.java
// public class SpentValueMessage {
//
// private String _address;
// private String _amount;
// private String _txFee;
//
// /**
// *
// * @param address
// * @param amount
// */
// public SpentValueMessage(String address, String amount) {
// this._address = address;
// this._amount = amount;
// this._txFee = null;
// }
//
// /**
// *
// * @param txFee
// */
// public void setTxFee(String txFee) {
// this._txFee = txFee;
// }
//
// /**
// *
// * @param amount
// */
// public void setAmount(String amount) {
// this._amount = amount;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
// /**
// * '
// * @return
// */
// public String getAddress() {
// return _address;
// }
//
// /**
// *
// * @return
// */
// public String getAmount() {
// return _amount;
// }
// }
| import com.bytetobyte.xwallet.service.ipcmodel.CoinTransaction;
import com.bytetobyte.xwallet.service.ipcmodel.SpentValueMessage;
import java.util.Date;
import java.util.List;
import java.util.Map; | package com.bytetobyte.xwallet.service.coin;
/**
* Created by bruno on 21.03.17.
*/
public interface CoinManager {
void setup(CoinAction.CoinActionCallback callback);
void sendCoins(String address, String amount, CoinAction.CoinActionCallback callback);
void onCoinsReceived();
void onReady();
List<CoinTransaction> getTransactionList();
String getBalanceFriendlyStr();
long getBalanceValue(); | // Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/CoinTransaction.java
// public class CoinTransaction implements Comparable<CoinTransaction> {
//
// private String _txFee;
// private String _txHash;
// private String _txAmount;
// private String _confirmations;
// private Date _txUpdate;
//
// /**
// *
// * @param fee
// * @param hash
// * @param amount
// */
// public CoinTransaction(String fee, String hash, String amount, String confirmations, Date updateTime) {
// this._txFee = fee;
// this._txHash = hash;
// this._txAmount = amount;
// this._txUpdate = updateTime;
// this._confirmations = confirmations;
// }
//
// public Date getTxUpdate() {
// return _txUpdate;
// }
//
// /**
// *
// * @return
// */
// public String getConfirmations() {
// return _confirmations;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
//
// /**
// *
// * @return
// */
// public String getTxAmount() {
// return _txAmount;
// }
//
// /**
// *
// * @return
// */
// public String getTxHash() {
// return _txHash;
// }
//
// /**
// *
// * @param o
// * @return
// */
// @Override
// public int compareTo(CoinTransaction o) {
// return _txUpdate.compareTo(o.getTxUpdate());
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/service/ipcmodel/SpentValueMessage.java
// public class SpentValueMessage {
//
// private String _address;
// private String _amount;
// private String _txFee;
//
// /**
// *
// * @param address
// * @param amount
// */
// public SpentValueMessage(String address, String amount) {
// this._address = address;
// this._amount = amount;
// this._txFee = null;
// }
//
// /**
// *
// * @param txFee
// */
// public void setTxFee(String txFee) {
// this._txFee = txFee;
// }
//
// /**
// *
// * @param amount
// */
// public void setAmount(String amount) {
// this._amount = amount;
// }
//
// /**
// *
// * @return
// */
// public String getTxFee() {
// return _txFee;
// }
//
// /**
// * '
// * @return
// */
// public String getAddress() {
// return _address;
// }
//
// /**
// *
// * @return
// */
// public String getAmount() {
// return _amount;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/CoinManager.java
import com.bytetobyte.xwallet.service.ipcmodel.CoinTransaction;
import com.bytetobyte.xwallet.service.ipcmodel.SpentValueMessage;
import java.util.Date;
import java.util.List;
import java.util.Map;
package com.bytetobyte.xwallet.service.coin;
/**
* Created by bruno on 21.03.17.
*/
public interface CoinManager {
void setup(CoinAction.CoinActionCallback callback);
void sendCoins(String address, String amount, CoinAction.CoinActionCallback callback);
void onCoinsReceived();
void onReady();
List<CoinTransaction> getTransactionList();
String getBalanceFriendlyStr();
long getBalanceValue(); | SpentValueMessage applyTxFee(SpentValueMessage valueMessage); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/network/api/TwitterSearchApi.java | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterAuthToken.java
// public class TwitterAuthToken {
// private String token_type;
// private String access_token;
//
// public String getAccessToken() {
// return access_token;
// }
//
// public String getTokenType() {
// return token_type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchStatuses.java
// public class TwitterSearchStatuses {
// private List<TwitterSearchResult> statuses;
//
// /**
// *
// * @return
// */
// public List<TwitterSearchResult> getStatuses() {
// return statuses;
// }
// }
| import android.os.AsyncTask;
import com.bytetobyte.xwallet.network.api.models.TwitterAuthToken;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchStatuses;
import com.google.gson.Gson;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import okio.GzipSource;
import okio.Okio; |
String content = null;
try {
Response response = client.newCall(request).execute();
ResponseBody body = response.body();
if (isZipped(response)) {
content = unzip(body);
} else {
content = body.string();
}
body.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
Gson gson = new Gson(); | // Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterAuthToken.java
// public class TwitterAuthToken {
// private String token_type;
// private String access_token;
//
// public String getAccessToken() {
// return access_token;
// }
//
// public String getTokenType() {
// return token_type;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchResult.java
// public class TwitterSearchResult {
// private String created_at;
// private String id_str;
// private String text;
// private boolean truncated;
//
// private TwitterEntities entities;
//
// public String getCreatedAt() {
// return created_at;
// }
//
// public String getIdStr() {
// return id_str;
// }
//
// public String getText() {
// return text;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// public TwitterEntities getEntities() {
// return entities;
// }
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/models/TwitterSearchStatuses.java
// public class TwitterSearchStatuses {
// private List<TwitterSearchResult> statuses;
//
// /**
// *
// * @return
// */
// public List<TwitterSearchResult> getStatuses() {
// return statuses;
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/network/api/TwitterSearchApi.java
import android.os.AsyncTask;
import com.bytetobyte.xwallet.network.api.models.TwitterAuthToken;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchResult;
import com.bytetobyte.xwallet.network.api.models.TwitterSearchStatuses;
import com.google.gson.Gson;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
import okio.GzipSource;
import okio.Okio;
String content = null;
try {
Response response = client.newCall(request).execute();
ResponseBody body = response.body();
if (isZipped(response)) {
content = unzip(body);
} else {
content = body.string();
}
body.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
*
* @param s
*/
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
Gson gson = new Gson(); | TwitterSearchStatuses searchResult = gson.fromJson(s, TwitterSearchStatuses.class); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/WalletUtils.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
// // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
// public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
//
// public static final char CHAR_HAIR_SPACE = '\u200a';
// public static final char CHAR_THIN_SPACE = '\u2009';
// public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
// public static final char CHAR_CHECKMARK = '\u2713';
// public static final char CURRENCY_PLUS_SIGN = '\uff0b';
// public static final char CURRENCY_MINUS_SIGN = '\uff0d';
// public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
// public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
// public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
//
// public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
//
// public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
//
// /** Maximum size of backups. Files larger will be rejected. */
// public static final long BACKUP_MAX_CHARS = 10000000;
//
// /** Currency code for the wallet name resolver. */
// public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
//
// /**
// * The earliest possible HD wallet.
// * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
// * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
// */
// public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
// private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
//
// private Iso8601Format(final String formatString) {
// super(formatString);
//
// setTimeZone(UTC);
// }
//
// public static DateFormat newTimeFormat() {
// return new Iso8601Format("HH:mm:ss");
// }
//
// public static DateFormat newDateFormat() {
// return new Iso8601Format("yyyy-MM-dd");
// }
//
// public static DateFormat newDateTimeFormat() {
// return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
// }
//
// public static String formatDateTime(final Date date) {
// return newDateTimeFormat().format(date);
// }
//
// public static Date parseDateTime(final String source) throws ParseException {
// return newDateTimeFormat().parse(source);
// }
//
// public static DateFormat newDateTimeFormatT() {
// return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
// }
//
// public static String formatDateTimeT(final Date date) {
// return newDateTimeFormatT().format(date);
// }
//
// public static Date parseDateTimeT(final String source) throws ParseException {
// return newDateTimeFormatT().parse(source);
// }
// }
| import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable; | package com.bytetobyte.xwallet.service.coin.bitcoin;
/**
* @author Andreas Schildbach
*/
public class WalletUtils {
public static Editable formatAddress(final Address address, final int groupSize, final int lineSize) {
return formatHash(address.toBase58(), groupSize, lineSize);
}
public static Editable formatAddress(@Nullable final String prefix, final Address address, final int groupSize,
final int lineSize) { | // Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
// // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
// public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
//
// public static final char CHAR_HAIR_SPACE = '\u200a';
// public static final char CHAR_THIN_SPACE = '\u2009';
// public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
// public static final char CHAR_CHECKMARK = '\u2713';
// public static final char CURRENCY_PLUS_SIGN = '\uff0b';
// public static final char CURRENCY_MINUS_SIGN = '\uff0d';
// public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
// public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
// public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
//
// public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
//
// public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
//
// /** Maximum size of backups. Files larger will be rejected. */
// public static final long BACKUP_MAX_CHARS = 10000000;
//
// /** Currency code for the wallet name resolver. */
// public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
//
// /**
// * The earliest possible HD wallet.
// * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
// * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
// */
// public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
// private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
//
// private Iso8601Format(final String formatString) {
// super(formatString);
//
// setTimeZone(UTC);
// }
//
// public static DateFormat newTimeFormat() {
// return new Iso8601Format("HH:mm:ss");
// }
//
// public static DateFormat newDateFormat() {
// return new Iso8601Format("yyyy-MM-dd");
// }
//
// public static DateFormat newDateTimeFormat() {
// return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
// }
//
// public static String formatDateTime(final Date date) {
// return newDateTimeFormat().format(date);
// }
//
// public static Date parseDateTime(final String source) throws ParseException {
// return newDateTimeFormat().parse(source);
// }
//
// public static DateFormat newDateTimeFormatT() {
// return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
// }
//
// public static String formatDateTimeT(final Date date) {
// return newDateTimeFormatT().format(date);
// }
//
// public static Date parseDateTimeT(final String source) throws ParseException {
// return newDateTimeFormatT().parse(source);
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/WalletUtils.java
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;
package com.bytetobyte.xwallet.service.coin.bitcoin;
/**
* @author Andreas Schildbach
*/
public class WalletUtils {
public static Editable formatAddress(final Address address, final int groupSize, final int lineSize) {
return formatHash(address.toBase58(), groupSize, lineSize);
}
public static Editable formatAddress(@Nullable final String prefix, final Address address, final int groupSize,
final int lineSize) { | return formatHash(prefix, address.toBase58(), groupSize, lineSize, Constants.CHAR_THIN_SPACE); |
ehanoc/xwallet | app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/WalletUtils.java | // Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
// // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
// public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
//
// public static final char CHAR_HAIR_SPACE = '\u200a';
// public static final char CHAR_THIN_SPACE = '\u2009';
// public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
// public static final char CHAR_CHECKMARK = '\u2713';
// public static final char CURRENCY_PLUS_SIGN = '\uff0b';
// public static final char CURRENCY_MINUS_SIGN = '\uff0d';
// public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
// public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
// public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
//
// public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
//
// public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
//
// /** Maximum size of backups. Files larger will be rejected. */
// public static final long BACKUP_MAX_CHARS = 10000000;
//
// /** Currency code for the wallet name resolver. */
// public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
//
// /**
// * The earliest possible HD wallet.
// * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
// * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
// */
// public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
// private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
//
// private Iso8601Format(final String formatString) {
// super(formatString);
//
// setTimeZone(UTC);
// }
//
// public static DateFormat newTimeFormat() {
// return new Iso8601Format("HH:mm:ss");
// }
//
// public static DateFormat newDateFormat() {
// return new Iso8601Format("yyyy-MM-dd");
// }
//
// public static DateFormat newDateTimeFormat() {
// return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
// }
//
// public static String formatDateTime(final Date date) {
// return newDateTimeFormat().format(date);
// }
//
// public static Date parseDateTime(final String source) throws ParseException {
// return newDateTimeFormat().parse(source);
// }
//
// public static DateFormat newDateTimeFormatT() {
// return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
// }
//
// public static String formatDateTimeT(final Date date) {
// return newDateTimeFormatT().format(date);
// }
//
// public static Date parseDateTimeT(final String source) throws ParseException {
// return newDateTimeFormatT().parse(source);
// }
// }
| import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable; | }
}
public static Wallet restoreWalletFromProtobuf(final InputStream is,
final NetworkParameters expectedNetworkParameters) throws IOException {
try {
final Wallet wallet = new WalletProtobufSerializer().readWallet(is, true, null);
if (!wallet.getParams().equals(expectedNetworkParameters))
throw new IOException("bad wallet backup network parameters: " + wallet.getParams().getId());
if (!wallet.isConsistent())
throw new IOException("inconsistent wallet backup");
return wallet;
} catch (final UnreadableWalletException x) {
throw new IOException("unreadable wallet", x);
}
}
public static Wallet restorePrivateKeysFromBase58(final InputStream is,
final NetworkParameters expectedNetworkParameters) throws IOException {
final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
// create non-HD wallet
final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
return new Wallet(expectedNetworkParameters, group);
}
public static void writeKeys(final Writer out, final List<ECKey> keys) throws IOException { | // Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
// // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
// public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
//
// public static final char CHAR_HAIR_SPACE = '\u200a';
// public static final char CHAR_THIN_SPACE = '\u2009';
// public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
// public static final char CHAR_CHECKMARK = '\u2713';
// public static final char CURRENCY_PLUS_SIGN = '\uff0b';
// public static final char CURRENCY_MINUS_SIGN = '\uff0d';
// public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
// public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
// public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
//
// public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
//
// public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
//
// /** Maximum size of backups. Files larger will be rejected. */
// public static final long BACKUP_MAX_CHARS = 10000000;
//
// /** Currency code for the wallet name resolver. */
// public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
//
// /**
// * The earliest possible HD wallet.
// * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
// * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
// */
// public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
//
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
// private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
//
// private Iso8601Format(final String formatString) {
// super(formatString);
//
// setTimeZone(UTC);
// }
//
// public static DateFormat newTimeFormat() {
// return new Iso8601Format("HH:mm:ss");
// }
//
// public static DateFormat newDateFormat() {
// return new Iso8601Format("yyyy-MM-dd");
// }
//
// public static DateFormat newDateTimeFormat() {
// return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
// }
//
// public static String formatDateTime(final Date date) {
// return newDateTimeFormat().format(date);
// }
//
// public static Date parseDateTime(final String source) throws ParseException {
// return newDateTimeFormat().parse(source);
// }
//
// public static DateFormat newDateTimeFormatT() {
// return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
// }
//
// public static String formatDateTimeT(final Date date) {
// return newDateTimeFormatT().format(date);
// }
//
// public static Date parseDateTimeT(final String source) throws ParseException {
// return newDateTimeFormatT().parse(source);
// }
// }
// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/WalletUtils.java
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;
}
}
public static Wallet restoreWalletFromProtobuf(final InputStream is,
final NetworkParameters expectedNetworkParameters) throws IOException {
try {
final Wallet wallet = new WalletProtobufSerializer().readWallet(is, true, null);
if (!wallet.getParams().equals(expectedNetworkParameters))
throw new IOException("bad wallet backup network parameters: " + wallet.getParams().getId());
if (!wallet.isConsistent())
throw new IOException("inconsistent wallet backup");
return wallet;
} catch (final UnreadableWalletException x) {
throw new IOException("unreadable wallet", x);
}
}
public static Wallet restorePrivateKeysFromBase58(final InputStream is,
final NetworkParameters expectedNetworkParameters) throws IOException {
final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
// create non-HD wallet
final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
return new Wallet(expectedNetworkParameters, group);
}
public static void writeKeys(final Writer out, final List<ECKey> keys) throws IOException { | final DateFormat format = Iso8601Format.newDateTimeFormatT(); |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I420Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class I420Test extends TestBase {
public I420Test() {
super("frames/I420.yuv");
}
static final Conversion SliceI420ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 2;
int srcStrideV = WIDTH / 2;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT / 2, srcStrideV * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I420Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class I420Test extends TestBase {
public I420Test() {
super("frames/I420.yuv");
}
static final Conversion SliceI420ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 2;
int srcStrideV = WIDTH / 2;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT / 2, srcStrideV * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromI420().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/NV21Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class NV21Test extends TestBase {
public NV21Test() {
super("frames/NV21.yuv");
}
static final Conversion SliceNV21ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideVU = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideVU * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/NV21Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class NV21Test extends TestBase {
public NV21Test() {
super("frames/NV21.yuv");
}
static final Conversion SliceNV21ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideVU = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideVU * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromNV21().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/RGB24Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class RGB24Test extends TestBase {
public RGB24Test() {
super("frames/RGB24.rgb");
}
static final Conversion RGB24ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideRGB24 = WIDTH * 3;
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/RGB24Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class RGB24Test extends TestBase {
public RGB24Test() {
super("frames/RGB24.rgb");
}
static final Conversion RGB24ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideRGB24 = WIDTH * 3;
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromRGB24().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/RGB565Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class RGB565Test extends TestBase {
public RGB565Test() {
super("frames/RGB565.rgb");
}
static final Conversion RGB565ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideRGB565 = WIDTH * 2;
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/RGB565Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class RGB565Test extends TestBase {
public RGB565Test() {
super("frames/RGB565.rgb");
}
static final Conversion RGB565ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideRGB565 = WIDTH * 2;
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromRGB565().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/NV12Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class NV12Test extends TestBase {
public NV12Test() {
super("frames/NV12.yuv");
}
static final Conversion SliceNV12ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideUV = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideUV * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/NV12Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class NV12Test extends TestBase {
public NV12Test() {
super("frames/NV12.yuv");
}
static final Conversion SliceNV12ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideUV = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideUV * HEIGHT / 2);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromNV12().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I411Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class I411Test extends TestBase {
public I411Test() {
super("frames/I411.yuv");
}
static final Conversion SliceI411ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 4;
int srcStrideV = WIDTH / 4;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I411Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class I411Test extends TestBase {
public I411Test() {
super("frames/I411.yuv");
}
static final Conversion SliceI411ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 4;
int srcStrideV = WIDTH / 4;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromI411().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I444Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class I444Test extends TestBase {
public I444Test() {
super("frames/I444.yuv");
}
static final Conversion SliceI444ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH;
int srcStrideV = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I444Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class I444Test extends TestBase {
public I444Test() {
super("frames/I444.yuv");
}
static final Conversion SliceI444ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH;
int srcStrideV = WIDTH;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromI444().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I400Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class I400Test extends TestBase {
public I400Test() {
super("frames/I400.yuv");
}
static final Conversion I400ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I400Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class I400Test extends TestBase {
public I400Test() {
super("frames/I400.yuv");
}
static final Conversion I400ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromI400().toARGB( |
Gekkio/robotic-chameleon | robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I422Test.java | // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
| import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon; | package fi.gekkio.roboticchameleon.tests;
public class I422Test extends TestBase {
public I422Test() {
super("frames/I422.yuv");
}
static final Conversion SliceI422ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 2;
int srcStrideV = WIDTH / 2;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| // Path: robotic-chameleon/src/fi/gekkio/roboticchameleon/RoboticChameleon.java
// public final class RoboticChameleon {
//
// private RoboticChameleon() {
// }
//
// public static ABGR fromABGR() {
// return ABGR.INSTANCE;
// }
//
// public static ARGB fromARGB() {
// return ARGB.INSTANCE;
// }
//
// public static ARGB1555 fromARGB1555() {
// return ARGB1555.INSTANCE;
// }
//
// public static ARGB4444 fromARGB4444() {
// return ARGB4444.INSTANCE;
// }
//
// public static BGRA fromBGRA() {
// return BGRA.INSTANCE;
// }
//
// public static I400 fromI400() {
// return I400.INSTANCE;
// }
//
// public static I411 fromI411() {
// return I411.INSTANCE;
// }
//
// public static I420 fromI420() {
// return I420.INSTANCE;
// }
//
// public static I422 fromI422() {
// return I422.INSTANCE;
// }
//
// public static I444 fromI444() {
// return I444.INSTANCE;
// }
//
// public static M420 fromM420() {
// return M420.INSTANCE;
// }
//
// public static NV12 fromNV12() {
// return NV12.INSTANCE;
// }
//
// public static NV21 fromNV21() {
// return NV21.INSTANCE;
// }
//
// public static Q420 fromQ420() {
// return Q420.INSTANCE;
// }
//
// public static RAW fromRAW() {
// return RAW.INSTANCE;
// }
//
// public static RGB24 fromRGB24() {
// return RGB24.INSTANCE;
// }
//
// public static RGB565 fromRGB565() {
// return RGB565.INSTANCE;
// }
//
// public static RGBA fromRGBA() {
// return RGBA.INSTANCE;
// }
//
// public static UYVY fromUYVY() {
// return UYVY.INSTANCE;
// }
//
// public static YUY2 fromYUY2() {
// return YUY2.INSTANCE;
// }
//
// public static YV12 fromYV12() {
// return YV12.INSTANCE;
// }
//
// }
// Path: robotic-chameleon-tests/src/fi/gekkio/roboticchameleon/tests/I422Test.java
import java.nio.ByteBuffer;
import fi.gekkio.roboticchameleon.RoboticChameleon;
package fi.gekkio.roboticchameleon.tests;
public class I422Test extends TestBase {
public I422Test() {
super("frames/I422.yuv");
}
static final Conversion SliceI422ToARGB = new Conversion() {
@Override
public void convert(ByteBuffer src, ByteBuffer dst) {
int srcStrideY = WIDTH;
int srcStrideU = WIDTH / 2;
int srcStrideV = WIDTH / 2;
ByteBuffer[] srcs = ByteBuffers.slice(src, srcStrideY * HEIGHT, srcStrideU * HEIGHT, srcStrideV * HEIGHT);
int dstStrideARGB = WIDTH * 4;
| RoboticChameleon.fromI422().toARGB( |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/Configure.java | // Path: src/main/java/org/yetiz/lib/acd/exception/BadContentException.java
// public class BadContentException extends RuntimeException {
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public BadContentException() {
// super("Data can't convert to JSON type.");
// Log.e(getMessage());
// }
//
// public BadContentException(String message) {
// super(message);
// Log.e(getMessage());
// }
// }
| import org.yetiz.lib.acd.exception.BadContentException;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties; | public String getPath() {
return path;
}
public String getClientId() {
return client_id;
}
/**
* required field.
* @param client_id
*/
public void setClientId(String client_id) {
this.client_id = client_id;
}
public String getClientSecret() {
return client_secret;
}
/**
* required field.
* @param client_secret
*/
public void setClientSecret(String client_secret) {
this.client_secret = client_secret;
}
public String getOwner() {
if (owner == null || owner.equals("")) { | // Path: src/main/java/org/yetiz/lib/acd/exception/BadContentException.java
// public class BadContentException extends RuntimeException {
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public BadContentException() {
// super("Data can't convert to JSON type.");
// Log.e(getMessage());
// }
//
// public BadContentException(String message) {
// super(message);
// Log.e(getMessage());
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/Configure.java
import org.yetiz.lib.acd.exception.BadContentException;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
public String getPath() {
return path;
}
public String getClientId() {
return client_id;
}
/**
* required field.
* @param client_id
*/
public void setClientId(String client_id) {
this.client_id = client_id;
}
public String getClientSecret() {
return client_secret;
}
/**
* required field.
* @param client_secret
*/
public void setClientSecret(String client_secret) {
this.client_secret = client_secret;
}
public String getOwner() {
if (owner == null || owner.equals("")) { | throw new BadContentException("This API need owner parameter, please set owner on configure!"); |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/MethodNotAllowedException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class MethodNotAllowedException extends ACDResponseException {
public MethodNotAllowedException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/MethodNotAllowedException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class MethodNotAllowedException extends ACDResponseException {
public MethodNotAllowedException(Response response) {
super(response); | statusCode = ResponseCode.Error.METHOD_NOT_ALLOWED; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/ResourceNotFoundException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ResourceNotFoundException extends ACDResponseException {
public ResourceNotFoundException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/ResourceNotFoundException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ResourceNotFoundException extends ACDResponseException {
public ResourceNotFoundException(Response response) {
super(response); | statusCode = ResponseCode.Error.RESOURCE_NOT_FOUND; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/ContentLengthNotExistedException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ContentLengthNotExistedException extends ACDResponseException {
public ContentLengthNotExistedException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/ContentLengthNotExistedException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ContentLengthNotExistedException extends ACDResponseException {
public ContentLengthNotExistedException(Response response) {
super(response); | statusCode = ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/Utils.java | // Path: src/main/java/org/yetiz/lib/acd/exception/BadContentException.java
// public class BadContentException extends RuntimeException {
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public BadContentException() {
// super("Data can't convert to JSON type.");
// Log.e(getMessage());
// }
//
// public BadContentException(String message) {
// super(message);
// Log.e(getMessage());
// }
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ning.http.client.RequestBuilder;
import com.ning.http.client.Response;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.yetiz.lib.acd.exception.BadContentException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date; | package org.yetiz.lib.acd;
/**
* Created by yeti on 2015/4/13.
*/
public class Utils {
public static JsonObject convertBodyToJson(Response response) {
try {
return ((JsonObject) new JsonParser().parse(response.getResponseBody("utf-8")));
} catch (IOException e) { | // Path: src/main/java/org/yetiz/lib/acd/exception/BadContentException.java
// public class BadContentException extends RuntimeException {
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public BadContentException() {
// super("Data can't convert to JSON type.");
// Log.e(getMessage());
// }
//
// public BadContentException(String message) {
// super(message);
// Log.e(getMessage());
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/Utils.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ning.http.client.RequestBuilder;
import com.ning.http.client.Response;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.yetiz.lib.acd.exception.BadContentException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date;
package org.yetiz.lib.acd;
/**
* Created by yeti on 2015/4/13.
*/
public class Utils {
public static JsonObject convertBodyToJson(Response response) {
try {
return ((JsonObject) new JsonParser().parse(response.getResponseBody("utf-8")));
} catch (IOException e) { | throw new BadContentException(); |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/BadContentException.java | // Path: src/main/java/org/yetiz/lib/utils/Log.java
// public class Log {
// private static Logger getLogger() {
// return LoggerFactory.getLogger(Thread.currentThread().getStackTrace()[3].getClassName());
// }
//
// private static Logger getLogger(String className) {
// return LoggerFactory.getLogger(className);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String description) {
// getLogger().trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String description) {
// getLogger().debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(String description) {
// getLogger().info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String description) {
// getLogger().warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(String description) {
// getLogger().error(" {}", description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String name, String description) {
// getLogger().trace("{}: {}", name, description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String name, String description) {
// getLogger().debug("{}: {}", name, description);
// }
//
// /**
// * info
// *
// */
// public static void i(String name, String description) {
// getLogger().info("{}: {}", name, description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String name, String description) {
// getLogger().warn("{}: {}", name, description);
// }
//
// /**
// * error
// *
// */
// public static void e(String name, String description) {
// getLogger().error("{}: {}", name, description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(Class clazz, String description) {
// getLogger(clazz.getName()).trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(Class clazz, String description) {
// getLogger(clazz.getName()).debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(Class clazz, String description) {
// getLogger(clazz.getName()).info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(Class clazz, String description) {
// getLogger(clazz.getName()).warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(Class clazz, String description) {
// getLogger(clazz.getName()).error(" {}", description);
// }
// }
| import org.yetiz.lib.utils.Log; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class BadContentException extends RuntimeException {
/**
* Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
public BadContentException() {
super("Data can't convert to JSON type."); | // Path: src/main/java/org/yetiz/lib/utils/Log.java
// public class Log {
// private static Logger getLogger() {
// return LoggerFactory.getLogger(Thread.currentThread().getStackTrace()[3].getClassName());
// }
//
// private static Logger getLogger(String className) {
// return LoggerFactory.getLogger(className);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String description) {
// getLogger().trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String description) {
// getLogger().debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(String description) {
// getLogger().info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String description) {
// getLogger().warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(String description) {
// getLogger().error(" {}", description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String name, String description) {
// getLogger().trace("{}: {}", name, description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String name, String description) {
// getLogger().debug("{}: {}", name, description);
// }
//
// /**
// * info
// *
// */
// public static void i(String name, String description) {
// getLogger().info("{}: {}", name, description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String name, String description) {
// getLogger().warn("{}: {}", name, description);
// }
//
// /**
// * error
// *
// */
// public static void e(String name, String description) {
// getLogger().error("{}: {}", name, description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(Class clazz, String description) {
// getLogger(clazz.getName()).trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(Class clazz, String description) {
// getLogger(clazz.getName()).debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(Class clazz, String description) {
// getLogger(clazz.getName()).info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(Class clazz, String description) {
// getLogger(clazz.getName()).warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(Class clazz, String description) {
// getLogger(clazz.getName()).error(" {}", description);
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/BadContentException.java
import org.yetiz.lib.utils.Log;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class BadContentException extends RuntimeException {
/**
* Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
public BadContentException() {
super("Data can't convert to JSON type."); | Log.e(getMessage()); |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/RequestForbiddenException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestForbiddenException extends ACDResponseException {
public RequestForbiddenException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/RequestForbiddenException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestForbiddenException extends ACDResponseException {
public RequestForbiddenException(Response response) {
super(response); | statusCode = ResponseCode.Error.REQUEST_FORBIDDEN; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/InvalidAuthTokenException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class InvalidAuthTokenException extends ACDResponseException {
public InvalidAuthTokenException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/InvalidAuthTokenException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class InvalidAuthTokenException extends ACDResponseException {
public InvalidAuthTokenException(Response response) {
super(response); | statusCode = ResponseCode.Error.INVALID_AUTH_TOKEN; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/ServiceUnavailableException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ServiceUnavailableException extends ACDResponseException {
public ServiceUnavailableException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/ServiceUnavailableException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class ServiceUnavailableException extends ACDResponseException {
public ServiceUnavailableException(Response response) {
super(response); | statusCode = ResponseCode.Error.SERVICE_UNAVAILABLE; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/AuthorizationRequiredException.java | // Path: src/main/java/org/yetiz/lib/utils/Log.java
// public class Log {
// private static Logger getLogger() {
// return LoggerFactory.getLogger(Thread.currentThread().getStackTrace()[3].getClassName());
// }
//
// private static Logger getLogger(String className) {
// return LoggerFactory.getLogger(className);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String description) {
// getLogger().trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String description) {
// getLogger().debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(String description) {
// getLogger().info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String description) {
// getLogger().warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(String description) {
// getLogger().error(" {}", description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String name, String description) {
// getLogger().trace("{}: {}", name, description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String name, String description) {
// getLogger().debug("{}: {}", name, description);
// }
//
// /**
// * info
// *
// */
// public static void i(String name, String description) {
// getLogger().info("{}: {}", name, description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String name, String description) {
// getLogger().warn("{}: {}", name, description);
// }
//
// /**
// * error
// *
// */
// public static void e(String name, String description) {
// getLogger().error("{}: {}", name, description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(Class clazz, String description) {
// getLogger(clazz.getName()).trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(Class clazz, String description) {
// getLogger(clazz.getName()).debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(Class clazz, String description) {
// getLogger(clazz.getName()).info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(Class clazz, String description) {
// getLogger(clazz.getName()).warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(Class clazz, String description) {
// getLogger(clazz.getName()).error(" {}", description);
// }
// }
| import org.yetiz.lib.utils.Log;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class AuthorizationRequiredException extends RuntimeException {
/**
* Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
private String client_id;
private String redirectUrl;
private boolean writable;
public AuthorizationRequiredException(String client_id, String redirectUrl, boolean writable) {
this.client_id = client_id;
this.redirectUrl = redirectUrl;
this.writable = writable; | // Path: src/main/java/org/yetiz/lib/utils/Log.java
// public class Log {
// private static Logger getLogger() {
// return LoggerFactory.getLogger(Thread.currentThread().getStackTrace()[3].getClassName());
// }
//
// private static Logger getLogger(String className) {
// return LoggerFactory.getLogger(className);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String description) {
// getLogger().trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String description) {
// getLogger().debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(String description) {
// getLogger().info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String description) {
// getLogger().warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(String description) {
// getLogger().error(" {}", description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(String name, String description) {
// getLogger().trace("{}: {}", name, description);
// }
//
// /**
// * debug
// *
// */
// public static void d(String name, String description) {
// getLogger().debug("{}: {}", name, description);
// }
//
// /**
// * info
// *
// */
// public static void i(String name, String description) {
// getLogger().info("{}: {}", name, description);
// }
//
// /**
// * warning
// *
// */
// public static void w(String name, String description) {
// getLogger().warn("{}: {}", name, description);
// }
//
// /**
// * error
// *
// */
// public static void e(String name, String description) {
// getLogger().error("{}: {}", name, description);
// }
//
// /**
// * verbose
// *
// */
// public static void t(Class clazz, String description) {
// getLogger(clazz.getName()).trace(" {}", description);
// }
//
// /**
// * debug
// *
// */
// public static void d(Class clazz, String description) {
// getLogger(clazz.getName()).debug(" {}", description);
// }
//
// /**
// * info
// *
// */
// public static void i(Class clazz, String description) {
// getLogger(clazz.getName()).info(" {}", description);
// }
//
// /**
// * warning
// *
// */
// public static void w(Class clazz, String description) {
// getLogger(clazz.getName()).warn(" {}", description);
// }
//
// /**
// * error
// *
// */
// public static void e(Class clazz, String description) {
// getLogger(clazz.getName()).error(" {}", description);
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/AuthorizationRequiredException.java
import org.yetiz.lib.utils.Log;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class AuthorizationRequiredException extends RuntimeException {
/**
* Constructs a new runtime exception with {@code null} as its
* detail message. The cause is not initialized, and may subsequently be
* initialized by a call to {@link #initCause}.
*/
private String client_id;
private String redirectUrl;
private boolean writable;
public AuthorizationRequiredException(String client_id, String redirectUrl, boolean writable) {
this.client_id = client_id;
this.redirectUrl = redirectUrl;
this.writable = writable; | Log.e(getMessage()); |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/BadParameterException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class BadParameterException extends ACDResponseException {
public BadParameterException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/BadParameterException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class BadParameterException extends ACDResponseException {
public BadParameterException(Response response) {
super(response); | statusCode = ResponseCode.Error.BAD_PARAMETER; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/RequestRateLimitedException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestRateLimitedException extends ACDResponseException {
public RequestRateLimitedException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/RequestRateLimitedException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestRateLimitedException extends ACDResponseException {
public RequestRateLimitedException(Response response) {
super(response); | statusCode = ResponseCode.Error.REQUEST_RATE_LIMITED; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/InternalServerErrorException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class InternalServerErrorException extends ACDResponseException {
public InternalServerErrorException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/InternalServerErrorException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class InternalServerErrorException extends ACDResponseException {
public InternalServerErrorException(Response response) {
super(response); | statusCode = ResponseCode.Error.INTERNAL_SERVER_ERROR; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/PreconditionFailedException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class PreconditionFailedException extends ACDResponseException {
public PreconditionFailedException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/PreconditionFailedException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class PreconditionFailedException extends ACDResponseException {
public PreconditionFailedException(Response response) {
super(response); | statusCode = ResponseCode.Error.PRECONDITION_FAILED; |
yetisno/ACD-JAPI | src/main/java/org/yetiz/lib/acd/exception/RequestConflictException.java | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
| import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode; | package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestConflictException extends ACDResponseException {
public RequestConflictException(Response response) {
super(response); | // Path: src/main/java/org/yetiz/lib/acd/ResponseCode.java
// public class ResponseCode {
//
// private static Map<Integer, Class> errorList = new HashMap<Integer, Class>();
//
// static {
// errorList.put(ResponseCode.Error.BAD_PARAMETER.getValue(), BadParameterException.class);
// errorList.put(ResponseCode.Error.INVALID_AUTH_TOKEN.getValue(), InvalidAuthTokenException.class);
// errorList.put(ResponseCode.Error.REQUEST_FORBIDDEN.getValue(), RequestForbiddenException.class);
// errorList.put(ResponseCode.Error.RESOURCE_NOT_FOUND.getValue(), ResourceNotFoundException.class);
// errorList.put(ResponseCode.Error.METHOD_NOT_ALLOWED.getValue(), MethodNotAllowedException.class);
// errorList.put(ResponseCode.Error.REQUEST_CONFLICT.getValue(), RequestConflictException.class);
// errorList.put(ResponseCode.Error.CONTENT_LENGTH_NOT_EXIST.getValue(), ContentLengthNotExistedException.class);
// errorList.put(ResponseCode.Error.PRECONDITION_FAILED.getValue(), PreconditionFailedException.class);
// errorList.put(ResponseCode.Error.REQUEST_RATE_LIMITED.getValue(), RequestRateLimitedException.class);
// errorList.put(ResponseCode.Error.INTERNAL_SERVER_ERROR.getValue(), InternalServerErrorException.class);
// errorList.put(ResponseCode.Error.SERVICE_UNAVAILABLE.getValue(), ServiceUnavailableException.class);
// }
//
// public static void check(Response response) {
// if (errorList.containsKey(response.getStatusCode())) {
// ACDResponseException exception = null;
// try {
// exception = ((ACDResponseException) errorList.get(response.getStatusCode())
// .getConstructor(Response.class).newInstance(response));
// } catch (Throwable t) {
// }
// throw exception;
// }
// }
//
// public enum Error {
// BAD_PARAMETER(400, "Bad input parameter. Error message should indicate which one and why."),
// INVALID_AUTH_TOKEN(401, "The client passed in the invalid Auth token. Client should refresh the token and " +
// "then try again."),
// REQUEST_FORBIDDEN(403, "\t1. Customer doesn’t exist.\n" +
// "\t2. Application not registered.\n" +
// "\t3. Application try to access to properties not belong to an App.\n" +
// "\t4. Application try to trash/purge root node.\n" +
// "\t5. Application try to update contentProperties.\n" +
// "\t6. Operation is blocked (for third-party apps)."),
// RESOURCE_NOT_FOUND(404, "Resource not found."),
// METHOD_NOT_ALLOWED(405, "The resource doesn't support the specified HTTP verb."),
// REQUEST_CONFLICT(409, "Conflict."),
// CONTENT_LENGTH_NOT_EXIST(411, "The Content-Length header was not specified."),
// PRECONDITION_FAILED(412, "Precondition failed."),
// REQUEST_RATE_LIMITED(429, "Too many request for rate limiting."),
// INTERNAL_SERVER_ERROR(500, "Servers are not working as expected. The request is probably valid but needs to " +
// "be requested again later."),
// SERVICE_UNAVAILABLE(503, "Service Unavailable.");
//
//
// private int value;
// private String description;
//
// private Error(int value, String description) {
// this.value = value;
// this.description = description;
// }
//
// public int getValue() {
// return value;
// }
//
// public String getDescription() {
// return description;
// }
// }
// }
// Path: src/main/java/org/yetiz/lib/acd/exception/RequestConflictException.java
import com.ning.http.client.Response;
import org.yetiz.lib.acd.ResponseCode;
package org.yetiz.lib.acd.exception;
/**
* Created by yeti on 2015/4/13.
*/
public class RequestConflictException extends ACDResponseException {
public RequestConflictException(Response response) {
super(response); | statusCode = ResponseCode.Error.REQUEST_CONFLICT; |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/FeedbackPreference.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/ActivityUtils.java
// public class ActivityUtils {
// private ActivityUtils() {}
//
// public static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (Exception e) {
// // ignore
// e.printStackTrace();
// }
// }
// }
| import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.DialogPreference;
import android.text.Html;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.ActivityUtils; | super(context, attrs);
init();
}
private void init() {
final Context context = getContext();
PackageManager packageManager = context.getPackageManager();
String versionName;
try {
PackageInfo info = packageManager.getPackageInfo(context.getPackageName(), 0);
versionName = info.versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = "1.0";
}
setTitle(R.string.dlg_feedback_title);
setSummary(new StringBuilder(getContext().getString(R.string.app_name)).append(" v").append(versionName));
setDialogTitle(R.string.dlg_feedback_title);
setDialogMessage(Html.fromHtml(getContext().getString(R.string.dlg_feedback_content)));
setPositiveButtonText(R.string.dlg_feedback_positive_text);
setNegativeButtonText(R.string.dlg_feedback_negative_text);
}
@Override
public void onClick(DialogInterface dialog, int which) {
super.onClick(dialog, which);
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + getContext().getPackageName())); | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/ActivityUtils.java
// public class ActivityUtils {
// private ActivityUtils() {}
//
// public static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (Exception e) {
// // ignore
// e.printStackTrace();
// }
// }
// }
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/FeedbackPreference.java
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.DialogPreference;
import android.text.Html;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.ActivityUtils;
super(context, attrs);
init();
}
private void init() {
final Context context = getContext();
PackageManager packageManager = context.getPackageManager();
String versionName;
try {
PackageInfo info = packageManager.getPackageInfo(context.getPackageName(), 0);
versionName = info.versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = "1.0";
}
setTitle(R.string.dlg_feedback_title);
setSummary(new StringBuilder(getContext().getString(R.string.app_name)).append(" v").append(versionName));
setDialogTitle(R.string.dlg_feedback_title);
setDialogMessage(Html.fromHtml(getContext().getString(R.string.dlg_feedback_content)));
setPositiveButtonText(R.string.dlg_feedback_positive_text);
setNegativeButtonText(R.string.dlg_feedback_negative_text);
}
@Override
public void onClick(DialogInterface dialog, int which) {
super.onClick(dialog, which);
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + getContext().getPackageName())); | ActivityUtils.startActivitySafe(getContext(), intent); |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/ShareAppPreference.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/PlayStoreUtils.java
// public class PlayStoreUtils {
//
// private static final String MARKET_DETAILS_PREFIX = "market://details?id=";
// private static final String WEB_DETAIL_PREFIX = "https://play.google.com/store/apps/details?id=";
//
// public static String generateAppDetailPageLink(String packageName, boolean isWebPage) {
// return (isWebPage ? WEB_DETAIL_PREFIX : MARKET_DETAILS_PREFIX) + packageName;
// }
//
// public static void launchAppDetailPage(Context context, String packageName, boolean isWebPage) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(generateAppDetailPageLink(packageName, isWebPage)));
// startActivitySafe(context, intent);
// }
//
// public static void launchAuthorAppsPage(Context context) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:MoboDev"));
// startActivitySafe(context, intent);
// }
//
// private static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.toast_play_store_unavailable, Toast.LENGTH_SHORT).show();
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.PlayStoreUtils; | }
public ShareAppPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ShareAppPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
setTitle(R.string.pref_share_app_title);
setSummary(R.string.pref_share_app_description);
}
@Override
protected void onClick() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, generateShareText());
sendIntent.setType("text/plain");
getContext().startActivity(Intent.createChooser(sendIntent, getContext().getText(R.string.send_to)));
}
private String generateShareText() {
if (mTextToShare == null) {
mTextToShare = new StringBuilder(getContext().getString(R.string.app_name))
.append(' ') | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/PlayStoreUtils.java
// public class PlayStoreUtils {
//
// private static final String MARKET_DETAILS_PREFIX = "market://details?id=";
// private static final String WEB_DETAIL_PREFIX = "https://play.google.com/store/apps/details?id=";
//
// public static String generateAppDetailPageLink(String packageName, boolean isWebPage) {
// return (isWebPage ? WEB_DETAIL_PREFIX : MARKET_DETAILS_PREFIX) + packageName;
// }
//
// public static void launchAppDetailPage(Context context, String packageName, boolean isWebPage) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(generateAppDetailPageLink(packageName, isWebPage)));
// startActivitySafe(context, intent);
// }
//
// public static void launchAuthorAppsPage(Context context) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:MoboDev"));
// startActivitySafe(context, intent);
// }
//
// private static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.toast_play_store_unavailable, Toast.LENGTH_SHORT).show();
// }
// }
// }
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/ShareAppPreference.java
import android.content.Context;
import android.content.Intent;
import android.preference.Preference;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.PlayStoreUtils;
}
public ShareAppPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ShareAppPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
setTitle(R.string.pref_share_app_title);
setSummary(R.string.pref_share_app_description);
}
@Override
protected void onClick() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, generateShareText());
sendIntent.setType("text/plain");
getContext().startActivity(Intent.createChooser(sendIntent, getContext().getText(R.string.send_to)));
}
private String generateShareText() {
if (mTextToShare == null) {
mTextToShare = new StringBuilder(getContext().getString(R.string.app_name))
.append(' ') | .append(PlayStoreUtils.generateAppDetailPageLink(getContext().getPackageName(), true)) |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/RecommendAppPreference.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/PlayStoreUtils.java
// public class PlayStoreUtils {
//
// private static final String MARKET_DETAILS_PREFIX = "market://details?id=";
// private static final String WEB_DETAIL_PREFIX = "https://play.google.com/store/apps/details?id=";
//
// public static String generateAppDetailPageLink(String packageName, boolean isWebPage) {
// return (isWebPage ? WEB_DETAIL_PREFIX : MARKET_DETAILS_PREFIX) + packageName;
// }
//
// public static void launchAppDetailPage(Context context, String packageName, boolean isWebPage) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(generateAppDetailPageLink(packageName, isWebPage)));
// startActivitySafe(context, intent);
// }
//
// public static void launchAuthorAppsPage(Context context) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:MoboDev"));
// startActivitySafe(context, intent);
// }
//
// private static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.toast_play_store_unavailable, Toast.LENGTH_SHORT).show();
// }
// }
// }
| import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.PlayStoreUtils; | package io.github.mobodev.heartbeatfixerforgcm.preference;
/**
* Created by shaobin on 1/18/15.
*/
public class RecommendAppPreference extends Preference {
public RecommendAppPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public RecommendAppPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public RecommendAppPreference(Context context) {
super(context);
init();
}
private void init() {
setTitle(R.string.pref_recommend_apps_title);
setSummary(R.string.pref_recommend_apps_description);
}
@Override
protected void onClick() { | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/PlayStoreUtils.java
// public class PlayStoreUtils {
//
// private static final String MARKET_DETAILS_PREFIX = "market://details?id=";
// private static final String WEB_DETAIL_PREFIX = "https://play.google.com/store/apps/details?id=";
//
// public static String generateAppDetailPageLink(String packageName, boolean isWebPage) {
// return (isWebPage ? WEB_DETAIL_PREFIX : MARKET_DETAILS_PREFIX) + packageName;
// }
//
// public static void launchAppDetailPage(Context context, String packageName, boolean isWebPage) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(generateAppDetailPageLink(packageName, isWebPage)));
// startActivitySafe(context, intent);
// }
//
// public static void launchAuthorAppsPage(Context context) {
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:MoboDev"));
// startActivitySafe(context, intent);
// }
//
// private static void startActivitySafe(Context context, Intent intent) {
// try {
// context.startActivity(intent);
// } catch (ActivityNotFoundException e) {
// Toast.makeText(context, R.string.toast_play_store_unavailable, Toast.LENGTH_SHORT).show();
// }
// }
// }
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/RecommendAppPreference.java
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.PlayStoreUtils;
package io.github.mobodev.heartbeatfixerforgcm.preference;
/**
* Created by shaobin on 1/18/15.
*/
public class RecommendAppPreference extends Preference {
public RecommendAppPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public RecommendAppPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public RecommendAppPreference(Context context) {
super(context);
init();
}
private void init() {
setTitle(R.string.pref_recommend_apps_title);
setSummary(R.string.pref_recommend_apps_description);
}
@Override
protected void onClick() { | PlayStoreUtils.launchAuthorAppsPage(getContext()); |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/DonatePreference.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/DialogHelper.java
// public class DialogHelper {
// public static final String TAG_FRAGMENT_DONATION = "dialog_donate";
//
// public static void showDonateDialog(@NonNull AppCompatActivity activity) {
// showDialog(activity, DonateDialogFragment.class, TAG_FRAGMENT_DONATION);
// }
//
// private static void showDialog(@NonNull AppCompatActivity activity,
// @NonNull Class clazz,
// @NonNull String tag) {
// try {
// showDialog(activity, (DialogFragment) clazz.newInstance(), tag);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static void showDialog(@NonNull AppCompatActivity activity,
// @NonNull DialogFragment fragment,
// @NonNull String tag) {
// if (Looper.myLooper() != Looper.getMainLooper()) {
// throw new RuntimeException("Should be called on the main thread");
// }
//
// FragmentManager fm = activity.getSupportFragmentManager();
// FragmentTransaction ft = fm.beginTransaction();
// Fragment prev = fm.findFragmentByTag(tag);
// if (prev != null) {
// ft.remove(prev);
// }
// ft.addToBackStack(null);
// fragment.show(ft, tag);
// }
// }
| import android.content.Context;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.DialogHelper;
import io.github.mobodev.heartbeatfixerforgcm.R; | package io.github.mobodev.heartbeatfixerforgcm.preference;
/**
* Created by shaobin on 3/9/15.
*/
public class DonatePreference extends Preference {
public DonatePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public DonatePreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public DonatePreference(Context context) {
super(context);
init();
}
private void init() {
setTitle(R.string.pref_donate_title);
setSummary(R.string.pref_donate_summary);
}
@Override
protected void onClick() { | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/DialogHelper.java
// public class DialogHelper {
// public static final String TAG_FRAGMENT_DONATION = "dialog_donate";
//
// public static void showDonateDialog(@NonNull AppCompatActivity activity) {
// showDialog(activity, DonateDialogFragment.class, TAG_FRAGMENT_DONATION);
// }
//
// private static void showDialog(@NonNull AppCompatActivity activity,
// @NonNull Class clazz,
// @NonNull String tag) {
// try {
// showDialog(activity, (DialogFragment) clazz.newInstance(), tag);
// } catch (InstantiationException e) {
// throw new RuntimeException(e);
// } catch (IllegalAccessException e) {
// throw new RuntimeException(e);
// }
// }
//
// private static void showDialog(@NonNull AppCompatActivity activity,
// @NonNull DialogFragment fragment,
// @NonNull String tag) {
// if (Looper.myLooper() != Looper.getMainLooper()) {
// throw new RuntimeException("Should be called on the main thread");
// }
//
// FragmentManager fm = activity.getSupportFragmentManager();
// FragmentTransaction ft = fm.beginTransaction();
// Fragment prev = fm.findFragmentByTag(tag);
// if (prev != null) {
// ft.remove(prev);
// }
// ft.addToBackStack(null);
// fragment.show(ft, tag);
// }
// }
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/DonatePreference.java
import android.content.Context;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.DialogHelper;
import io.github.mobodev.heartbeatfixerforgcm.R;
package io.github.mobodev.heartbeatfixerforgcm.preference;
/**
* Created by shaobin on 3/9/15.
*/
public class DonatePreference extends Preference {
public DonatePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public DonatePreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public DonatePreference(Context context) {
super(context);
init();
}
private void init() {
setTitle(R.string.pref_donate_title);
setSummary(R.string.pref_donate_summary);
}
@Override
protected void onClick() { | DialogHelper.showDonateDialog((AppCompatActivity)getContext()); |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatFixerUtils.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/DeviceUtils.java
// public class DeviceUtils {
// private DeviceUtils() {}
//
// public static boolean hasHoneycomb() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
// }
//
// public static boolean hasKitkat() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// }
//
// public static boolean hasLollipop() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
// }
// }
| import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.util.Log;
import io.github.mobodev.heartbeatfixerforgcm.utils.DeviceUtils; | return;
}
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
if (!fromNetworkStateChange || sNetworkState != NetworkState.CONNECTED) {
sNetworkState = NetworkState.CONNECTED;
int intervalMillis;
if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
intervalMillis = getHeartbeatIntervalMillisForWifi(context);
} else {
intervalMillis = getHeartbeatIntervalMillisForMobile(context);
}
setNextHeartbeatRequest(context, intervalMillis);
}
} else {
if (!fromNetworkStateChange || sNetworkState != NetworkState.DISCONNECTED) {
sNetworkState = NetworkState.DISCONNECTED;
cancelHeartbeatRequest(context);
}
}
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void setNextHeartbeatRequest(Context context, int intervalMillis) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long triggerAtMillis = System.currentTimeMillis() + intervalMillis;
Log.d(TAG, "setNextHeartbeatRequest at: " + DateFormat.format("yyyy-MM-dd hh:mm:ss", triggerAtMillis));
PendingIntent broadcastPendingIntent = getBroadcastPendingIntent(context);
int rtcWakeup = AlarmManager.RTC_WAKEUP; | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/DeviceUtils.java
// public class DeviceUtils {
// private DeviceUtils() {}
//
// public static boolean hasHoneycomb() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
// }
//
// public static boolean hasKitkat() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// }
//
// public static boolean hasLollipop() {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
// }
// }
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatFixerUtils.java
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.format.DateFormat;
import android.util.Log;
import io.github.mobodev.heartbeatfixerforgcm.utils.DeviceUtils;
return;
}
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
if (!fromNetworkStateChange || sNetworkState != NetworkState.CONNECTED) {
sNetworkState = NetworkState.CONNECTED;
int intervalMillis;
if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
intervalMillis = getHeartbeatIntervalMillisForWifi(context);
} else {
intervalMillis = getHeartbeatIntervalMillisForMobile(context);
}
setNextHeartbeatRequest(context, intervalMillis);
}
} else {
if (!fromNetworkStateChange || sNetworkState != NetworkState.DISCONNECTED) {
sNetworkState = NetworkState.DISCONNECTED;
cancelHeartbeatRequest(context);
}
}
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void setNextHeartbeatRequest(Context context, int intervalMillis) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long triggerAtMillis = System.currentTimeMillis() + intervalMillis;
Log.d(TAG, "setNextHeartbeatRequest at: " + DateFormat.format("yyyy-MM-dd hh:mm:ss", triggerAtMillis));
PendingIntent broadcastPendingIntent = getBroadcastPendingIntent(context);
int rtcWakeup = AlarmManager.RTC_WAKEUP; | if (DeviceUtils.hasKitkat()) { |
shaobin0604/HeartbeatFixerForGCM | app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatReceiver.java | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatFixerForGcmApp.java
// static final String TAG = "HeartbeatFixerForGCM";
| import static io.github.mobodev.heartbeatfixerforgcm.HeartbeatFixerForGcmApp.TAG;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log; | package io.github.mobodev.heartbeatfixerforgcm;
/**
* Created by shaobin on 3/8/15.
*/
public class HeartbeatReceiver extends BroadcastReceiver {
private static final Intent GTALK_HEART_BEAT_INTENT = new Intent("com.google.android.intent.action.GTALK_HEARTBEAT");
private static final Intent MCS_MCS_HEARTBEAT_INTENT = new Intent("com.google.android.intent.action.MCS_HEARTBEAT");
@Override
public void onReceive(Context context, Intent intent) {
context.sendBroadcast(GTALK_HEART_BEAT_INTENT);
context.sendBroadcast(MCS_MCS_HEARTBEAT_INTENT); | // Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatFixerForGcmApp.java
// static final String TAG = "HeartbeatFixerForGCM";
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/HeartbeatReceiver.java
import static io.github.mobodev.heartbeatfixerforgcm.HeartbeatFixerForGcmApp.TAG;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
package io.github.mobodev.heartbeatfixerforgcm;
/**
* Created by shaobin on 3/8/15.
*/
public class HeartbeatReceiver extends BroadcastReceiver {
private static final Intent GTALK_HEART_BEAT_INTENT = new Intent("com.google.android.intent.action.GTALK_HEARTBEAT");
private static final Intent MCS_MCS_HEARTBEAT_INTENT = new Intent("com.google.android.intent.action.MCS_HEARTBEAT");
@Override
public void onReceive(Context context, Intent intent) {
context.sendBroadcast(GTALK_HEART_BEAT_INTENT);
context.sendBroadcast(MCS_MCS_HEARTBEAT_INTENT); | Log.d(TAG, "HeartbeatReceiver sent heartbeat request"); |
BinaryMuse/gwt-wizard | src/net/binarymuse/gwt/client/ui/wizard/view/widget/WizardNavigationPanel.java | // Path: src/net/binarymuse/gwt/client/ui/wizard/Wizard.java
// public interface Display extends WidgetDisplay {
// /**
// * The {@link Wizard}'s title is handled by an object that implements
// * GWT's <code>HasHTML</code>.
// * @return implementation of GWT's <code>HasHTML</code> for the {@link Wizard}'s title
// */
// HasHTML getCaption();
// /**
// * The {@link Wizard} maintains a list of its pages via an
// * implementation of {@link HasWizardTitles}.
// * @return implementation of {@link HasWizardTitles} for the {@link Wizard}'s page titles
// */
// HasWizardTitles getPageList();
// /**
// * The {@link Wizard}'s button bar is an implementation of
// * {@link HasWizardButtons}. If you implement your own button
// * bar, you can remove certain buttons (e.g., "Cancel")
// * by returning <code>null</code> in their getter functions (e.g.
// * {@link HasWizardButtons#getCancelButton()}.
// * @return implementation of {@link HasWizardButtons} for the {@link Wizard}'s button bar
// */
// HasWizardButtons getButtonBar();
// /**
// * The main content area is implemented with a GWT DeckPanel.
// * To keep this decision from being forced upon user-created
// * views, we extend DeckPanel into {@link WizardDeckPanel},
// * which implements {@link HasIndexedWidgets}. If you use a
// * panel that doesn't implement GWT's IndexedPanel, you have to
// * keep track of index-to-Widget relationships yourself,
// * since {@link Wizard} uses <code>getContent().showWidget(int index)</code>.
// * @return implementation of {@link HasIndexedWidgets} for the {@link Wizard}'s main content area
// */
// HasIndexedWidgets getContent();
// /**
// * Returns the Display's {@link HandlerFactory}, which provides
// * common event handlers for user created {@link Wizard}s and {@link WizardPage}s.
// * @return the {@link HandlerFactory} for this display
// */
// HandlerFactory<Display> getHandlerFactory();
// /**
// * Indicate to the view that work is being done. The
// * default view shows an animated "working" icon.
// */
// void startProcessing();
// /**
// * Indicate to the view that work is no longer being
// * done (used after calling {@link #startProcessing()}.
// */
// void stopProcessing();
// /**
// * {@link Wizard} is a composite that. <code>asWidget()</code>
// * returns the Widget that the Wizard will wrap using
// * <code>initWidget</code>.
// * @return the Widget the {@link Wizard} Composite will wrap
// */
// Widget asWidget();
// }
//
// Path: src/net/binarymuse/gwt/client/ui/wizard/view/HasWizardButtonMethods.java
// public interface HasWizardButtonMethods extends HasClickHandlers {
//
// /**
// * Whether or not the button is enabled.
// * @return <code>true</code> if enabled, <code>false</code> otherwise
// */
// public boolean isEnabled();
// /**
// * Set the enabled state of the button.
// * @param enabled <code>true</code> to enable the button, <code>false</code> to disable it
// */
// public void setEnabled(boolean enabled);
// /**
// * Whether or not the button is visible.
// * @return <code>true</code> if visible, <code>false</code> otherwise
// */
// public boolean isVisible();
// /**
// * Set the visibility of the button.
// * @param visible <code>true</code> to show the button, <code>false</code> to hide it
// */
// public void setVisible(boolean visible);
// /**
// * Simulate a click on the button.
// */
// public void click();
//
// }
//
// Path: src/net/binarymuse/gwt/client/ui/wizard/view/HasWizardButtons.java
// public interface HasWizardButtons {
// public HasWizardButtonMethods getCancelButton();
// public HasWizardButtonMethods getFinishButton();
// public HasWizardButtonMethods getPreviousButton();
// public HasWizardButtonMethods getNextButton();
// }
| import net.binarymuse.gwt.client.ui.wizard.Wizard.Display;
import net.binarymuse.gwt.client.ui.wizard.view.HasWizardButtonMethods;
import net.binarymuse.gwt.client.ui.wizard.view.HasWizardButtons;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel; | this.container.setWidth("100%");
HTML leftSpacer = new HTML(" ");
leftSpacer.setWidth("100%");
this.cancel = new WizardButton(cancelText);
this.finish = new WizardButton(finishText);
HTML spacer = new HTML(" ");
this.prev = new WizardButton(prevText);
this.next = new WizardButton(nextText);
this.container.add(leftSpacer);
this.container.add(this.cancel);
this.container.add(this.finish);
this.container.add(spacer);
this.container.add(this.prev);
this.container.add(this.next);
this.container.setCellWidth(leftSpacer, "100%");
this.cancel.setWidth("75px");
this.cancel.setHeight("25px");
this.finish.setWidth("75px");
this.finish.setHeight("25px");
this.container.setCellWidth(spacer, "20px");
this.prev.setWidth("75px");
this.prev.setHeight("25px");
this.next.setWidth("75px");
this.next.setHeight("25px");
}
@Override | // Path: src/net/binarymuse/gwt/client/ui/wizard/Wizard.java
// public interface Display extends WidgetDisplay {
// /**
// * The {@link Wizard}'s title is handled by an object that implements
// * GWT's <code>HasHTML</code>.
// * @return implementation of GWT's <code>HasHTML</code> for the {@link Wizard}'s title
// */
// HasHTML getCaption();
// /**
// * The {@link Wizard} maintains a list of its pages via an
// * implementation of {@link HasWizardTitles}.
// * @return implementation of {@link HasWizardTitles} for the {@link Wizard}'s page titles
// */
// HasWizardTitles getPageList();
// /**
// * The {@link Wizard}'s button bar is an implementation of
// * {@link HasWizardButtons}. If you implement your own button
// * bar, you can remove certain buttons (e.g., "Cancel")
// * by returning <code>null</code> in their getter functions (e.g.
// * {@link HasWizardButtons#getCancelButton()}.
// * @return implementation of {@link HasWizardButtons} for the {@link Wizard}'s button bar
// */
// HasWizardButtons getButtonBar();
// /**
// * The main content area is implemented with a GWT DeckPanel.
// * To keep this decision from being forced upon user-created
// * views, we extend DeckPanel into {@link WizardDeckPanel},
// * which implements {@link HasIndexedWidgets}. If you use a
// * panel that doesn't implement GWT's IndexedPanel, you have to
// * keep track of index-to-Widget relationships yourself,
// * since {@link Wizard} uses <code>getContent().showWidget(int index)</code>.
// * @return implementation of {@link HasIndexedWidgets} for the {@link Wizard}'s main content area
// */
// HasIndexedWidgets getContent();
// /**
// * Returns the Display's {@link HandlerFactory}, which provides
// * common event handlers for user created {@link Wizard}s and {@link WizardPage}s.
// * @return the {@link HandlerFactory} for this display
// */
// HandlerFactory<Display> getHandlerFactory();
// /**
// * Indicate to the view that work is being done. The
// * default view shows an animated "working" icon.
// */
// void startProcessing();
// /**
// * Indicate to the view that work is no longer being
// * done (used after calling {@link #startProcessing()}.
// */
// void stopProcessing();
// /**
// * {@link Wizard} is a composite that. <code>asWidget()</code>
// * returns the Widget that the Wizard will wrap using
// * <code>initWidget</code>.
// * @return the Widget the {@link Wizard} Composite will wrap
// */
// Widget asWidget();
// }
//
// Path: src/net/binarymuse/gwt/client/ui/wizard/view/HasWizardButtonMethods.java
// public interface HasWizardButtonMethods extends HasClickHandlers {
//
// /**
// * Whether or not the button is enabled.
// * @return <code>true</code> if enabled, <code>false</code> otherwise
// */
// public boolean isEnabled();
// /**
// * Set the enabled state of the button.
// * @param enabled <code>true</code> to enable the button, <code>false</code> to disable it
// */
// public void setEnabled(boolean enabled);
// /**
// * Whether or not the button is visible.
// * @return <code>true</code> if visible, <code>false</code> otherwise
// */
// public boolean isVisible();
// /**
// * Set the visibility of the button.
// * @param visible <code>true</code> to show the button, <code>false</code> to hide it
// */
// public void setVisible(boolean visible);
// /**
// * Simulate a click on the button.
// */
// public void click();
//
// }
//
// Path: src/net/binarymuse/gwt/client/ui/wizard/view/HasWizardButtons.java
// public interface HasWizardButtons {
// public HasWizardButtonMethods getCancelButton();
// public HasWizardButtonMethods getFinishButton();
// public HasWizardButtonMethods getPreviousButton();
// public HasWizardButtonMethods getNextButton();
// }
// Path: src/net/binarymuse/gwt/client/ui/wizard/view/widget/WizardNavigationPanel.java
import net.binarymuse.gwt.client.ui.wizard.Wizard.Display;
import net.binarymuse.gwt.client.ui.wizard.view.HasWizardButtonMethods;
import net.binarymuse.gwt.client.ui.wizard.view.HasWizardButtons;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
this.container.setWidth("100%");
HTML leftSpacer = new HTML(" ");
leftSpacer.setWidth("100%");
this.cancel = new WizardButton(cancelText);
this.finish = new WizardButton(finishText);
HTML spacer = new HTML(" ");
this.prev = new WizardButton(prevText);
this.next = new WizardButton(nextText);
this.container.add(leftSpacer);
this.container.add(this.cancel);
this.container.add(this.finish);
this.container.add(spacer);
this.container.add(this.prev);
this.container.add(this.next);
this.container.setCellWidth(leftSpacer, "100%");
this.cancel.setWidth("75px");
this.cancel.setHeight("25px");
this.finish.setWidth("75px");
this.finish.setHeight("25px");
this.container.setCellWidth(spacer, "20px");
this.prev.setWidth("75px");
this.prev.setHeight("25px");
this.next.setWidth("75px");
this.next.setHeight("25px");
}
@Override | public HasWizardButtonMethods getCancelButton() { |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
| import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap; |
public Builder textAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) { | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
public Builder textAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) { | overlayModules.add(new CpuUsageModule()); |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
| import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap; | public Builder textAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule()); | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
public Builder textAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule()); | overlayModules.add(new MemInfoModule(application)); |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
| import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap; | this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule());
overlayModules.add(new MemInfoModule(application)); | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
this.textAlpha = alpha;
return this;
}
public Builder allowSystemLayer(boolean allowSystemLayer) {
this.allowSystemLayer = allowSystemLayer;
return this;
}
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule());
overlayModules.add(new MemInfoModule(application)); | overlayModules.add(new FpsModule()); |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
| import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap; |
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule());
overlayModules.add(new MemInfoModule(application));
overlayModules.add(new FpsModule());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Removes any CpuUsageModule/CpuFreqModule if a device is running Android O and above
Iterator<OverlayModule> iterator = overlayModules.iterator();
while (iterator.hasNext()) {
OverlayModule overlayModule = iterator.next(); | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
// public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
//
// public static final int DEFAULT_INTERVAL = 2000; // 2000ms
//
// public CpuFreqModule() {
// super(null, null);
// }
//
// public CpuFreqModule(int interval) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
//
// public CpuFreqModule(int interval, ViewModule<List<CpuFreq>> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
// public class CpuUsageModule extends OverlayModule<CpuUsage> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public CpuUsageModule() {
// super(null, null);
// }
//
// public CpuUsageModule(int interval) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public CpuUsageModule(ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
//
// public CpuUsageModule(int interval, ViewModule<CpuUsage> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
// public class FpsModule extends OverlayModule<Double> {
//
// public static final int DEFAULT_INTERVAL = 1000; // 1000ms
//
// public FpsModule() {
// super(null, null);
// }
//
// public FpsModule(int interval) {
// super(null, null);
// }
//
// public FpsModule(int interval, int layoutResId) {
// super(null, null);
// }
//
// public FpsModule(ViewModule<Double> viewModule) {
// super(null, null);
// }
//
// public FpsModule(int interval, ViewModule<Double> viewModule) {
// super(null, null);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
// public class MemInfoModule extends OverlayModule<MemInfo> {
//
// public static final int DEFAULT_INTERVAL = 1500; // 1500ms
//
// public MemInfoModule(@NonNull Context context) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
// super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
// }
//
// public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, DEFAULT_INTERVAL), viewModule);
// }
//
// public MemInfoModule(@NonNull Context context, int interval, @NonNull ViewModule<MemInfo> viewModule) {
// super(new MemInfoDataModule(context, interval), viewModule);
// }
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/DebugOverlay.java
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.ms_square.debugoverlay.modules.CpuFreqModule;
import com.ms_square.debugoverlay.modules.CpuUsageModule;
import com.ms_square.debugoverlay.modules.FpsModule;
import com.ms_square.debugoverlay.modules.MemInfoModule;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
public Builder notification(boolean show) {
this.showNotification = show;
return this;
}
public Builder notification(boolean show, @Nullable String activityName) {
this.showNotification = show;
this.activityName = activityName;
return this;
}
public DebugOverlay build() {
if (!allowSystemLayer) {
if (showNotification) {
Log.w(TAG, "if systemLayer is not allowed, notification is not supported; thus don't show notification.");
showNotification = false;
}
}
if (overlayModules.size() == 0) {
overlayModules.add(new CpuUsageModule());
overlayModules.add(new MemInfoModule(application));
overlayModules.add(new FpsModule());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Removes any CpuUsageModule/CpuFreqModule if a device is running Android O and above
Iterator<OverlayModule> iterator = overlayModules.iterator();
while (iterator.hasNext()) {
OverlayModule overlayModule = iterator.next(); | if (overlayModule instanceof CpuUsageModule || overlayModule instanceof CpuFreqModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class MemInfoModule extends OverlayModule<MemInfo> {
public static final int DEFAULT_INTERVAL = 1500; // 1500ms
public MemInfoModule(@NonNull Context context) {
super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
}
public MemInfoModule(@NonNull Context context, int interval) {
super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
}
public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class MemInfoModule extends OverlayModule<MemInfo> {
public static final int DEFAULT_INTERVAL = 1500; // 1500ms
public MemInfoModule(@NonNull Context context) {
super(new MemInfoDataModule(context, DEFAULT_INTERVAL), new MemInfoViewModule());
}
public MemInfoModule(@NonNull Context context, int interval) {
super(new MemInfoDataModule(context, interval), new MemInfoViewModule());
}
public MemInfoModule(@NonNull Context context, int interval, @LayoutRes int layoutResId) {
super(new MemInfoDataModule(context, interval), new MemInfoViewModule(layoutResId));
}
| public MemInfoModule(@NonNull Context context, @NonNull ViewModule<MemInfo> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/BaseDataModule.java | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/DataModule.java
// public interface DataModule<T> {
//
// void start();
//
// void stop();
//
// void notifyObservers();
//
// void addObserver(DataObserver<T> observer);
//
// void removeObserver(DataObserver<T> observer);
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/DataObserver.java
// public interface DataObserver<T> {
// void onDataAvailable(T data);
// }
| import com.ms_square.debugoverlay.DataModule;
import com.ms_square.debugoverlay.DataObserver; | package com.ms_square.debugoverlay.modules;
public abstract class BaseDataModule<T> implements DataModule<T> {
@Override
public void notifyObservers() {
}
@Override | // Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/DataModule.java
// public interface DataModule<T> {
//
// void start();
//
// void stop();
//
// void notifyObservers();
//
// void addObserver(DataObserver<T> observer);
//
// void removeObserver(DataObserver<T> observer);
// }
//
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/DataObserver.java
// public interface DataObserver<T> {
// void onDataAvailable(T data);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/BaseDataModule.java
import com.ms_square.debugoverlay.DataModule;
import com.ms_square.debugoverlay.DataObserver;
package com.ms_square.debugoverlay.modules;
public abstract class BaseDataModule<T> implements DataModule<T> {
@Override
public void notifyObservers() {
}
@Override | public void addObserver(DataObserver observer) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.content.Context;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class MemInfoModule extends OverlayModule<MemInfo> {
public static final int DEFAULT_INTERVAL = 1500; // 1500ms
public MemInfoModule(Context context) {
super(null, null);
}
public MemInfoModule(Context context, int interval) {
super(null, null);
}
public MemInfoModule(Context context, int interval, int layoutResId) {
super(null, null);
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/MemInfoModule.java
import android.content.Context;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class MemInfoModule extends OverlayModule<MemInfo> {
public static final int DEFAULT_INTERVAL = 1500; // 1500ms
public MemInfoModule(Context context) {
super(null, null);
}
public MemInfoModule(Context context, int interval) {
super(null, null);
}
public MemInfoModule(Context context, int interval, int layoutResId) {
super(null, null);
}
| public MemInfoModule(Context context, ViewModule<MemInfo> viewModule) { |
Manabu-GT/DebugOverlay-Android | sample/src/androidTest/java/com/ms_square/debugoverlay/SystemLayerInstrumentedTest.java | // Path: sample/src/main/java/com/ms_square/debugoverlay/sample/MainActivity.java
// public class MainActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Timber.d("fab clicked");
// startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
// }
// });
//
// Timber.d("onCreate() called");
// }
//
// @Override
// public void onResume() {
// super.onResume();
// Timber.d("onResume() called");
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.menu_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
| import android.support.test.filters.LargeTest;
import android.support.test.filters.SdkSuppress;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ms_square.debugoverlay.sample.MainActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith; | package com.ms_square.debugoverlay;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
@LargeTest
public class SystemLayerInstrumentedTest extends DebugOverlayInstrumentedTest {
@Rule | // Path: sample/src/main/java/com/ms_square/debugoverlay/sample/MainActivity.java
// public class MainActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Timber.d("fab clicked");
// startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
// }
// });
//
// Timber.d("onCreate() called");
// }
//
// @Override
// public void onResume() {
// super.onResume();
// Timber.d("onResume() called");
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.menu_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
// Path: sample/src/androidTest/java/com/ms_square/debugoverlay/SystemLayerInstrumentedTest.java
import android.support.test.filters.LargeTest;
import android.support.test.filters.SdkSuppress;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ms_square.debugoverlay.sample.MainActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
package com.ms_square.debugoverlay;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
@LargeTest
public class SystemLayerInstrumentedTest extends DebugOverlayInstrumentedTest {
@Rule | public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class); |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class CpuUsageModule extends OverlayModule<CpuUsage> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public CpuUsageModule() {
super(null, null);
}
public CpuUsageModule(int interval) {
super(null, null);
}
public CpuUsageModule(int interval, int layoutResId) {
super(null, null);
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class CpuUsageModule extends OverlayModule<CpuUsage> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public CpuUsageModule() {
super(null, null);
}
public CpuUsageModule(int interval) {
super(null, null);
}
public CpuUsageModule(int interval, int layoutResId) {
super(null, null);
}
| public CpuUsageModule(ViewModule<CpuUsage> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
import java.util.List; | package com.ms_square.debugoverlay.modules;
public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
public static final int DEFAULT_INTERVAL = 2000; // 2000ms
public CpuFreqModule() {
super(null, null);
}
public CpuFreqModule(int interval) {
super(null, null);
}
public CpuFreqModule(int interval, int layoutResId) {
super(null, null);
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
import java.util.List;
package com.ms_square.debugoverlay.modules;
public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
public static final int DEFAULT_INTERVAL = 2000; // 2000ms
public CpuFreqModule() {
super(null, null);
}
public CpuFreqModule(int interval) {
super(null, null);
}
public CpuFreqModule(int interval, int layoutResId) {
super(null, null);
}
| public CpuFreqModule(ViewModule<List<CpuFreq>> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class FpsModule extends OverlayModule<Double> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public FpsModule() {
super(null, null);
}
public FpsModule(int interval) {
super(null, null);
}
public FpsModule(int interval, int layoutResId) {
super(null, null);
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class FpsModule extends OverlayModule<Double> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public FpsModule() {
super(null, null);
}
public FpsModule(int interval) {
super(null, null);
}
public FpsModule(int interval, int layoutResId) {
super(null, null);
}
| public FpsModule(ViewModule<Double> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/LogcatModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class LogcatModule extends OverlayModule<LogcatLine> {
public static final int DEFAULT_MAX_LINES = 15;
public LogcatModule() {
super(null, null);
}
public LogcatModule(int maxLines) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineFilter lineFilter) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineColorScheme colorScheme) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineFilter lineFilter, LogcatLineColorScheme colorScheme) {
super(null, null);
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay-no-op/src/main/java/com/ms_square/debugoverlay/modules/LogcatModule.java
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class LogcatModule extends OverlayModule<LogcatLine> {
public static final int DEFAULT_MAX_LINES = 15;
public LogcatModule() {
super(null, null);
}
public LogcatModule(int maxLines) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineFilter lineFilter) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineColorScheme colorScheme) {
super(null, null);
}
public LogcatModule(int maxLines, LogcatLineFilter lineFilter, LogcatLineColorScheme colorScheme) {
super(null, null);
}
| public LogcatModule(ViewModule<LogcatLine> viewModule) { |
Manabu-GT/DebugOverlay-Android | sample/src/androidTest/java/com/ms_square/debugoverlay/AppLayerInstrumentedTest.java | // Path: sample/src/main/java/com/ms_square/debugoverlay/sample/MainActivity.java
// public class MainActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Timber.d("fab clicked");
// startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
// }
// });
//
// Timber.d("onCreate() called");
// }
//
// @Override
// public void onResume() {
// super.onResume();
// Timber.d("onResume() called");
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.menu_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
| import android.support.test.filters.LargeTest;
import android.support.test.filters.SdkSuppress;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ms_square.debugoverlay.sample.MainActivity;
import org.junit.Rule;
import org.junit.runner.RunWith; | package com.ms_square.debugoverlay;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
@LargeTest
public class AppLayerInstrumentedTest extends DebugOverlayInstrumentedTest {
@Rule | // Path: sample/src/main/java/com/ms_square/debugoverlay/sample/MainActivity.java
// public class MainActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//
// FloatingActionButton fab = findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Timber.d("fab clicked");
// startActivity(new Intent(MainActivity.this, ScrollingActivity.class));
// }
// });
//
// Timber.d("onCreate() called");
// }
//
// @Override
// public void onResume() {
// super.onResume();
// Timber.d("onResume() called");
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.menu_main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// }
// Path: sample/src/androidTest/java/com/ms_square/debugoverlay/AppLayerInstrumentedTest.java
import android.support.test.filters.LargeTest;
import android.support.test.filters.SdkSuppress;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.ms_square.debugoverlay.sample.MainActivity;
import org.junit.Rule;
import org.junit.runner.RunWith;
package com.ms_square.debugoverlay;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@SdkSuppress(minSdkVersion = 18)
@LargeTest
public class AppLayerInstrumentedTest extends DebugOverlayInstrumentedTest {
@Rule | public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class, |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
import java.util.List; | package com.ms_square.debugoverlay.modules;
/**
* @deprecated will not work on Android O and above.
* @see <a href="https://issuetracker.google.com/issues/37140047">this issue</a> for its background.
*/
@Deprecated
public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
public static final int DEFAULT_INTERVAL = 2000; // 2000ms
public CpuFreqModule() {
super(new CpuFreqDataModule(DEFAULT_INTERVAL), new CpuFreqViewModule());
}
public CpuFreqModule(int interval) {
super(new CpuFreqDataModule(interval), new CpuFreqViewModule());
}
public CpuFreqModule(int interval, @LayoutRes int layoutResId) {
super(new CpuFreqDataModule(interval), new CpuFreqViewModule(layoutResId));
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/CpuFreqModule.java
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
import java.util.List;
package com.ms_square.debugoverlay.modules;
/**
* @deprecated will not work on Android O and above.
* @see <a href="https://issuetracker.google.com/issues/37140047">this issue</a> for its background.
*/
@Deprecated
public class CpuFreqModule extends OverlayModule<List<CpuFreq>> {
public static final int DEFAULT_INTERVAL = 2000; // 2000ms
public CpuFreqModule() {
super(new CpuFreqDataModule(DEFAULT_INTERVAL), new CpuFreqViewModule());
}
public CpuFreqModule(int interval) {
super(new CpuFreqDataModule(interval), new CpuFreqViewModule());
}
public CpuFreqModule(int interval, @LayoutRes int layoutResId) {
super(new CpuFreqDataModule(interval), new CpuFreqViewModule(layoutResId));
}
| public CpuFreqModule(@NonNull ViewModule<List<CpuFreq>> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/LogcatModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.support.annotation.NonNull;
import android.support.annotation.Size;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class LogcatModule extends OverlayModule<LogcatLine> {
public static final int DEFAULT_MAX_LINES = 15;
public LogcatModule() {
super(new LogcatDataModule(), new LogcatViewModule(DEFAULT_MAX_LINES));
}
public LogcatModule(@Size(min=1,max=100) int maxLines) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineFilter lineFilter) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, lineFilter));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineColorScheme colorScheme) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, colorScheme));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineFilter lineFilter,
@NonNull LogcatLineColorScheme colorScheme) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, lineFilter, colorScheme));
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/LogcatModule.java
import android.support.annotation.NonNull;
import android.support.annotation.Size;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class LogcatModule extends OverlayModule<LogcatLine> {
public static final int DEFAULT_MAX_LINES = 15;
public LogcatModule() {
super(new LogcatDataModule(), new LogcatViewModule(DEFAULT_MAX_LINES));
}
public LogcatModule(@Size(min=1,max=100) int maxLines) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineFilter lineFilter) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, lineFilter));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineColorScheme colorScheme) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, colorScheme));
}
public LogcatModule(@Size(min=1,max=100) int maxLines, @NonNull LogcatLineFilter lineFilter,
@NonNull LogcatLineColorScheme colorScheme) {
super(new LogcatDataModule(), new LogcatViewModule(maxLines, lineFilter, colorScheme));
}
| public LogcatModule(@NonNull ViewModule<LogcatLine> viewModule) { |
Manabu-GT/DebugOverlay-Android | sample/src/main/java/com/ms_square/debugoverlay/sample/IPAddressModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/SimpleViewModule.java
// public class SimpleViewModule extends BaseViewModule<String> {
//
// private TextView textView;
//
// public SimpleViewModule(@LayoutRes int layoutResId) {
// super(layoutResId);
// }
//
// @Override
// public void onDataAvailable(String data) {
// if (textView != null) {
// textView.setText(data);
// }
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// View view = LayoutInflater.from(root.getContext()).inflate(layoutResId, root, false);
// textView = view.findViewById(R.id.debugoverlay_overlay_text);
// textView.setTextColor(textColor);
// textView.setTextSize(textSize);
// textView.setAlpha(textAlpha);
// return view;
// }
// }
| import android.content.Context;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.modules.SimpleViewModule; | package com.ms_square.debugoverlay.sample;
public class IPAddressModule extends OverlayModule<String> {
public IPAddressModule(@NonNull Context context) { | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/SimpleViewModule.java
// public class SimpleViewModule extends BaseViewModule<String> {
//
// private TextView textView;
//
// public SimpleViewModule(@LayoutRes int layoutResId) {
// super(layoutResId);
// }
//
// @Override
// public void onDataAvailable(String data) {
// if (textView != null) {
// textView.setText(data);
// }
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// View view = LayoutInflater.from(root.getContext()).inflate(layoutResId, root, false);
// textView = view.findViewById(R.id.debugoverlay_overlay_text);
// textView.setTextColor(textColor);
// textView.setTextSize(textSize);
// textView.setAlpha(textAlpha);
// return view;
// }
// }
// Path: sample/src/main/java/com/ms_square/debugoverlay/sample/IPAddressModule.java
import android.content.Context;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.modules.SimpleViewModule;
package com.ms_square.debugoverlay.sample;
public class IPAddressModule extends OverlayModule<String> {
public IPAddressModule(@NonNull Context context) { | super(new IPAddressDataModule(context), new SimpleViewModule(R.layout.view_overlay_ip)); |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
public class FpsModule extends OverlayModule<Double> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public FpsModule() {
super(new FpsDataModule(DEFAULT_INTERVAL), new FpsViewModule());
}
public FpsModule(int interval) {
super(new FpsDataModule(interval), new FpsViewModule());
}
public FpsModule(int interval, @LayoutRes int layoutResId) {
super(new FpsDataModule(interval), new FpsViewModule(layoutResId));
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/FpsModule.java
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
public class FpsModule extends OverlayModule<Double> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public FpsModule() {
super(new FpsDataModule(DEFAULT_INTERVAL), new FpsViewModule());
}
public FpsModule(int interval) {
super(new FpsDataModule(interval), new FpsViewModule());
}
public FpsModule(int interval, @LayoutRes int layoutResId) {
super(new FpsDataModule(interval), new FpsViewModule(layoutResId));
}
| public FpsModule(@NonNull ViewModule<Double> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
| import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule; | package com.ms_square.debugoverlay.modules;
/**
* @deprecated will not work on Android O and above.
* For details, @see <a href="https://issuetracker.google.com/issues/37140047">this issue</a>
*/
@Deprecated
public class CpuUsageModule extends OverlayModule<CpuUsage> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public CpuUsageModule() {
super(new CpuUsageDataModule(DEFAULT_INTERVAL), new CpuUsageViewModule());
}
public CpuUsageModule(int interval) {
super(new CpuUsageDataModule(interval), new CpuUsageViewModule());
}
public CpuUsageModule(int interval, @LayoutRes int layoutResId) {
super(new CpuUsageDataModule(interval), new CpuUsageViewModule(layoutResId));
}
| // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/ViewModule.java
// public interface ViewModule<T> extends DataObserver<T> {
//
// /**
// * Given the root (overlay's view container), create an overlay view to add
// * either programmatically or using LayoutInflater.
// * You are also given the preferred textColor, textSize, and textAlpha for your overlay view.
// * Please respect those passed values unless you have good reason not to do so.
// *
// * Note:
// * {@link DataObserver}'s onDataAvailable could be called before this method if systemLayer is
// * not allowed to use. So, it's safe to do null checks within onDataAvailable()
// * for any view variable references you keep as a result of this method.
// *
// * @param root
// * @param textColor
// * @param textSize - in sp
// * @param textAlpha
// * @return View to be added to the overlay container.
// */
// @NonNull
// View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha);
// }
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/CpuUsageModule.java
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.ViewModule;
package com.ms_square.debugoverlay.modules;
/**
* @deprecated will not work on Android O and above.
* For details, @see <a href="https://issuetracker.google.com/issues/37140047">this issue</a>
*/
@Deprecated
public class CpuUsageModule extends OverlayModule<CpuUsage> {
public static final int DEFAULT_INTERVAL = 1000; // 1000ms
public CpuUsageModule() {
super(new CpuUsageDataModule(DEFAULT_INTERVAL), new CpuUsageViewModule());
}
public CpuUsageModule(int interval) {
super(new CpuUsageDataModule(interval), new CpuUsageViewModule());
}
public CpuUsageModule(int interval, @LayoutRes int layoutResId) {
super(new CpuUsageDataModule(interval), new CpuUsageViewModule(layoutResId));
}
| public CpuUsageModule(@NonNull ViewModule<CpuUsage> viewModule) { |
Manabu-GT/DebugOverlay-Android | debugoverlay-ext-netstats/src/main/java/com/ms_square/debugoverlay_ext_netstats/NetStatsModule.java | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/SimpleViewModule.java
// public class SimpleViewModule extends BaseViewModule<String> {
//
// private TextView textView;
//
// public SimpleViewModule(@LayoutRes int layoutResId) {
// super(layoutResId);
// }
//
// @Override
// public void onDataAvailable(String data) {
// if (textView != null) {
// textView.setText(data);
// }
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// View view = LayoutInflater.from(root.getContext()).inflate(layoutResId, root, false);
// textView = view.findViewById(R.id.debugoverlay_overlay_text);
// textView.setTextColor(textColor);
// textView.setTextSize(textSize);
// textView.setAlpha(textAlpha);
// return view;
// }
// }
| import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.modules.SimpleViewModule; | package com.ms_square.debugoverlay_ext_netstats;
public class NetStatsModule extends OverlayModule<String> {
private static final int DEFAULT_INTERVAL = 1000; // ms
public NetStatsModule() {
this(DEFAULT_INTERVAL);
}
public NetStatsModule(int interval) { | // Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/OverlayModule.java
// public abstract class OverlayModule<T> implements DataModule<T>, ViewModule<T> {
//
// private final DataModule<T> dataModule;
//
// private final ViewModule<T> viewModule;
//
// public OverlayModule(DataModule<T> dataModule, ViewModule<T> viewModule) {
// this.dataModule = dataModule;
// this.viewModule = viewModule;
// }
//
// @Override
// public void start() {
// dataModule.addObserver(viewModule);
// dataModule.start();
// }
//
// @Override
// public void stop() {
// dataModule.removeObserver(viewModule);
// dataModule.stop();
// }
//
// @Override
// public void notifyObservers() {
// dataModule.notifyObservers();
// }
//
// @Override
// public void addObserver(@NonNull DataObserver observer) {
// dataModule.addObserver(observer);
// }
//
// @Override
// public void removeObserver(@NonNull DataObserver observer) {
// dataModule.removeObserver(observer);
// }
//
// @Override
// public void onDataAvailable(T data) {
// viewModule.onDataAvailable(data);
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// return viewModule.createView(root, textColor, textSize, textAlpha);
// }
// }
//
// Path: debugoverlay/src/main/java/com/ms_square/debugoverlay/modules/SimpleViewModule.java
// public class SimpleViewModule extends BaseViewModule<String> {
//
// private TextView textView;
//
// public SimpleViewModule(@LayoutRes int layoutResId) {
// super(layoutResId);
// }
//
// @Override
// public void onDataAvailable(String data) {
// if (textView != null) {
// textView.setText(data);
// }
// }
//
// @Override
// public View createView(@NonNull ViewGroup root, @ColorInt int textColor, float textSize, float textAlpha) {
// View view = LayoutInflater.from(root.getContext()).inflate(layoutResId, root, false);
// textView = view.findViewById(R.id.debugoverlay_overlay_text);
// textView.setTextColor(textColor);
// textView.setTextSize(textSize);
// textView.setAlpha(textAlpha);
// return view;
// }
// }
// Path: debugoverlay-ext-netstats/src/main/java/com/ms_square/debugoverlay_ext_netstats/NetStatsModule.java
import com.ms_square.debugoverlay.OverlayModule;
import com.ms_square.debugoverlay.modules.SimpleViewModule;
package com.ms_square.debugoverlay_ext_netstats;
public class NetStatsModule extends OverlayModule<String> {
private static final int DEFAULT_INTERVAL = 1000; // ms
public NetStatsModule() {
this(DEFAULT_INTERVAL);
}
public NetStatsModule(int interval) { | super(new NetStatsDataModule(interval), new SimpleViewModule(R.layout.debugoverlay_netstats)); |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.core/src/si/gos/transpiler/core/model/TranspileItem.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/InstalledTranspiler.java
// public class InstalledTranspiler {
//
// private String name;
// private String id;
// private String sourceExtension;
// private String destinationExtension;
// private String path;
// private String cmd;
// private String transpilerId;
//
// private ITranspiler transpiler;
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// buildId();
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the path
// */
// public String getPath() {
// return path;
// }
//
// /**
// * @param path the path to set
// */
// public void setPath(String path) {
// this.path = path;
// }
//
// /**
// * @return the cmd
// */
// public String getCmd() {
// return cmd;
// }
//
// /**
// * @param cmd the cmd to set
// */
// public void setCmd(String cmd) {
// this.cmd = cmd;
// }
//
// /**
// * @return the transpiler
// */
// public ITranspiler getTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setTranspiler(ITranspiler transpiler) {
// this.transpiler = transpiler;
// setTranspilerId(transpiler.getId());
// }
//
// /**
// * @return the transpilerId
// */
// public String getTranspilerId() {
// return transpilerId;
// }
//
// /**
// * @param transpilerId the transpilerId to set
// */
// public void setTranspilerId(String transpilerId) {
// this.transpilerId = transpilerId;
// buildId();
// }
//
// private void buildId() {
// if (transpiler != null) {
// if (transpiler.isGeneric()) {
// setId(transpilerId + "_" + name.toLowerCase());
// } else {
// setId(transpilerId);
// }
// }
// }
//
// /**
// * @return the extension
// */
// public String getSourceExtension() {
// return sourceExtension;
// }
//
// /**
// * @param extension the extension to set
// */
// public void setSourceExtension(String extension) {
// this.sourceExtension = extension;
// }
//
// /**
// * @return the destinationExtension
// */
// public String getDestinationExtension() {
// return destinationExtension;
// }
//
// /**
// * @param destinationExtension the destinationExtension to set
// */
// public void setDestinationExtension(String destinationExtension) {
// this.destinationExtension = destinationExtension;
// }
//
// public static InstalledTranspiler fromTranspiler(ITranspiler transpiler) {
// InstalledTranspiler itp = new InstalledTranspiler();
// itp.setCmd(transpiler.getCmd());
// itp.setSourceExtension(transpiler.getSourceExtension());
// itp.setDestinationExtension(transpiler.getDestinationExtension());
// itp.setName(transpiler.getName());
// itp.setTranspiler(transpiler);
//
// return itp;
// }
//
// }
| import org.eclipse.core.runtime.IPath;
import si.gos.transpiler.core.transpiler.InstalledTranspiler; | package si.gos.transpiler.core.model;
public class TranspileItem {
private PathEntry pathEntry; | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/InstalledTranspiler.java
// public class InstalledTranspiler {
//
// private String name;
// private String id;
// private String sourceExtension;
// private String destinationExtension;
// private String path;
// private String cmd;
// private String transpilerId;
//
// private ITranspiler transpiler;
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// buildId();
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the path
// */
// public String getPath() {
// return path;
// }
//
// /**
// * @param path the path to set
// */
// public void setPath(String path) {
// this.path = path;
// }
//
// /**
// * @return the cmd
// */
// public String getCmd() {
// return cmd;
// }
//
// /**
// * @param cmd the cmd to set
// */
// public void setCmd(String cmd) {
// this.cmd = cmd;
// }
//
// /**
// * @return the transpiler
// */
// public ITranspiler getTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setTranspiler(ITranspiler transpiler) {
// this.transpiler = transpiler;
// setTranspilerId(transpiler.getId());
// }
//
// /**
// * @return the transpilerId
// */
// public String getTranspilerId() {
// return transpilerId;
// }
//
// /**
// * @param transpilerId the transpilerId to set
// */
// public void setTranspilerId(String transpilerId) {
// this.transpilerId = transpilerId;
// buildId();
// }
//
// private void buildId() {
// if (transpiler != null) {
// if (transpiler.isGeneric()) {
// setId(transpilerId + "_" + name.toLowerCase());
// } else {
// setId(transpilerId);
// }
// }
// }
//
// /**
// * @return the extension
// */
// public String getSourceExtension() {
// return sourceExtension;
// }
//
// /**
// * @param extension the extension to set
// */
// public void setSourceExtension(String extension) {
// this.sourceExtension = extension;
// }
//
// /**
// * @return the destinationExtension
// */
// public String getDestinationExtension() {
// return destinationExtension;
// }
//
// /**
// * @param destinationExtension the destinationExtension to set
// */
// public void setDestinationExtension(String destinationExtension) {
// this.destinationExtension = destinationExtension;
// }
//
// public static InstalledTranspiler fromTranspiler(ITranspiler transpiler) {
// InstalledTranspiler itp = new InstalledTranspiler();
// itp.setCmd(transpiler.getCmd());
// itp.setSourceExtension(transpiler.getSourceExtension());
// itp.setDestinationExtension(transpiler.getDestinationExtension());
// itp.setName(transpiler.getName());
// itp.setTranspiler(transpiler);
//
// return itp;
// }
//
// }
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/TranspileItem.java
import org.eclipse.core.runtime.IPath;
import si.gos.transpiler.core.transpiler.InstalledTranspiler;
package si.gos.transpiler.core.model;
public class TranspileItem {
private PathEntry pathEntry; | private InstalledTranspiler itp; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/TranspilerController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspiler.java
// public interface ITranspiler {
//
// public String getName();
//
// public String getCmd();
//
// public String getId();
//
// public String getSourceExtension();
//
// public String getDestinationExtension();
//
// public boolean isGeneric();
//
// public Map<String, Option> getOptions();
//
// public Option getOption(String name);
//
// public CommandLine getCommand(String path, Map<String, String> options);
//
// public InstalledTranspiler autoDetect();
//
// public IPath getOutputOption(IPath from, IPath to);
// }
| import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.transpiler.ITranspiler; | package si.gos.transpiler.ui.controller;
public class TranspilerController extends LabelProvider implements
IStructuredContentProvider {
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspiler.java
// public interface ITranspiler {
//
// public String getName();
//
// public String getCmd();
//
// public String getId();
//
// public String getSourceExtension();
//
// public String getDestinationExtension();
//
// public boolean isGeneric();
//
// public Map<String, Option> getOptions();
//
// public Option getOption(String name);
//
// public CommandLine getCommand(String path, Map<String, String> options);
//
// public InstalledTranspiler autoDetect();
//
// public IPath getOutputOption(IPath from, IPath to);
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/TranspilerController.java
import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.transpiler.ITranspiler;
package si.gos.transpiler.ui.controller;
public class TranspilerController extends LabelProvider implements
IStructuredContentProvider {
| protected Map<String, ITranspiler> transpilers; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/builder/TranspilerBuilder.java
// public class TranspilerBuilder extends IncrementalProjectBuilder {
//
// public static final String ID = "si.gos.transpiler.builder.TranspilerBuilder";
//
// private Map<String, TranspileItem> cache;
//
// public TranspilerBuilder() {
// cache = new HashMap<String, TranspileItem>();
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
// * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
// */
// protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor)
// throws CoreException {
//
// IProject project = getProject();
//
// if (project.hasNature(TranspilerNature.NATURE_ID) == false) {
// return null;
// }
//
// Launcher launcher = new Launcher(project);
// launcher.addResponseListener(new ConsoleResponseHandler());
//
// IResourceDelta delta = getDelta(project);
//
// if (delta != null) {
// ResourceLocator locator = new ResourceLocator(project);
// searchAndTranspile(delta.getAffectedChildren(), locator, launcher);
//
// // refresh workspace
// project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
// }
//
// return null;
// }
//
// private void searchAndTranspile(IResourceDelta[] affectedChildren, ResourceLocator locator, Launcher launcher) {
// for (IResourceDelta affected : affectedChildren) {
// IPath path = affected.getProjectRelativePath();
//
// if (affected.getResource() instanceof IFile) {
// TranspileItem transpileItem = null;
// // TODO: Cache, see: https://stackoverflow.com/questions/22886012/get-the-instance-for-an-eclipse-builder
// // String cacheKey = path.toString();
// // if (cache.containsKey(cacheKey)) {
// // transpileItem = cache.get(cacheKey);
// // } else {
// transpileItem = locator.getTranspileItem(path);
// // cache.put(cacheKey, transpileItem);
// // }
//
// if (transpileItem != null) {
// transpile(transpileItem, launcher);
// }
// }
//
// searchAndTranspile(affected.getAffectedChildren(), locator, launcher);
// }
// }
//
// private void transpile(TranspileItem transpileItem, Launcher launcher) {
// ConfiguredTranspiler ct = transpileItem.getConfiguredTranspiler();
// InstalledTranspiler itp = transpileItem.getInstalledTranspiler();
//
// String source = transpileItem.getSource().toOSString();
// String dest = transpileItem.getDestination().toOSString();
// String path = itp.getPath().toString();
//
// Map<String, String> subs = new HashMap<String, String>();
// subs.put("source", source);
// subs.put("destination", dest);
//
// CommandLine cmd = itp.getTranspiler().getCommand(path, ct.getOptions());
// cmd.setSubstitutionMap(subs);
//
// // System.out.println("Transpiler: " + ct.getInstalledTranspiler().getTranspiler().getName());
// // System.out.println("From: " + source + ", To: " + dest);
// // System.out.println("Cmd: " + cmd);
//
// try {
// launcher.launch(cmd);
// } catch (ExecuteException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// public void updateCache(ResourceLocator locator) {
// IProject project = locator.getProject();
// for (String cacheKey : cache.keySet()) {
// IPath path = project.findMember(cacheKey).getProjectRelativePath();
//
// TranspileItem item = locator.getTranspileItem(path);
// if (item == null) {
// cache.remove(cacheKey);
// }
// }
// }
//
// }
| import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import si.gos.transpiler.core.builder.TranspilerBuilder; | package si.gos.transpiler.core;
public class TranspilerNature implements IProjectNature {
/**
* ID of this project nature
*/
public static final String NATURE_ID = "si.gos.transpiler.nature";
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) { | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/builder/TranspilerBuilder.java
// public class TranspilerBuilder extends IncrementalProjectBuilder {
//
// public static final String ID = "si.gos.transpiler.builder.TranspilerBuilder";
//
// private Map<String, TranspileItem> cache;
//
// public TranspilerBuilder() {
// cache = new HashMap<String, TranspileItem>();
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
// * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
// */
// protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor)
// throws CoreException {
//
// IProject project = getProject();
//
// if (project.hasNature(TranspilerNature.NATURE_ID) == false) {
// return null;
// }
//
// Launcher launcher = new Launcher(project);
// launcher.addResponseListener(new ConsoleResponseHandler());
//
// IResourceDelta delta = getDelta(project);
//
// if (delta != null) {
// ResourceLocator locator = new ResourceLocator(project);
// searchAndTranspile(delta.getAffectedChildren(), locator, launcher);
//
// // refresh workspace
// project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
// }
//
// return null;
// }
//
// private void searchAndTranspile(IResourceDelta[] affectedChildren, ResourceLocator locator, Launcher launcher) {
// for (IResourceDelta affected : affectedChildren) {
// IPath path = affected.getProjectRelativePath();
//
// if (affected.getResource() instanceof IFile) {
// TranspileItem transpileItem = null;
// // TODO: Cache, see: https://stackoverflow.com/questions/22886012/get-the-instance-for-an-eclipse-builder
// // String cacheKey = path.toString();
// // if (cache.containsKey(cacheKey)) {
// // transpileItem = cache.get(cacheKey);
// // } else {
// transpileItem = locator.getTranspileItem(path);
// // cache.put(cacheKey, transpileItem);
// // }
//
// if (transpileItem != null) {
// transpile(transpileItem, launcher);
// }
// }
//
// searchAndTranspile(affected.getAffectedChildren(), locator, launcher);
// }
// }
//
// private void transpile(TranspileItem transpileItem, Launcher launcher) {
// ConfiguredTranspiler ct = transpileItem.getConfiguredTranspiler();
// InstalledTranspiler itp = transpileItem.getInstalledTranspiler();
//
// String source = transpileItem.getSource().toOSString();
// String dest = transpileItem.getDestination().toOSString();
// String path = itp.getPath().toString();
//
// Map<String, String> subs = new HashMap<String, String>();
// subs.put("source", source);
// subs.put("destination", dest);
//
// CommandLine cmd = itp.getTranspiler().getCommand(path, ct.getOptions());
// cmd.setSubstitutionMap(subs);
//
// // System.out.println("Transpiler: " + ct.getInstalledTranspiler().getTranspiler().getName());
// // System.out.println("From: " + source + ", To: " + dest);
// // System.out.println("Cmd: " + cmd);
//
// try {
// launcher.launch(cmd);
// } catch (ExecuteException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
//
// public void updateCache(ResourceLocator locator) {
// IProject project = locator.getProject();
// for (String cacheKey : cache.keySet()) {
// IPath path = project.findMember(cacheKey).getProjectRelativePath();
//
// TranspileItem item = locator.getTranspileItem(path);
// if (item == null) {
// cache.remove(cacheKey);
// }
// }
// }
//
// }
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import si.gos.transpiler.core.builder.TranspilerBuilder;
package si.gos.transpiler.core;
public class TranspilerNature implements IProjectNature {
/**
* ID of this project nature
*/
public static final String NATURE_ID = "si.gos.transpiler.nature";
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) { | if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) { |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/handler/RemoveTranspilerNatureHandler.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java
// public class TranspilerNature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "si.gos.transpiler.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(TranspilerBuilder.ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
| import java.util.Iterator;
import org.eclipse.core.commands.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import si.gos.transpiler.core.TranspilerNature; | package si.gos.transpiler.ui.handler;
public class RemoveTranspilerNatureHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it
.hasNext();) {
Object element = it.next();
IProject project = null;
if (element instanceof IProject) {
project = (IProject) element;
} else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element)
.getAdapter(IProject.class);
}
if (project != null) {
try {
removeTranspilerNature(project);
} catch (CoreException e) {
throw new ExecutionException("Failed to toggle nature", e);
}
}
}
}
return null;
}
/**
* Toggles sample nature on a project
*
* @param project
* to have sample nature added or removed
*/
private void removeTranspilerNature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) { | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java
// public class TranspilerNature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "si.gos.transpiler.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(TranspilerBuilder.ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/handler/RemoveTranspilerNatureHandler.java
import java.util.Iterator;
import org.eclipse.core.commands.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import si.gos.transpiler.core.TranspilerNature;
package si.gos.transpiler.ui.handler;
public class RemoveTranspilerNatureHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it
.hasNext();) {
Object element = it.next();
IProject project = null;
if (element instanceof IProject) {
project = (IProject) element;
} else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element)
.getAdapter(IProject.class);
}
if (project != null) {
try {
removeTranspilerNature(project);
} catch (CoreException e) {
throw new ExecutionException("Failed to toggle nature", e);
}
}
}
}
return null;
}
/**
* Toggles sample nature on a project
*
* @param project
* to have sample nature added or removed
*/
private void removeTranspilerNature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) { | if (TranspilerNature.NATURE_ID.equals(natures[i])) { |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/dialogs/PathDialog.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/internal/filter/TypedViewerFilter.java
// @SuppressWarnings("rawtypes")
// public class TypedViewerFilter extends ViewerFilter {
//
// private Class<?>[] fAcceptedTypes;
// private Object[] fRejectedElements;
//
// /**
// * Creates a filter that only allows elements of gives types.
// * @param acceptedTypes The types of accepted elements
// */
// public TypedViewerFilter(Class[] acceptedTypes) {
// this(acceptedTypes, null);
// }
//
// /**
// * Creates a filter that only allows elements of gives types, but not from a
// * list of rejected elements.
// * @param acceptedTypes Accepted elements must be of this types
// * @param rejectedElements Element equals to the rejected elements are
// * filtered out
// */
// public TypedViewerFilter(Class[] acceptedTypes, Object[] rejectedElements) {
// Assert.isNotNull(acceptedTypes);
// fAcceptedTypes= acceptedTypes;
// fRejectedElements= rejectedElements;
// }
//
// /**
// * @see ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
// */
// @Override
// public boolean select(Viewer viewer, Object parentElement, Object element) {
// if (fRejectedElements != null) {
// for (int i= 0; i < fRejectedElements.length; i++) {
// if (element.equals(fRejectedElements[i])) {
// return false;
// }
// }
// }
// for (int i= 0; i < fAcceptedTypes.length; i++) {
// if (fAcceptedTypes[i].isInstance(element)) {
// return true;
// }
// }
// return false;
// }
//
// }
| import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import si.gos.eclipse.dialogs.ResourceFileSelectionDialog;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
import si.gos.transpiler.ui.internal.filter.TypedViewerFilter; | package si.gos.transpiler.ui.dialogs;
public class PathDialog extends Dialog {
private Text source;
private Text destFile;
private Text destFolder;
private Composite destRow;
private Composite root;
private IProject project; | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/internal/filter/TypedViewerFilter.java
// @SuppressWarnings("rawtypes")
// public class TypedViewerFilter extends ViewerFilter {
//
// private Class<?>[] fAcceptedTypes;
// private Object[] fRejectedElements;
//
// /**
// * Creates a filter that only allows elements of gives types.
// * @param acceptedTypes The types of accepted elements
// */
// public TypedViewerFilter(Class[] acceptedTypes) {
// this(acceptedTypes, null);
// }
//
// /**
// * Creates a filter that only allows elements of gives types, but not from a
// * list of rejected elements.
// * @param acceptedTypes Accepted elements must be of this types
// * @param rejectedElements Element equals to the rejected elements are
// * filtered out
// */
// public TypedViewerFilter(Class[] acceptedTypes, Object[] rejectedElements) {
// Assert.isNotNull(acceptedTypes);
// fAcceptedTypes= acceptedTypes;
// fRejectedElements= rejectedElements;
// }
//
// /**
// * @see ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
// */
// @Override
// public boolean select(Viewer viewer, Object parentElement, Object element) {
// if (fRejectedElements != null) {
// for (int i= 0; i < fRejectedElements.length; i++) {
// if (element.equals(fRejectedElements[i])) {
// return false;
// }
// }
// }
// for (int i= 0; i < fAcceptedTypes.length; i++) {
// if (fAcceptedTypes[i].isInstance(element)) {
// return true;
// }
// }
// return false;
// }
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/dialogs/PathDialog.java
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import si.gos.eclipse.dialogs.ResourceFileSelectionDialog;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
import si.gos.transpiler.ui.internal.filter.TypedViewerFilter;
package si.gos.transpiler.ui.dialogs;
public class PathDialog extends Dialog {
private Text source;
private Text destFile;
private Text destFolder;
private Composite destRow;
private Composite root;
private IProject project; | private PathEntry entry; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/dialogs/PathDialog.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/internal/filter/TypedViewerFilter.java
// @SuppressWarnings("rawtypes")
// public class TypedViewerFilter extends ViewerFilter {
//
// private Class<?>[] fAcceptedTypes;
// private Object[] fRejectedElements;
//
// /**
// * Creates a filter that only allows elements of gives types.
// * @param acceptedTypes The types of accepted elements
// */
// public TypedViewerFilter(Class[] acceptedTypes) {
// this(acceptedTypes, null);
// }
//
// /**
// * Creates a filter that only allows elements of gives types, but not from a
// * list of rejected elements.
// * @param acceptedTypes Accepted elements must be of this types
// * @param rejectedElements Element equals to the rejected elements are
// * filtered out
// */
// public TypedViewerFilter(Class[] acceptedTypes, Object[] rejectedElements) {
// Assert.isNotNull(acceptedTypes);
// fAcceptedTypes= acceptedTypes;
// fRejectedElements= rejectedElements;
// }
//
// /**
// * @see ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
// */
// @Override
// public boolean select(Viewer viewer, Object parentElement, Object element) {
// if (fRejectedElements != null) {
// for (int i= 0; i < fRejectedElements.length; i++) {
// if (element.equals(fRejectedElements[i])) {
// return false;
// }
// }
// }
// for (int i= 0; i < fAcceptedTypes.length; i++) {
// if (fAcceptedTypes[i].isInstance(element)) {
// return true;
// }
// }
// return false;
// }
//
// }
| import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import si.gos.eclipse.dialogs.ResourceFileSelectionDialog;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
import si.gos.transpiler.ui.internal.filter.TypedViewerFilter; | package si.gos.transpiler.ui.dialogs;
public class PathDialog extends Dialog {
private Text source;
private Text destFile;
private Text destFolder;
private Composite destRow;
private Composite root;
private IProject project;
private PathEntry entry;
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/internal/filter/TypedViewerFilter.java
// @SuppressWarnings("rawtypes")
// public class TypedViewerFilter extends ViewerFilter {
//
// private Class<?>[] fAcceptedTypes;
// private Object[] fRejectedElements;
//
// /**
// * Creates a filter that only allows elements of gives types.
// * @param acceptedTypes The types of accepted elements
// */
// public TypedViewerFilter(Class[] acceptedTypes) {
// this(acceptedTypes, null);
// }
//
// /**
// * Creates a filter that only allows elements of gives types, but not from a
// * list of rejected elements.
// * @param acceptedTypes Accepted elements must be of this types
// * @param rejectedElements Element equals to the rejected elements are
// * filtered out
// */
// public TypedViewerFilter(Class[] acceptedTypes, Object[] rejectedElements) {
// Assert.isNotNull(acceptedTypes);
// fAcceptedTypes= acceptedTypes;
// fRejectedElements= rejectedElements;
// }
//
// /**
// * @see ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
// */
// @Override
// public boolean select(Viewer viewer, Object parentElement, Object element) {
// if (fRejectedElements != null) {
// for (int i= 0; i < fRejectedElements.length; i++) {
// if (element.equals(fRejectedElements[i])) {
// return false;
// }
// }
// }
// for (int i= 0; i < fAcceptedTypes.length; i++) {
// if (fAcceptedTypes[i].isInstance(element)) {
// return true;
// }
// }
// return false;
// }
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/dialogs/PathDialog.java
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import si.gos.eclipse.dialogs.ResourceFileSelectionDialog;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
import si.gos.transpiler.ui.internal.filter.TypedViewerFilter;
package si.gos.transpiler.ui.dialogs;
public class PathDialog extends Dialog {
private Text source;
private Text destFile;
private Text destFolder;
private Composite destRow;
private Composite root;
private IProject project;
private PathEntry entry;
| private Image file = TranspilerUIPluginImages.FILE.createImage(); |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/NonInstalledTranspilerController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerPlugin.java
// public class TranspilerPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "si.gos.transpiler.core"; //$NON-NLS-1$
//
// // The shared instance
// private static TranspilerPlugin plugin;
//
// private TranspilerManager transpilerManager;
//
// /**
// * The constructor
// */
// public TranspilerPlugin() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
//
// transpilerManager = new TranspilerManager();
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static TranspilerPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Returns an image descriptor for the image file at the given
// * plug-in relative path
// *
// * @param path the path
// * @return the image descriptor
// */
// public static ImageDescriptor getImageDescriptor(String path) {
// return imageDescriptorFromPlugin(PLUGIN_ID, path);
// }
//
// public ITranspilerManager getTranspilerManager() {
// return transpilerManager;
// }
//
// public IEclipsePreferences getProjectPreferences(IProject project) {
// ProjectScope ps = new ProjectScope(project);
// return ps.getNode(PLUGIN_ID);
// }
//
// public IEclipsePreferences getPreferences() {
// return InstanceScope.INSTANCE.getNode(PLUGIN_ID);
// }
//
// public IEclipsePreferences getPreferences(String path) {
// return InstanceScope.INSTANCE.getNode(PLUGIN_ID + "/" + path);
// }
// }
//
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspiler.java
// public interface ITranspiler {
//
// public String getName();
//
// public String getCmd();
//
// public String getId();
//
// public String getSourceExtension();
//
// public String getDestinationExtension();
//
// public boolean isGeneric();
//
// public Map<String, Option> getOptions();
//
// public Option getOption(String name);
//
// public CommandLine getCommand(String path, Map<String, String> options);
//
// public InstalledTranspiler autoDetect();
//
// public IPath getOutputOption(IPath from, IPath to);
// }
//
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspilerManager.java
// public interface ITranspilerManager {
//
// public Map<String, ITranspiler> getTranspilers();
//
// public ITranspiler getTranspiler(String id);
//
// public boolean isTranspilerInstalled(String id);
//
// public Map<String, InstalledTranspiler> getInstalledTranspilers();
//
// public InstalledTranspiler getInstalledTranspiler(String id);
//
// public void addInstalledTranspiler(InstalledTranspiler transpiler);
//
// public void removeInstalledTranspiler(InstalledTranspiler transpiler);
//
// public void saveInstalledTranspilers();
//
// public Map<String, ConfiguredTranspiler> getConfiguredTranspilers(IProject project);
//
// public void saveConfiguredTranspilers(IProject project, Map<String, ConfiguredTranspiler> configuredTranspilers);
//
// }
| import java.util.ArrayList;
import java.util.List;
import si.gos.transpiler.core.TranspilerPlugin;
import si.gos.transpiler.core.transpiler.ITranspiler;
import si.gos.transpiler.core.transpiler.ITranspilerManager; | package si.gos.transpiler.ui.controller;
public class NonInstalledTranspilerController extends TranspilerController {
private ITranspilerManager manager = TranspilerPlugin.getDefault().getTranspilerManager();
@Override
public Object[] getElements(Object inputElement) { | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerPlugin.java
// public class TranspilerPlugin extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "si.gos.transpiler.core"; //$NON-NLS-1$
//
// // The shared instance
// private static TranspilerPlugin plugin;
//
// private TranspilerManager transpilerManager;
//
// /**
// * The constructor
// */
// public TranspilerPlugin() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
//
// transpilerManager = new TranspilerManager();
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static TranspilerPlugin getDefault() {
// return plugin;
// }
//
// /**
// * Returns an image descriptor for the image file at the given
// * plug-in relative path
// *
// * @param path the path
// * @return the image descriptor
// */
// public static ImageDescriptor getImageDescriptor(String path) {
// return imageDescriptorFromPlugin(PLUGIN_ID, path);
// }
//
// public ITranspilerManager getTranspilerManager() {
// return transpilerManager;
// }
//
// public IEclipsePreferences getProjectPreferences(IProject project) {
// ProjectScope ps = new ProjectScope(project);
// return ps.getNode(PLUGIN_ID);
// }
//
// public IEclipsePreferences getPreferences() {
// return InstanceScope.INSTANCE.getNode(PLUGIN_ID);
// }
//
// public IEclipsePreferences getPreferences(String path) {
// return InstanceScope.INSTANCE.getNode(PLUGIN_ID + "/" + path);
// }
// }
//
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspiler.java
// public interface ITranspiler {
//
// public String getName();
//
// public String getCmd();
//
// public String getId();
//
// public String getSourceExtension();
//
// public String getDestinationExtension();
//
// public boolean isGeneric();
//
// public Map<String, Option> getOptions();
//
// public Option getOption(String name);
//
// public CommandLine getCommand(String path, Map<String, String> options);
//
// public InstalledTranspiler autoDetect();
//
// public IPath getOutputOption(IPath from, IPath to);
// }
//
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspilerManager.java
// public interface ITranspilerManager {
//
// public Map<String, ITranspiler> getTranspilers();
//
// public ITranspiler getTranspiler(String id);
//
// public boolean isTranspilerInstalled(String id);
//
// public Map<String, InstalledTranspiler> getInstalledTranspilers();
//
// public InstalledTranspiler getInstalledTranspiler(String id);
//
// public void addInstalledTranspiler(InstalledTranspiler transpiler);
//
// public void removeInstalledTranspiler(InstalledTranspiler transpiler);
//
// public void saveInstalledTranspilers();
//
// public Map<String, ConfiguredTranspiler> getConfiguredTranspilers(IProject project);
//
// public void saveConfiguredTranspilers(IProject project, Map<String, ConfiguredTranspiler> configuredTranspilers);
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/NonInstalledTranspilerController.java
import java.util.ArrayList;
import java.util.List;
import si.gos.transpiler.core.TranspilerPlugin;
import si.gos.transpiler.core.transpiler.ITranspiler;
import si.gos.transpiler.core.transpiler.ITranspilerManager;
package si.gos.transpiler.ui.controller;
public class NonInstalledTranspilerController extends TranspilerController {
private ITranspilerManager manager = TranspilerPlugin.getDefault().getTranspilerManager();
@Override
public Object[] getElements(Object inputElement) { | List<ITranspiler> selection = new ArrayList<ITranspiler>(); |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/InstalledTranspilerController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/InstalledTranspiler.java
// public class InstalledTranspiler {
//
// private String name;
// private String id;
// private String sourceExtension;
// private String destinationExtension;
// private String path;
// private String cmd;
// private String transpilerId;
//
// private ITranspiler transpiler;
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// buildId();
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the path
// */
// public String getPath() {
// return path;
// }
//
// /**
// * @param path the path to set
// */
// public void setPath(String path) {
// this.path = path;
// }
//
// /**
// * @return the cmd
// */
// public String getCmd() {
// return cmd;
// }
//
// /**
// * @param cmd the cmd to set
// */
// public void setCmd(String cmd) {
// this.cmd = cmd;
// }
//
// /**
// * @return the transpiler
// */
// public ITranspiler getTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setTranspiler(ITranspiler transpiler) {
// this.transpiler = transpiler;
// setTranspilerId(transpiler.getId());
// }
//
// /**
// * @return the transpilerId
// */
// public String getTranspilerId() {
// return transpilerId;
// }
//
// /**
// * @param transpilerId the transpilerId to set
// */
// public void setTranspilerId(String transpilerId) {
// this.transpilerId = transpilerId;
// buildId();
// }
//
// private void buildId() {
// if (transpiler != null) {
// if (transpiler.isGeneric()) {
// setId(transpilerId + "_" + name.toLowerCase());
// } else {
// setId(transpilerId);
// }
// }
// }
//
// /**
// * @return the extension
// */
// public String getSourceExtension() {
// return sourceExtension;
// }
//
// /**
// * @param extension the extension to set
// */
// public void setSourceExtension(String extension) {
// this.sourceExtension = extension;
// }
//
// /**
// * @return the destinationExtension
// */
// public String getDestinationExtension() {
// return destinationExtension;
// }
//
// /**
// * @param destinationExtension the destinationExtension to set
// */
// public void setDestinationExtension(String destinationExtension) {
// this.destinationExtension = destinationExtension;
// }
//
// public static InstalledTranspiler fromTranspiler(ITranspiler transpiler) {
// InstalledTranspiler itp = new InstalledTranspiler();
// itp.setCmd(transpiler.getCmd());
// itp.setSourceExtension(transpiler.getSourceExtension());
// itp.setDestinationExtension(transpiler.getDestinationExtension());
// itp.setName(transpiler.getName());
// itp.setTranspiler(transpiler);
//
// return itp;
// }
//
// }
| import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.transpiler.InstalledTranspiler; | package si.gos.transpiler.ui.controller;
public class InstalledTranspilerController extends LabelProvider implements
IStructuredContentProvider {
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/InstalledTranspiler.java
// public class InstalledTranspiler {
//
// private String name;
// private String id;
// private String sourceExtension;
// private String destinationExtension;
// private String path;
// private String cmd;
// private String transpilerId;
//
// private ITranspiler transpiler;
//
// /**
// * @return the name
// */
// public String getName() {
// return name;
// }
//
// /**
// * @param name the name to set
// */
// public void setName(String name) {
// this.name = name;
// buildId();
// }
//
// /**
// * @return the id
// */
// public String getId() {
// return id;
// }
//
// /**
// * @param id the id to set
// */
// public void setId(String id) {
// this.id = id;
// }
//
// /**
// * @return the path
// */
// public String getPath() {
// return path;
// }
//
// /**
// * @param path the path to set
// */
// public void setPath(String path) {
// this.path = path;
// }
//
// /**
// * @return the cmd
// */
// public String getCmd() {
// return cmd;
// }
//
// /**
// * @param cmd the cmd to set
// */
// public void setCmd(String cmd) {
// this.cmd = cmd;
// }
//
// /**
// * @return the transpiler
// */
// public ITranspiler getTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setTranspiler(ITranspiler transpiler) {
// this.transpiler = transpiler;
// setTranspilerId(transpiler.getId());
// }
//
// /**
// * @return the transpilerId
// */
// public String getTranspilerId() {
// return transpilerId;
// }
//
// /**
// * @param transpilerId the transpilerId to set
// */
// public void setTranspilerId(String transpilerId) {
// this.transpilerId = transpilerId;
// buildId();
// }
//
// private void buildId() {
// if (transpiler != null) {
// if (transpiler.isGeneric()) {
// setId(transpilerId + "_" + name.toLowerCase());
// } else {
// setId(transpilerId);
// }
// }
// }
//
// /**
// * @return the extension
// */
// public String getSourceExtension() {
// return sourceExtension;
// }
//
// /**
// * @param extension the extension to set
// */
// public void setSourceExtension(String extension) {
// this.sourceExtension = extension;
// }
//
// /**
// * @return the destinationExtension
// */
// public String getDestinationExtension() {
// return destinationExtension;
// }
//
// /**
// * @param destinationExtension the destinationExtension to set
// */
// public void setDestinationExtension(String destinationExtension) {
// this.destinationExtension = destinationExtension;
// }
//
// public static InstalledTranspiler fromTranspiler(ITranspiler transpiler) {
// InstalledTranspiler itp = new InstalledTranspiler();
// itp.setCmd(transpiler.getCmd());
// itp.setSourceExtension(transpiler.getSourceExtension());
// itp.setDestinationExtension(transpiler.getDestinationExtension());
// itp.setName(transpiler.getName());
// itp.setTranspiler(transpiler);
//
// return itp;
// }
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/InstalledTranspilerController.java
import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.transpiler.InstalledTranspiler;
package si.gos.transpiler.ui.controller;
public class InstalledTranspilerController extends LabelProvider implements
IStructuredContentProvider {
| private Map<String, InstalledTranspiler> transpilers; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/ConfiguredTranspilerController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/ConfiguredTranspiler.java
// public class ConfiguredTranspiler {
//
// private InstalledTranspiler transpiler;
// private List<PathEntry> paths = new ArrayList<PathEntry>();
// // private List<ConfiguredOption> options = new ArrayList<ConfiguredOption>();
// private Map<String, String> options = new HashMap<String, String>();
//
//
// /**
// * @return the transpiler
// */
// public InstalledTranspiler getInstalledTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setInstalledTranspiler(InstalledTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
// /**
// * Returns the id for this configured transpiler or null, if no
// * installed transpiler is set.
// *
// * @return id
// */
// public String getId() {
// if (transpiler != null) {
// return transpiler.getId();
// }
// return null;
// }
//
// public List<PathEntry> getPaths() {
// return paths;
// }
//
// public void setPaths(List<PathEntry> paths) {
// this.paths = paths;
// }
//
// public void addPath(PathEntry path) {
// path.setConfiguredTranspiler(this);
// paths.add(path);
// }
//
// public void removePath(PathEntry path) {
// path.setConfiguredTranspiler(null);
// paths.remove(path);
// }
//
// public void setOption(String name) {
// setOption(name, "");
// }
//
// public void setOption(String name, String value) {
// options.put(name, value);
// }
//
// public boolean hasOption(String name) {
// return options.containsKey(name);
// }
//
// public void removeOption(String name) {
// options.remove(name);
// }
//
// public String getOption(String name) {
// return options.get(name);
// }
//
// public Map<String, String> getOptions() {
// return options;
// }
// }
| import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.model.ConfiguredTranspiler; | package si.gos.transpiler.ui.controller;
public class ConfiguredTranspilerController extends LabelProvider implements
IStructuredContentProvider {
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/ConfiguredTranspiler.java
// public class ConfiguredTranspiler {
//
// private InstalledTranspiler transpiler;
// private List<PathEntry> paths = new ArrayList<PathEntry>();
// // private List<ConfiguredOption> options = new ArrayList<ConfiguredOption>();
// private Map<String, String> options = new HashMap<String, String>();
//
//
// /**
// * @return the transpiler
// */
// public InstalledTranspiler getInstalledTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setInstalledTranspiler(InstalledTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
// /**
// * Returns the id for this configured transpiler or null, if no
// * installed transpiler is set.
// *
// * @return id
// */
// public String getId() {
// if (transpiler != null) {
// return transpiler.getId();
// }
// return null;
// }
//
// public List<PathEntry> getPaths() {
// return paths;
// }
//
// public void setPaths(List<PathEntry> paths) {
// this.paths = paths;
// }
//
// public void addPath(PathEntry path) {
// path.setConfiguredTranspiler(this);
// paths.add(path);
// }
//
// public void removePath(PathEntry path) {
// path.setConfiguredTranspiler(null);
// paths.remove(path);
// }
//
// public void setOption(String name) {
// setOption(name, "");
// }
//
// public void setOption(String name, String value) {
// options.put(name, value);
// }
//
// public boolean hasOption(String name) {
// return options.containsKey(name);
// }
//
// public void removeOption(String name) {
// options.remove(name);
// }
//
// public String getOption(String name) {
// return options.get(name);
// }
//
// public Map<String, String> getOptions() {
// return options;
// }
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/ConfiguredTranspilerController.java
import java.util.Map;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import si.gos.transpiler.core.model.ConfiguredTranspiler;
package si.gos.transpiler.ui.controller;
public class ConfiguredTranspilerController extends LabelProvider implements
IStructuredContentProvider {
| private Map<String, ConfiguredTranspiler> transpilers; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/PathEntryController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
| import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages; | package si.gos.transpiler.ui.controller;
public class PathEntryController extends LabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/PathEntryController.java
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
package si.gos.transpiler.ui.controller;
public class PathEntryController extends LabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
| protected List<PathEntry> paths; |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/PathEntryController.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
| import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages; | package si.gos.transpiler.ui.controller;
public class PathEntryController extends LabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
protected List<PathEntry> paths;
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/PathEntry.java
// public class PathEntry {
//
// private IResource source;
// private IResource destination;
// private ConfiguredTranspiler transpiler;
//
// public PathEntry() {
//
// }
//
// public PathEntry(IResource source, IResource destination) {
// this.source = source;
// this.destination = destination;
// }
//
// /**
// * @return the source
// */
// public IResource getSource() {
// return source;
// }
//
// /**
// * @param source the source to set
// */
// public void setSource(IResource source) {
// this.source = source;
// }
//
// /**
// * @return the destination
// */
// public IResource getDestination() {
// return destination;
// }
//
// /**
// * @param destination the destination to set
// */
// public void setDestination(IResource destination) {
// this.destination = destination;
// }
//
// /**
// * @return the transpiler
// */
// public ConfiguredTranspiler getConfiguredTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setConfiguredTranspiler(ConfiguredTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
//
// }
//
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/TranspilerUIPluginImages.java
// public class TranspilerUIPluginImages {
//
// public static ImageDescriptor FOLDER = ResourceManager.getPluginImageDescriptor("org.eclipse.ui.ide", "/icons/full/obj16/folder.gif");
// public static ImageDescriptor FILE = ResourceManager.getPluginImageDescriptor("org.eclipse.ui", "/icons/full/obj16/file_obj.gif");
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/controller/PathEntryController.java
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import si.gos.transpiler.core.model.PathEntry;
import si.gos.transpiler.ui.TranspilerUIPluginImages;
package si.gos.transpiler.ui.controller;
public class PathEntryController extends LabelProvider implements
IStructuredContentProvider, ITableLabelProvider {
protected List<PathEntry> paths;
| private Image file = TranspilerUIPluginImages.FILE.createImage(); |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspilerManager.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/ConfiguredTranspiler.java
// public class ConfiguredTranspiler {
//
// private InstalledTranspiler transpiler;
// private List<PathEntry> paths = new ArrayList<PathEntry>();
// // private List<ConfiguredOption> options = new ArrayList<ConfiguredOption>();
// private Map<String, String> options = new HashMap<String, String>();
//
//
// /**
// * @return the transpiler
// */
// public InstalledTranspiler getInstalledTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setInstalledTranspiler(InstalledTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
// /**
// * Returns the id for this configured transpiler or null, if no
// * installed transpiler is set.
// *
// * @return id
// */
// public String getId() {
// if (transpiler != null) {
// return transpiler.getId();
// }
// return null;
// }
//
// public List<PathEntry> getPaths() {
// return paths;
// }
//
// public void setPaths(List<PathEntry> paths) {
// this.paths = paths;
// }
//
// public void addPath(PathEntry path) {
// path.setConfiguredTranspiler(this);
// paths.add(path);
// }
//
// public void removePath(PathEntry path) {
// path.setConfiguredTranspiler(null);
// paths.remove(path);
// }
//
// public void setOption(String name) {
// setOption(name, "");
// }
//
// public void setOption(String name, String value) {
// options.put(name, value);
// }
//
// public boolean hasOption(String name) {
// return options.containsKey(name);
// }
//
// public void removeOption(String name) {
// options.remove(name);
// }
//
// public String getOption(String name) {
// return options.get(name);
// }
//
// public Map<String, String> getOptions() {
// return options;
// }
// }
| import java.util.Map;
import org.eclipse.core.resources.IProject;
import si.gos.transpiler.core.model.ConfiguredTranspiler; | package si.gos.transpiler.core.transpiler;
public interface ITranspilerManager {
public Map<String, ITranspiler> getTranspilers();
public ITranspiler getTranspiler(String id);
public boolean isTranspilerInstalled(String id);
public Map<String, InstalledTranspiler> getInstalledTranspilers();
public InstalledTranspiler getInstalledTranspiler(String id);
public void addInstalledTranspiler(InstalledTranspiler transpiler);
public void removeInstalledTranspiler(InstalledTranspiler transpiler);
public void saveInstalledTranspilers();
| // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/model/ConfiguredTranspiler.java
// public class ConfiguredTranspiler {
//
// private InstalledTranspiler transpiler;
// private List<PathEntry> paths = new ArrayList<PathEntry>();
// // private List<ConfiguredOption> options = new ArrayList<ConfiguredOption>();
// private Map<String, String> options = new HashMap<String, String>();
//
//
// /**
// * @return the transpiler
// */
// public InstalledTranspiler getInstalledTranspiler() {
// return transpiler;
// }
//
// /**
// * @param transpiler the transpiler to set
// */
// public void setInstalledTranspiler(InstalledTranspiler transpiler) {
// this.transpiler = transpiler;
// }
//
// /**
// * Returns the id for this configured transpiler or null, if no
// * installed transpiler is set.
// *
// * @return id
// */
// public String getId() {
// if (transpiler != null) {
// return transpiler.getId();
// }
// return null;
// }
//
// public List<PathEntry> getPaths() {
// return paths;
// }
//
// public void setPaths(List<PathEntry> paths) {
// this.paths = paths;
// }
//
// public void addPath(PathEntry path) {
// path.setConfiguredTranspiler(this);
// paths.add(path);
// }
//
// public void removePath(PathEntry path) {
// path.setConfiguredTranspiler(null);
// paths.remove(path);
// }
//
// public void setOption(String name) {
// setOption(name, "");
// }
//
// public void setOption(String name, String value) {
// options.put(name, value);
// }
//
// public boolean hasOption(String name) {
// return options.containsKey(name);
// }
//
// public void removeOption(String name) {
// options.remove(name);
// }
//
// public String getOption(String name) {
// return options.get(name);
// }
//
// public Map<String, String> getOptions() {
// return options;
// }
// }
// Path: si.gos.transpiler.core/src/si/gos/transpiler/core/transpiler/ITranspilerManager.java
import java.util.Map;
import org.eclipse.core.resources.IProject;
import si.gos.transpiler.core.model.ConfiguredTranspiler;
package si.gos.transpiler.core.transpiler;
public interface ITranspilerManager {
public Map<String, ITranspiler> getTranspilers();
public ITranspiler getTranspiler(String id);
public boolean isTranspilerInstalled(String id);
public Map<String, InstalledTranspiler> getInstalledTranspilers();
public InstalledTranspiler getInstalledTranspiler(String id);
public void addInstalledTranspiler(InstalledTranspiler transpiler);
public void removeInstalledTranspiler(InstalledTranspiler transpiler);
public void saveInstalledTranspilers();
| public Map<String, ConfiguredTranspiler> getConfiguredTranspilers(IProject project); |
gossi/eclipse-transpiler-plugin | si.gos.transpiler.ui/src/si/gos/transpiler/ui/handler/AddTranspilerNatureHandler.java | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java
// public class TranspilerNature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "si.gos.transpiler.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(TranspilerBuilder.ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
| import java.util.Iterator;
import org.eclipse.core.commands.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import si.gos.transpiler.core.TranspilerNature; | } else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element)
.getAdapter(IProject.class);
}
if (project != null) {
try {
addTranspilerNature(project);
} catch (CoreException e) {
throw new ExecutionException("Failed to toggle nature", e);
}
}
}
}
return null;
}
/**
* Adds transpiler nature on a project
*
* @param project
* to have transpiler nature added
*/
private void addTranspilerNature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
// Add the nature
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length); | // Path: si.gos.transpiler.core/src/si/gos/transpiler/core/TranspilerNature.java
// public class TranspilerNature implements IProjectNature {
//
// /**
// * ID of this project nature
// */
// public static final String NATURE_ID = "si.gos.transpiler.nature";
//
// private IProject project;
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#configure()
// */
// public void configure() throws CoreException {
// IProjectDescription desc = project.getDescription();
// ICommand[] commands = desc.getBuildSpec();
//
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// return;
// }
// }
//
// ICommand[] newCommands = new ICommand[commands.length + 1];
// System.arraycopy(commands, 0, newCommands, 0, commands.length);
// ICommand command = desc.newCommand();
// command.setBuilderName(TranspilerBuilder.ID);
// newCommands[newCommands.length - 1] = command;
// desc.setBuildSpec(newCommands);
// project.setDescription(desc, null);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#deconfigure()
// */
// public void deconfigure() throws CoreException {
// IProjectDescription description = getProject().getDescription();
// ICommand[] commands = description.getBuildSpec();
// for (int i = 0; i < commands.length; ++i) {
// if (commands[i].getBuilderName().equals(TranspilerBuilder.ID)) {
// ICommand[] newCommands = new ICommand[commands.length - 1];
// System.arraycopy(commands, 0, newCommands, 0, i);
// System.arraycopy(commands, i + 1, newCommands, i,
// commands.length - i - 1);
// description.setBuildSpec(newCommands);
// project.setDescription(description, null);
// return;
// }
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#getProject()
// */
// public IProject getProject() {
// return project;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
// */
// public void setProject(IProject project) {
// this.project = project;
// }
//
// }
// Path: si.gos.transpiler.ui/src/si/gos/transpiler/ui/handler/AddTranspilerNatureHandler.java
import java.util.Iterator;
import org.eclipse.core.commands.*;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import si.gos.transpiler.core.TranspilerNature;
} else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element)
.getAdapter(IProject.class);
}
if (project != null) {
try {
addTranspilerNature(project);
} catch (CoreException e) {
throw new ExecutionException("Failed to toggle nature", e);
}
}
}
}
return null;
}
/**
* Adds transpiler nature on a project
*
* @param project
* to have transpiler nature added
*/
private void addTranspilerNature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
// Add the nature
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length); | newNatures[natures.length] = TranspilerNature.NATURE_ID; |
attentiveness/News | app/src/main/java/org/attentiveness/news/list/StoryListFragment.java | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; | }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.mStoriesAdapter = new StoryListAdapter();
this.mStoriesAdapter.setOnItemClickListener(this);
Bundle bundle = getArguments();
if (bundle != null && bundle.containsKey(EXTRA_DATE)) {
this.mOriginalDate = bundle.getString(EXTRA_DATE);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_story_list, container, false);
ButterKnife.bind(this, rootView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
this.mStoriesView.setLayoutManager(linearLayoutManager);
this.mStoriesView.setAdapter(this.mStoriesAdapter);
this.mLoadingCount = 0;
this.mDate = this.mOriginalDate;
// LogUtil.e(mDate);
this.mLoadMoreListener = new LoadMoreListener(linearLayoutManager) {
@Override
void onLoadMore() {
mLoadingCount++; | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
// Path: app/src/main/java/org/attentiveness/news/list/StoryListFragment.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.mStoriesAdapter = new StoryListAdapter();
this.mStoriesAdapter.setOnItemClickListener(this);
Bundle bundle = getArguments();
if (bundle != null && bundle.containsKey(EXTRA_DATE)) {
this.mOriginalDate = bundle.getString(EXTRA_DATE);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_story_list, container, false);
ButterKnife.bind(this, rootView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
this.mStoriesView.setLayoutManager(linearLayoutManager);
this.mStoriesView.setAdapter(this.mStoriesAdapter);
this.mLoadingCount = 0;
this.mDate = this.mOriginalDate;
// LogUtil.e(mDate);
this.mLoadMoreListener = new LoadMoreListener(linearLayoutManager) {
@Override
void onLoadMore() {
mLoadingCount++; | mDate = DateUtil.getDate(mLoadingCount); |
attentiveness/News | app/src/main/java/org/attentiveness/news/list/StoryListFragment.java | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; | public void showRetry() {
this.mLoadingErrorView.setVisibility(View.VISIBLE);
}
@Override
public void hideRetry() {
this.mLoadingErrorView.setVisibility(View.GONE);
}
@Override
public void showError(String message) {
showMessage(this.mSwipeRefreshLayout, message);
}
@Override
public void setLoadingIndicator(final boolean active) {
if (!this.isActive() || getView() == null) {
return;
}
// Make sure setRefreshing() is called after the layout is done with everything else.
this.mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(active);
}
});
}
@Override | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
// Path: app/src/main/java/org/attentiveness/news/list/StoryListFragment.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public void showRetry() {
this.mLoadingErrorView.setVisibility(View.VISIBLE);
}
@Override
public void hideRetry() {
this.mLoadingErrorView.setVisibility(View.GONE);
}
@Override
public void showError(String message) {
showMessage(this.mSwipeRefreshLayout, message);
}
@Override
public void setLoadingIndicator(final boolean active) {
if (!this.isActive() || getView() == null) {
return;
}
// Make sure setRefreshing() is called after the layout is done with everything else.
this.mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(active);
}
});
}
@Override | public void showStoryList(List<Story> storyList) { |
attentiveness/News | app/src/main/java/org/attentiveness/news/list/StoryListFragment.java | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick; | mSwipeRefreshLayout.setRefreshing(active);
}
});
}
@Override
public void showStoryList(List<Story> storyList) {
this.mStoriesView.setVisibility(View.VISIBLE);
this.mStoriesAdapter.setItemList(storyList);
}
@Override
public void appendStoryList(List<Story> storyList) {
this.mStoriesView.setVisibility(View.VISIBLE);
this.mStoriesAdapter.addItemList(storyList);
}
@Override
public void hideStoryList() {
this.mStoriesView.setVisibility(View.GONE);
}
@Override
public boolean isActive() {
return isAdded();
}
@Override
public void onStoryClicked(Story story) {
if (story != null && story.getId() > 0) { | // Path: app/src/main/java/org/attentiveness/news/base/BaseFragment.java
// public class BaseFragment extends Fragment {
//
// public BaseFragment() {
// // Required empty public constructor
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/detail/StoryDetailActivity.java
// public class StoryDetailActivity extends BaseActivity {
//
// private static final String INSTANCE_STORY_ID = "story_id";
//
// private int mStoryId;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_detail);
// ButterKnife.bind(this);
// setup();
//
// if (savedInstanceState == null) {
// this.mStoryId = getIntent().getIntExtra(StoryListFragment.EXTRA_ID, 0);
// } else {
// this.mStoryId = savedInstanceState.getInt(INSTANCE_STORY_ID);
// }
//
// StoryDetailFragment storyDetailFragment = (StoryDetailFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (storyDetailFragment == null) {
// storyDetailFragment = StoryDetailFragment.newInstance();
// addFragment(getSupportFragmentManager(), R.id.fl_container, storyDetailFragment);
// }
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryDetailPresenter presenter = new StoryDetailPresenter(this.mStoryId, repository, storyDetailFragment);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// outState.putInt(INSTANCE_STORY_ID, this.mStoryId);
// }
// }
//
// Path: app/src/main/java/org/attentiveness/news/util/DateUtil.java
// public class DateUtil {
//
// public static String getToday() {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// public static String getDate(int before) {
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DAY_OF_YEAR, 1 - before);
// SimpleDateFormat simpleDateFormat = getDataFormat();
// return simpleDateFormat.format(calendar.getTime());
// }
//
// private static SimpleDateFormat getDataFormat() {
// return new SimpleDateFormat("yyyyMMdd", Locale.US);
// }
//
// }
// Path: app/src/main/java/org/attentiveness/news/list/StoryListFragment.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseFragment;
import org.attentiveness.news.data.Story;
import org.attentiveness.news.detail.StoryDetailActivity;
import org.attentiveness.news.util.DateUtil;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
mSwipeRefreshLayout.setRefreshing(active);
}
});
}
@Override
public void showStoryList(List<Story> storyList) {
this.mStoriesView.setVisibility(View.VISIBLE);
this.mStoriesAdapter.setItemList(storyList);
}
@Override
public void appendStoryList(List<Story> storyList) {
this.mStoriesView.setVisibility(View.VISIBLE);
this.mStoriesAdapter.addItemList(storyList);
}
@Override
public void hideStoryList() {
this.mStoriesView.setVisibility(View.GONE);
}
@Override
public boolean isActive() {
return isAdded();
}
@Override
public void onStoryClicked(Story story) {
if (story != null && story.getId() > 0) { | Intent intent = new Intent(this.getActivity(), StoryDetailActivity.class); |
attentiveness/News | app/src/main/java/org/attentiveness/news/splash/SplashActivity.java | // Path: app/src/main/java/org/attentiveness/news/base/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// @Nullable
// @BindView(R.id.toolbar)
// Toolbar mToolbar;
// @Nullable
// @BindView(R.id.drawer_layout)
// protected DrawerLayout mDrawerLayout;
// @Nullable
// @BindView(R.id.nav_view)
// NavigationView mNavigationView;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// }
//
// protected void setup() {
// setup(-1);
// }
//
// protected void setup(int barIconId) {
// setSupportActionBar(this.mToolbar);
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// if (barIconId > 0) {
// actionBar.setHomeAsUpIndicator(barIconId);
// }
// actionBar.setDisplayHomeAsUpEnabled(true);
// }
//
// if (this.mDrawerLayout != null) {
// this.mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
// }
// if (this.mNavigationView != null) {
// setupDrawerContent(this.mNavigationView);
// }
// }
//
// protected void setupDrawerContent(NavigationView navigationView) {
//
// }
//
// protected void addFragment(FragmentManager fragmentManager, int containerId, Fragment fragment) {
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
// fragmentTransaction.add(containerId, fragment);
// fragmentTransaction.commit();
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/list/StoryListActivity.java
// public class StoryListActivity extends BaseActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_list);
// ButterKnife.bind(this);
// setup(R.drawable.ic_menu);
//
// StoryListFragment newsListFragment = (StoryListFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (newsListFragment == null) {
// String today = DateUtil.getToday();
// newsListFragment = StoryListFragment.newInstance(today);
// addFragment(getSupportFragmentManager(), R.id.fl_container, newsListFragment);
// }
//
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryListPresenter presenter = new StoryListPresenter(repository, newsListFragment);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// // Open the navigation drawer when the home icon is selected from the toolbar.
// if (this.mDrawerLayout != null) {
// this.mDrawerLayout.openDrawer(GravityCompat.START);
// }
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// protected void setupDrawerContent(NavigationView navigationView) {
// navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
// @Override
// public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// int itemId = item.getItemId();
// switch (itemId) {
// case R.id.nav_news_list:
// //do nothing
// break;
// case R.id.nav_feedback:
// break;
// case R.id.nav_about:
// break;
// case R.id.nav_settings:
// break;
// default:
// break;
// }
// // Close the navigation drawer when an item is selected.
// item.setChecked(true);
// if (mDrawerLayout != null) {
// mDrawerLayout.closeDrawers();
// }
// return true;
// }
// });
// }
//
// }
| import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.design.widget.NavigationView;
import android.view.Window;
import android.view.WindowManager;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseActivity;
import org.attentiveness.news.list.StoryListActivity;
import butterknife.ButterKnife; | package org.attentiveness.news.splash;
public class SplashActivity extends BaseActivity {
private CountDownTimer mTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
init();
}
@Override
protected void setupDrawerContent(NavigationView navigationView) {
//do nothing
}
private void init() {
mTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
navigate();
finish();
}
};
mTimer.start();
}
private void navigate() { | // Path: app/src/main/java/org/attentiveness/news/base/BaseActivity.java
// public abstract class BaseActivity extends AppCompatActivity {
//
// @Nullable
// @BindView(R.id.toolbar)
// Toolbar mToolbar;
// @Nullable
// @BindView(R.id.drawer_layout)
// protected DrawerLayout mDrawerLayout;
// @Nullable
// @BindView(R.id.nav_view)
// NavigationView mNavigationView;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// }
//
// protected void setup() {
// setup(-1);
// }
//
// protected void setup(int barIconId) {
// setSupportActionBar(this.mToolbar);
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// if (barIconId > 0) {
// actionBar.setHomeAsUpIndicator(barIconId);
// }
// actionBar.setDisplayHomeAsUpEnabled(true);
// }
//
// if (this.mDrawerLayout != null) {
// this.mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
// }
// if (this.mNavigationView != null) {
// setupDrawerContent(this.mNavigationView);
// }
// }
//
// protected void setupDrawerContent(NavigationView navigationView) {
//
// }
//
// protected void addFragment(FragmentManager fragmentManager, int containerId, Fragment fragment) {
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
// fragmentTransaction.add(containerId, fragment);
// fragmentTransaction.commit();
// }
//
// protected void showMessage(View anchorView, String message) {
// Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/list/StoryListActivity.java
// public class StoryListActivity extends BaseActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_story_list);
// ButterKnife.bind(this);
// setup(R.drawable.ic_menu);
//
// StoryListFragment newsListFragment = (StoryListFragment) getSupportFragmentManager().findFragmentById(R.id.fl_container);
// if (newsListFragment == null) {
// String today = DateUtil.getToday();
// newsListFragment = StoryListFragment.newInstance(today);
// addFragment(getSupportFragmentManager(), R.id.fl_container, newsListFragment);
// }
//
// StoriesDataRepository repository = StoriesDataRepository.getInstance(
// RemoteStoriesDataSource.getInstance(this), LocalStoriesDataSource.getInstance(this));
// StoryListPresenter presenter = new StoryListPresenter(repository, newsListFragment);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// switch (item.getItemId()) {
// case android.R.id.home:
// // Open the navigation drawer when the home icon is selected from the toolbar.
// if (this.mDrawerLayout != null) {
// this.mDrawerLayout.openDrawer(GravityCompat.START);
// }
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
// @Override
// protected void setupDrawerContent(NavigationView navigationView) {
// navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
// @Override
// public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// int itemId = item.getItemId();
// switch (itemId) {
// case R.id.nav_news_list:
// //do nothing
// break;
// case R.id.nav_feedback:
// break;
// case R.id.nav_about:
// break;
// case R.id.nav_settings:
// break;
// default:
// break;
// }
// // Close the navigation drawer when an item is selected.
// item.setChecked(true);
// if (mDrawerLayout != null) {
// mDrawerLayout.closeDrawers();
// }
// return true;
// }
// });
// }
//
// }
// Path: app/src/main/java/org/attentiveness/news/splash/SplashActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.design.widget.NavigationView;
import android.view.Window;
import android.view.WindowManager;
import org.attentiveness.news.R;
import org.attentiveness.news.base.BaseActivity;
import org.attentiveness.news.list.StoryListActivity;
import butterknife.ButterKnife;
package org.attentiveness.news.splash;
public class SplashActivity extends BaseActivity {
private CountDownTimer mTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
init();
}
@Override
protected void setupDrawerContent(NavigationView navigationView) {
//do nothing
}
private void init() {
mTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
navigate();
finish();
}
};
mTimer.start();
}
private void navigate() { | Intent intent = new Intent(this, StoryListActivity.class); |
attentiveness/News | app/src/main/java/org/attentiveness/news/list/StoryListContract.java | // Path: app/src/main/java/org/attentiveness/news/base/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/base/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(@NonNull T presenter);
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
| import android.support.annotation.NonNull;
import org.attentiveness.news.base.BasePresenter;
import org.attentiveness.news.base.BaseView;
import org.attentiveness.news.data.Story;
import java.util.List; | package org.attentiveness.news.list;
interface StoryListContract {
interface View extends BaseView<Presenter> {
| // Path: app/src/main/java/org/attentiveness/news/base/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/base/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(@NonNull T presenter);
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
// Path: app/src/main/java/org/attentiveness/news/list/StoryListContract.java
import android.support.annotation.NonNull;
import org.attentiveness.news.base.BasePresenter;
import org.attentiveness.news.base.BaseView;
import org.attentiveness.news.data.Story;
import java.util.List;
package org.attentiveness.news.list;
interface StoryListContract {
interface View extends BaseView<Presenter> {
| void showStoryList(List<Story> storyList); |
attentiveness/News | app/src/main/java/org/attentiveness/news/list/StoryListContract.java | // Path: app/src/main/java/org/attentiveness/news/base/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/base/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(@NonNull T presenter);
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
| import android.support.annotation.NonNull;
import org.attentiveness.news.base.BasePresenter;
import org.attentiveness.news.base.BaseView;
import org.attentiveness.news.data.Story;
import java.util.List; | package org.attentiveness.news.list;
interface StoryListContract {
interface View extends BaseView<Presenter> {
void showStoryList(List<Story> storyList);
void appendStoryList(List<Story> storyList);
void hideStoryList();
void setLoadingIndicator(boolean active);
void showRetry();
void hideRetry();
void showError(String message);
boolean isActive();
}
| // Path: app/src/main/java/org/attentiveness/news/base/BasePresenter.java
// public interface BasePresenter {
//
// void subscribe();
//
// void unsubscribe();
//
// }
//
// Path: app/src/main/java/org/attentiveness/news/base/BaseView.java
// public interface BaseView<T> {
//
// void setPresenter(@NonNull T presenter);
// }
//
// Path: app/src/main/java/org/attentiveness/news/data/Story.java
// public class Story {
//
// private int id;
// private String title;
//
// @SerializedName("images")
// private List<String> imageList;
//
// public Story() {
//
// }
//
// public Story(int id, String title) {
// this.id = id;
// this.title = title;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public List<String> getImageList() {
// return imageList;
// }
//
// public void setImageList(List<String> imageList) {
// this.imageList = imageList;
// }
// }
// Path: app/src/main/java/org/attentiveness/news/list/StoryListContract.java
import android.support.annotation.NonNull;
import org.attentiveness.news.base.BasePresenter;
import org.attentiveness.news.base.BaseView;
import org.attentiveness.news.data.Story;
import java.util.List;
package org.attentiveness.news.list;
interface StoryListContract {
interface View extends BaseView<Presenter> {
void showStoryList(List<Story> storyList);
void appendStoryList(List<Story> storyList);
void hideStoryList();
void setLoadingIndicator(boolean active);
void showRetry();
void hideRetry();
void showError(String message);
boolean isActive();
}
| interface Presenter extends BasePresenter { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.